Lion Cipher Lab
Validate X.509 Certificate Paths From Scratch (and Break the Naive Ones)
- Identity & Access Management
- Advanced
- ~60 min
- Free · no account required
Why it matters
Every TLS handshake your browser makes depends on certificate-path validation being correct, and the history of web PKI is a graveyard of validators that got it subtly wrong — the most famous being the class of bug where a validator forgets to check basicConstraints, letting anyone with a legitimately-issued leaf certificate mint trusted-looking certs for any domain they like. Building the validator yourself, then removing one check at a time and watching a forged victim.com certificate sail through, moves 'validate the chain' from a phrase in a diagram to something you understand at the…
What you'll learn
- X.509 path validation
- RFC 5280 chain building
- basicConstraints & keyUsage
- certificate signature verification
- CA-impersonation bug class
- secure use of pyca/cryptography
Steps in this lab
- What path validation is, and why we build it to break it
- Set up Python and the cryptography library
- Generate a 3-cert hierarchy plus the attacker's material
- Write the from-scratch validator
- Run the honest chain: it should be VALID
- The headline bug: skip basicConstraints and impersonate any CA
- Three more classic omissions: expiry, anchoring, and pathLen
- The judgment call: never ship this in production