Skip to content
Pwnversity
CRYPTO-PKIintermediate · 5 min · upd. 2026-10

PKI & certificates

CWE-295

Asymmetric cryptography and PKI (Public Key Infrastructure) underpin TLS, code signing, encrypted email, and certificate authentication. This card covers how the chain of trust works and the attacks that appear when validation is done wrong.

A PKI is the ecosystem of keys, certificates, and authorities that lets you trust a public key without having exchanged it in person beforehand. An X.509 certificate binds a public key to an identity (domain, person, code) through the signature of a certificate authority (CA) we already trust.

At the base is the asymmetric key pair:

  • Encryption: encrypt with the recipient’s public key; only their private key decrypts (confidentiality).
  • Signing: sign with your own private key; anyone verifies with the public key (authenticity and non-repudiation).
  • RSA: based on the hardness of factoring. Use RSA-OAEP (encryption) and RSA-PSS (signing), never raw PKCS#1 v1.5.
  • ECC: elliptic curves; short keys with the same security. Ed25519 (signing, RFC 8032), X25519 (exchange, RFC 7748).

Asymmetric cryptography is solid; what breaks is validation. If the client doesn’t correctly verify the chain, the name, or revocation, a network-positioned attacker presents their own certificate and performs a full MITM. The other major front is the private key: if it leaks or is weak, all trust collapses.

flowchart TD
    Root[Root CA - OS/browser truststore] -->|signs| Inter[Intermediate CA]
    Inter -->|signs| Leaf[Server certificate - CN/SAN = domain]
    Leaf --> V{Client validation}
    V --> C1[Signature of each link up to a trusted CA]
    V --> C2[Validity: not expired]
    V --> C3[SAN matches the host]
    V --> C4[Revocation: CRL / OCSP]

Validating a certificate means verifying the signature of each link up to a trusted CA, and also checking validity, matching the name (SAN) to the host, and the revocation status.

Broken certificate validation (clients and apps)

Section titled “Broken certificate validation (clients and apps)”

The most common flaw in mobile apps, IoT, and custom clients:

  • Not validating the chain → accepts a self-signed certificate → MITM.
  • Not checking the hostname (SAN) → a valid certificate for another domain works → MITM.
  • Accepting expired or revoked certificates.
Ventana de terminal
# Intercept with a proxy that presents its own certificate;
# if the client accepts it without complaint, validation is broken
mitmproxy --mode regular --listen-port 8080
# Inspect a real certificate
openssl s_client -connect example.com:443 -servername example.com </dev/null \
| openssl x509 -noout -text
  • alg=none: some verifiers accept a token with no signature.
  • RS256 → HS256: if the verifier doesn’t pin the algorithm, you sign with the public key (known) treated as an HMAC secret. See JWT.
  • RSA with a small key (< 2048 bits) or poorly generated primes (twin keys from a weak RNG, see Weak randomness (RNG)).
  • Private key exposed in repositories, binaries, or firmware → full impersonation.
  • PKCS#1 v1.5 padding → Bleichenbacher/ROBOT (RSA padding oracle). See Padding oracle.
  • Always validate chain + hostname + validity + revocation; don’t disable verification “to make it work”.
  • Certificate pinning in high-value mobile apps; use RSA ≥ 2048 or ECC, with OAEP/PSS.
  • Protect the private key (HSM/KMS, strict permissions); monitor issuance with Certificate Transparency.
  • JWT: pin the expected algorithm on the server; reject none and the RS→HS switch.
  • goto fail (CVE-2014-1266, Apple): a duplicated goto skipped TLS signature verification.
  • DigiNotar (2011): a compromised CA issued fake Google certificates, used for MITM in Iran.
  • ROBOT (2017): revival of the RSA PKCS#1 v1.5 padding oracle at large sites and load balancers.
  • Client/app: does it validate chain and hostname? (MITM with a proxy)
  • Does it accept self-signed, expired, or revoked certificates?
  • JWT: test alg=none and RS256→HS256 confusion
  • RSA key size/quality? Repeated keys from a weak RNG?
  • Look for leaked private keys (repos, firmware, binaries)
  • RSA: PKCS#1 v1.5 padding vulnerable to an oracle?
  • Recon: enumerate subdomains via crt.sh (Certificate Transparency)