Commit d433363
Validate SVS-Vamana stored_vectors size on deserialization (ISV2) (#5434)
Summary:
Pull Request resolved: #5434
The `ISV2` (IndexSVSVamana) deserialization branch reads `ntotal`, `d`
(header), and the raw `stored_vectors` payload as independent fields and
never re-establishes the invariant `stored_vectors.size() == ntotal * d`
that the programmatic `add()` path maintains.
`IndexSVSVamana::reconstruct` guards only `key < ntotal` and
`stored_vectors` non-empty, then `memcpy`s `sizeof(float) * d` bytes from
`stored_vectors.data() + key * d`. A crafted index declaring e.g.
`ntotal=1, d=256` with a 1-element payload reads ~1 KiB past the heap
allocation (heap-buffer-overflow read).
Adds the `stored_vectors.size() == ntotal * d` check at deserialization,
matching the sibling flat-codes readers, converting the OOB read into a
clean FaissException. The SVS family is compile-gated (FAISS_ENABLE_SVS,
x86_64). Found by agentic fuzzing.
Reviewed By: trang-nm-nguyen
Differential Revision: D112368334
fbshipit-source-id: ba4ba275dd0444216139921c8d15628ccbb29fc01 parent dfd2a25 commit d433363
1 file changed
Lines changed: 7 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2851 | 2851 | | |
2852 | 2852 | | |
2853 | 2853 | | |
| 2854 | + | |
| 2855 | + | |
| 2856 | + | |
| 2857 | + | |
| 2858 | + | |
| 2859 | + | |
| 2860 | + | |
2854 | 2861 | | |
2855 | 2862 | | |
2856 | 2863 | | |
| |||
0 commit comments