Sign a release, distribute it, and detect a tampered copy

capstone · 120 min · Objective 1.4

Task

Pull Domain 1 together into one exercise: publish a signed artefact with a certificate chain you built, verify it as a recipient would, then tamper with it and show precisely which check catches the tampering and which does not.

Steps

  1. On the publisher, create the release: printf 'lab release v1\n' > release.txt, and publish a digest file release.sha256 beside it.
  2. Sign the digest with the server key from the PKI lab, producing release.sig, and place root.crt and intermediate.crt alongside.
  3. Serve the four files on the lab network only: python3 -m http.server 8080 --bind 10.99.0.10.
  4. On the recipient, retrieve all four from http://10.99.0.10:8080/ and verify in the right order: first the certificate chain, then the signature over the digest, then the digest against the file.
  5. Now tamper. Modify release.txt on the publisher WITHOUT updating anything else, and repeat the recipient's three checks. Record which one failed.
  6. Tamper the second way: modify release.txt AND regenerate release.sha256 to match, leaving the signature alone. Repeat the checks and record which one failed this time.
  7. Tamper the third way: sign the new digest with a DIFFERENT key you generate now, and present that key's self-signed certificate. Repeat the checks and record which one failed.
  8. Write /tmp/release-report.md mapping each of the three tampering methods to the check that caught it, and state which check would have been the only defence if the other two were skipped.

Verify

openssl verify -CAfile root.crt -untrusted intermediate.crt server.crt
openssl dgst -sha256 -verify pub.pem -signature release.sig release.sha256
sha256sum -c release.sha256
grep -ciE "chain|signature|digest" /tmp/release-report.md

Run all three checks after each tampering round and record the outcomes. The first round must fail at sha256sum -c; the second must pass the digest check and fail the signature check; the third must pass both and fail the chain verification. The grep must be at least three — the report maps every method to its check.

Notes

The third round is the one that matters, and it is the supply chain problem from Domain 2 in miniature: the attacker produced a perfectly valid digest and a perfectly valid signature. Only the certificate chain — the question of WHOSE key signed it — caught them. An organisation that checks digests and signatures but never validates the signer has a verification process that a self-signed key defeats.

This is an independent study companion for CompTIA Security+ SY0-701 and is not produced by or endorsed by CompTIA.