CVE-2026-62157: mongo_fdw out-of-bounds read when building an ObjectId from short _id values
mongofdw converts id values to 12-byte MongoDB ObjectIds with libbson functions that read a fixed number of bytes without checking the input length: 12 bytes for a bytea id, and 24 characters for name-typed values and $oid fields in JSON. A shorter value causes a read past the end of the input, which can crash the PostgreSQL backend or include adjacent memory in the query sent to MongoDB. Any user who can supply an id value or predicate on a foreign table can trigger it. The issue is fixed in mongofdw 5.6.0. From mongofdw 5.6.0, mongofdw accepts only valid 24-character hexadecimal ObjectIds and 12-byte bytea values.
Affected Software
Remediation
Recommended actions to resolve this vulnerability, in priority order.
- Upgrade
Upgrade
mongo_fdwto a version that resolves this vulnerability.Fixed in 5.6.0
Event History
Frequently Asked Questions
Who can trigger this issue?
Any user who can supply an _id value or a predicate on a mongo_fdw foreign table can trigger the out-of-bounds read. This can crash the PostgreSQL backend or cause adjacent memory to be included in a query sent to MongoDB.
What input values are unsafe in affected versions?
Bytea _id values shorter than 12 bytes are unsafe. Name-typed values and JSON $oid fields shorter than 24 characters are also unsafe because the conversion reads a fixed-length ObjectId input without validating its length.
Are default deployments affected?
The issue applies where users can provide _id values or predicates against mongo_fdw foreign tables. The provided information does not establish whether such access is available in a default deployment.
What changes in the fixed release?
mongo_fdw 5.6.0 fixes the issue by accepting only valid 24-character hexadecimal ObjectIds and 12-byte bytea values.
What can be done before upgrading?
Restrict untrusted users from supplying _id values or predicates on mongo_fdw foreign tables, and reject short bytea, name-typed, and JSON $oid inputs before they reach mongo_fdw.