Sign a release, distribute it, and detect a tampered copy
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
- On the publisher, create the release:
printf 'lab release v1\n' > release.txt, and publish a digest filerelease.sha256beside it. - Sign the digest with the server key from the PKI lab, producing
release.sig, and placeroot.crtandintermediate.crtalongside. - Serve the four files on the lab network only:
python3 -m http.server 8080 --bind 10.99.0.10. - 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. - Now tamper. Modify
release.txton the publisher WITHOUT updating anything else, and repeat the recipient's three checks. Record which one failed. - Tamper the second way: modify
release.txtAND regeneraterelease.sha256to match, leaving the signature alone. Repeat the checks and record which one failed this time. - 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.
- Write
/tmp/release-report.mdmapping 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.