-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Summary: In both the binary and compact protocols, previously it was possible for the `Vec::with_capacity` and `HashSet::with_capacity_and_hasher` and `HashMap::with_capacity_and_hasher` in these types' `fbthrift::Deserialize` impls to allocate arbitrarily big collections when fed a small Thrift message containing a large collection size. This makes Rust Thrift servers vulnerable to Denial Of Service from maliciously crafted Thrift messages, or even just unlucky garbage messages. This diff makes these Deserialize impls short-circuit with `ProtocolError::EOF` if the remaining input data cannot possibly contain the number of collection elements claimed by the collection size. For example, in compact protocol which represents `f32` using 4 bytes, deserializing `Vec<f32>` with 4000 bytes remaining in the input data will not bother trying to allocate a Vec with capacity larger than 1000. In particular, it will no longer try to allocate a Vec with capacity 10¹⁵, even if the serialized collection size claims that the input contains 10¹⁵ list elements. Reviewed By: zertosh Differential Revision: D68986442 fbshipit-source-id: a3885833d6d49f581912ffcb1365af381671a28e
- Loading branch information
1 parent
5b7b835
commit e68f20c
Showing
7 changed files
with
218 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters