IDL→Rust codegen: the bounded-string length check is emitted without regard to
|
Replies: 1 comment
|
Thank you, @swarm59, for the precise report and the compiler diagnostic. You were exactly right: the generated bound check did not carry the member’s The direct failure is fixed on Your report led us into two substantially broader audits. First, we found that the decoder side often checked only whether enough bytes remained in the input buffer, but did not enforce the bound declared by the IDL type itself. A well-formed peer could therefore send a value larger than Second, following the same untrusted-length pattern beyond generated IDL code uncovered a wider allocation-hardening family. Several handwritten network decoders could reserve memory from a wire-supplied length before validating it against the remaining frame or a protocol limit. The follow-up in Each corrected path has a regression proving that an over-bound or oversized value is rejected cleanly while a valid within-bound value still round-trips. The complete public I am closing this discussion as fixed. If an optional bounded member still fails to compile, or if you find another generated decoder that accepts a value beyond its declared IDL bound, please let us know here — we will be very happy to reopen the discussion and investigate further. Thank you again for a report that ultimately improved not only the original Rust code-generation path, but bound enforcement and untrusted-input handling across a much wider part of the project. |
Thank you, @swarm59, for the precise report and the compiler diagnostic. You were exactly right: the generated bound check did not carry the member’s
@optionalstate into the emitted expression, so it called.len()directly on anOption<String>and produced uncompilable Rust.The direct failure is fixed on
maininbd7e592. Bound checks for optional members are now guarded and applied only when a value is present, on both the encode and decode paths.Your report led us into two substantially broader audits.
First, we found that the decoder side often checked only whether enough bytes remained in the input buffer, but did not enforce the bound declared by the IDL type itself. A well-formed …