Validate id_map size matches ntotal in IndexBinaryIDMap deserialization (#4917)#4917
Closed
scsiguy wants to merge 2 commits into
Closed
Validate id_map size matches ntotal in IndexBinaryIDMap deserialization (#4917)#4917scsiguy wants to merge 2 commits into
scsiguy wants to merge 2 commits into
Conversation
Contributor
scsiguy
added a commit
to scsiguy/faiss
that referenced
this pull request
Mar 12, 2026
…on (facebookresearch#4917) Summary: Add a check in the `IBMp`/`IBM2` deserialization path that rejects input where `id_map.size() != ntotal`. Without this validation, a crafted index with a mismatched `id_map` would silently deserialize, and subsequent `search()` or `reconstruct()` calls would use an inconsistent ID mapping. For `IndexBinaryIDMap2`, the downstream `construct_rev_map()` call would also build a corrupted reverse map. Reviewed By: mnorris11 Differential Revision: D96333421
scsiguy
added a commit
to scsiguy/faiss
that referenced
this pull request
Mar 12, 2026
…on (facebookresearch#4917) Summary: Add a check in the `IBMp`/`IBM2` deserialization path that rejects input where `id_map.size() != ntotal`. Without this validation, a crafted index with a mismatched `id_map` would silently deserialize, and subsequent `search()` or `reconstruct()` calls would use an inconsistent ID mapping. For `IndexBinaryIDMap2`, the downstream `construct_rev_map()` call would also build a corrupted reverse map. Reviewed By: mnorris11 Differential Revision: D96333421
9d79640 to
e53e658
Compare
scsiguy
added a commit
to scsiguy/faiss
that referenced
this pull request
Mar 12, 2026
…on (facebookresearch#4917) Summary: Add a check in the `IBMp`/`IBM2` deserialization path that rejects input where `id_map.size() != ntotal`. Without this validation, a crafted index with a mismatched `id_map` would silently deserialize, and subsequent `search()` or `reconstruct()` calls would use an inconsistent ID mapping. For `IndexBinaryIDMap2`, the downstream `construct_rev_map()` call would also build a corrupted reverse map. Reviewed By: mnorris11 Differential Revision: D96333421
scsiguy
added a commit
to scsiguy/faiss
that referenced
this pull request
Mar 12, 2026
…on (facebookresearch#4917) Summary: Add a check in the `IBMp`/`IBM2` deserialization path that rejects input where `id_map.size() != ntotal`. Without this validation, a crafted index with a mismatched `id_map` would silently deserialize, and subsequent `search()` or `reconstruct()` calls would use an inconsistent ID mapping. For `IndexBinaryIDMap2`, the downstream `construct_rev_map()` call would also build a corrupted reverse map. Reviewed By: mnorris11 Differential Revision: D96333421
scsiguy
added a commit
to scsiguy/faiss
that referenced
this pull request
Mar 12, 2026
…on (facebookresearch#4917) Summary: Add a check in the `IBMp`/`IBM2` deserialization path that rejects input where `id_map.size() != ntotal`. Without this validation, a crafted index with a mismatched `id_map` would silently deserialize, and subsequent `search()` or `reconstruct()` calls would use an inconsistent ID mapping. For `IndexBinaryIDMap2`, the downstream `construct_rev_map()` call would also build a corrupted reverse map. Reviewed By: mnorris11 Differential Revision: D96333421
scsiguy
added a commit
to scsiguy/faiss
that referenced
this pull request
Mar 12, 2026
…on (facebookresearch#4917) Summary: Pull Request resolved: facebookresearch#4917 Add a check in the `IBMp`/`IBM2` deserialization path that rejects input where `id_map.size() != ntotal`. Without this validation, a crafted index with a mismatched `id_map` would silently deserialize, and subsequent `search()` or `reconstruct()` calls would use an inconsistent ID mapping. For `IndexBinaryIDMap2`, the downstream `construct_rev_map()` call would also build a corrupted reverse map. Reviewed By: mnorris11 Differential Revision: D96333421
e53e658 to
1fffd75
Compare
Summary: In `read_binary_multi_hash_map()`, individual `ilsz` values are read from the untrusted bitstring buffer and used to control an inner loop that calls `BitstringReader::read()`. The existing buffer-size check validates total expected bits assuming `sum(ilsz) == ntotal`, but crafted `ilsz` values can violate this invariant and cause the reader to consume bits past the end of the buffer. Add a running `total_ids` counter and reject any `ilsz` that would push the cumulative ID count past `ntotal`, throwing a descriptive `FaissException` before the overrun occurs. Differential Revision: D96329613
scsiguy
added a commit
to scsiguy/faiss
that referenced
this pull request
Mar 13, 2026
…on (facebookresearch#4917) Summary: Add a check in the `IBMp`/`IBM2` deserialization path that rejects input where `id_map.size() != ntotal`. Without this validation, a crafted index with a mismatched `id_map` would silently deserialize, and subsequent `search()` or `reconstruct()` calls would use an inconsistent ID mapping. For `IndexBinaryIDMap2`, the downstream `construct_rev_map()` call would also build a corrupted reverse map. Reviewed By: mnorris11 Differential Revision: D96333421
1fffd75 to
2e722b7
Compare
scsiguy
added a commit
to scsiguy/faiss
that referenced
this pull request
Mar 13, 2026
…on (facebookresearch#4917) Summary: Add a check in the `IBMp`/`IBM2` deserialization path that rejects input where `id_map.size() != ntotal`. Without this validation, a crafted index with a mismatched `id_map` would silently deserialize, and subsequent `search()` or `reconstruct()` calls would use an inconsistent ID mapping. For `IndexBinaryIDMap2`, the downstream `construct_rev_map()` call would also build a corrupted reverse map. Reviewed By: mnorris11 Differential Revision: D96333421
scsiguy
added a commit
to scsiguy/faiss
that referenced
this pull request
Mar 13, 2026
…on (facebookresearch#4917) Summary: Add a check in the `IBMp`/`IBM2` deserialization path that rejects input where `id_map.size() != ntotal`. Without this validation, a crafted index with a mismatched `id_map` would silently deserialize, and subsequent `search()` or `reconstruct()` calls would use an inconsistent ID mapping. For `IndexBinaryIDMap2`, the downstream `construct_rev_map()` call would also build a corrupted reverse map. Reviewed By: mnorris11 Differential Revision: D96333421
…on (facebookresearch#4917) Summary: Pull Request resolved: facebookresearch#4917 Add a check in the `IBMp`/`IBM2` deserialization path that rejects input where `id_map.size() != ntotal`. Without this validation, a crafted index with a mismatched `id_map` would silently deserialize, and subsequent `search()` or `reconstruct()` calls would use an inconsistent ID mapping. For `IndexBinaryIDMap2`, the downstream `construct_rev_map()` call would also build a corrupted reverse map. Reviewed By: mnorris11 Differential Revision: D96333421
2e722b7 to
0a554c6
Compare
scsiguy
added a commit
to scsiguy/faiss
that referenced
this pull request
Mar 13, 2026
…on (facebookresearch#4917) Summary: Add a check in the `IBMp`/`IBM2` deserialization path that rejects input where `id_map.size() != ntotal`. Without this validation, a crafted index with a mismatched `id_map` would silently deserialize, and subsequent `search()` or `reconstruct()` calls would use an inconsistent ID mapping. For `IndexBinaryIDMap2`, the downstream `construct_rev_map()` call would also build a corrupted reverse map. Reviewed By: mnorris11 Differential Revision: D96333421
Contributor
|
This pull request has been merged in cdb7254. |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary:
Add a check in the
IBMp/IBM2deserialization path that rejectsinput where
id_map.size() != ntotal. Without this validation,a crafted index with a mismatched
id_mapwould silently deserialize,and subsequent
search()orreconstruct()calls would use aninconsistent ID mapping. For
IndexBinaryIDMap2, the downstreamconstruct_rev_map()call would also build a corrupted reverse map.Reviewed By: mnorris11
Differential Revision: D96333421