fix: add minimum size guard and @security PHPDoc to ZVecDoc::deserialize()#150
Merged
Conversation
…ize() Add trust boundary protection to ZVecDoc::deserialize() to prevent crashes from trivially small payloads. The C++ layer crashes on malformed data, so the PHP layer now rejects inputs shorter than 8 bytes before they reach the FFI boundary. Changes: - Add minimum size check (8 bytes) to ZVecDoc::deserialize() - Add @security PHPDoc warning about untrusted data - Add 4 .phpt tests for deserialization edge cases Fixes #81
The native zvec extension does not have the minimum size guard added to the FFI PHP layer. Skip these tests when the native extension is loaded to avoid false failures in CI.
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 trust boundary protection to
ZVecDoc::deserialize()to prevent crashes from trivially small payloads. The C++ layer crashes on malformed data, so the PHP layer now rejects inputs shorter than 8 bytes before they reach the FFI boundary.Changes
ZVecDoc::deserialize()@securityPHPDoc warning about untrusted datatest_deserialize_empty.phpt— rejects empty stringtest_deserialize_too_short.phpt— rejects data shorter than 8 bytestest_deserialize_valid.phpt— round-trip preserves all fieldstest_deserialize_trust_boundary.phpt— malformed data handlingTest Results
All 144 tests pass (1 skipped, 2 expected failures). No regressions.
Fixes #81