We ran into this when writing a Rust wrapper around libmongoc: https://github.com/thijsc/mongo-rust-driver
We use the bson Rust library to prepare bson byte arrays that get converted to libmongoc bsons using bson_new_from_data. This happens here: https://github.com/thijsc/mongo-rust-driver/blob/master/src/bsonc.rs#L31
Rust strings in the bson are converted to bson strings, these can contain null bytes as is allowed in the bson spec. When you try to insert these documents with either a normal insert or a bulk operation the insert fails with this error: "replacement document contains invalid keys)".
After debugging this it looks like libmongoc sets the allow_null option to false when validating bson. I've found no way to override this. It seems like we should just be able to use this bson byte array, since it conforms to the spec. How could we call normal inserts and bulk operations in such a way they will allow this bson?