Problem and impact
PyMongo accepts a stapled OCSP response without verifying that it covers the presented TLS certificate. A revoked endpoint can therefore staple a genuine issuer-signed Good response for a different certificate from the same CA and complete the handshake. The client then volunteers credentials (PLAIN passwords, OIDC tokens) to the revoked endpoint.
Detailed steps to reproduce the problem
- Connect over TLS to a server presenting a revoked, must-staple certificate stapled with a Good response issued for a different certificate from the same CA (pymongo[ocsp] extra installed).
- The connection succeeds and authenticates. Reproduce with the PoC attached to SECBUG-5809.
Definition of done: what must be done to consider the task complete?
- PyMongo rejects a stapled OCSP response that does not cover the presented certificate and ends the connection, per the MongoDB OCSP spec's suggested behavior #2.
- Regression tests cover the rejection case.
The exact version of PyMongo used, with patch level
All releases from 3.11.0 up to the fix in 4.20.2 (3.11 < 4.20.2), including master. Only the synchronous driver with the pymongo[ocsp] extra is affected; the asynchronous driver is not.
Security Vulnerabilities
Tracked as SECBUG-5809 (embargoed HackerOne report; mirrored in SECBUG-5802). Keep this ticket restricted to MongoDB Internal and coordinate disclosure through Product Security.