Skip to content

Digital Signatures

A digital signature proves that data came from the holder of a private key and has not been changed since. Anyone with the public key can check it. It provides integrity and authenticity, and non-repudiation when the key is controlled by one party.

DraftLast reviewed Oct 11, 20261 scriptEdit this page on GitHub

This page is a draft: its scripts were tested in a lab, but its references still need an independent review.

On this page

After this lesson you can

  • Explain what Digital Signatures is in your own words.
  • Describe how the attack or technique works.
  • Walk through a real-world example from start to finish.
  • Recognise it using the detection techniques in this lesson.
  • Apply the prevention methods described here.
  • Read and run the Python script in a lab you control.
  • Relate the topic to T1553.002, CWE-347 in the standards.

Last reviewed: 2026-10-11 | Status: Draft (new topic; scripts tested against local lab targets, references not yet independently re-verified)

Standards mapping

FrameworkReference
OWASP Top 10:2025Software or Data Integrity Failures; Cryptographic Failures
MITRE ATT&CK (v19)Related: Defense Evasion code-signing abuse (T1553.002)
CWECWE-347 Improper Verification of Cryptographic Signature
CAPECnot applicable
ExampleFlame malware forged a Microsoft code-signing certificate (2012)

What it is

A digital signature proves that data came from the holder of a private key and has not been changed since. Anyone with the public key can check it. It provides integrity and authenticity, and non-repudiation when the key is controlled by one party.

How it works

The signer hashes the data and transforms the hash with the private key. The verifier recomputes the hash and checks it against the signature with the public key. Any change to the data, the signature or the signed metadata makes verification fail. The weak points are usually key theft, weak hash functions and verifiers that skip or mishandle the check.

Real-world example

The Flame malware (2012) used a chosen-prefix collision against the MD5 hash to forge a certificate chaining to Microsoft's, letting malicious code appear to be signed by Microsoft. Microsoft revoked the affected certificates (Security Advisory 2718704).

Detection

  • Find unsigned artifacts that should be signed (packages, releases, containers, firmware)
  • Alert on signature verification failures instead of logging and continuing
  • Monitor certificate transparency logs and code-signing key usage

Prevention

In order of strength. The first items fix the cause; the rest reduce risk.

  1. Use modern algorithms: Ed25519 or ECDSA P-256, or RSA-PSS with 3072-bit keys; never MD5 or SHA-1
  2. Verify before use, fail closed, and check that the signing key is the one you expect (pin the key id)
  3. Protect signing keys in an HSM or a managed key service; separate build and signing duties
  4. Sign metadata together with the file hash so none of it can be swapped
  5. Plan revocation and key rotation before you need them

Scripts in this topic

  • file_signer.py: Ed25519 key generation, detached signatures, strict verification

Common mistakes

  • Verifying that a signature is well-formed but not who made it
  • Trusting a signature when the public key came from the same download
  • Signing only the file name or a timestamp, not the content hash
  • Treating a valid signature as proof the software is safe: it proves origin only

Test it safely

Use file_signer.py in a scratch folder: sign a file, change one byte, and watch verification fail.

Practical Python labs

Open a script to read its source and copy the run commands. Run security tools only on systems you own or have written permission to test.

Check what you have covered

These questions are generated from this lesson's category, standards mapping and scripts. They test where things live in the guide, not how well you understand the concepts. Nothing is saved or tracked.

1.Which category is "Digital Signatures" part of?
2.Which MITRE ATT&CK identifier is listed in the standards mapping for "Digital Signatures"?
3.Which of these scripts belongs to the "Digital Signatures" lesson?

References