Validate guest-writable fields in try_pop_buffer_into before allocation#1262
Conversation
24dccad to
7d51b11
Compare
The back-pointer and flatbuffer size prefix in the shared output buffer are written by the guest and were used without validation, allowing a malicious guest to trigger a ~4 GB host-side allocation. Add bounds checks on both fields before any heap allocation occurs and return descriptive errors on violation. Add unit and integration tests exercising corrupt size prefixes and back-pointers. Signed-off-by: Ludvig Liljenberg <4257730+ludfjig@users.noreply.github.com>
7d51b11 to
56d40f6
Compare
There was a problem hiding this comment.
The arithmetic overflows causing unintentional panics issue I bet is something we have in other places. (I stand by some of the arguments I made earlier about panic-ing being reasonable behaviour in some situations---but it's important that we are directly aware of the panic opportunities and clear on whether they make sense---i.e. we should have a sensible reasoned argument why they ought to be impossible, even in the face of attacker-controlled data). It would be interesting to take a look at e.g. enumerating every cfg path from any exported function to panic (on an opt build, so that a bunch of the easy ones are gone) and see how much work it would be to make an argument either way on each path.
try_pop_buffer_intoreads two values from guest-writable shared memoryChanges: