validate cascade node feature index before init#466
Open
metsw24-max wants to merge 1 commit into
Open
Conversation
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.
Out-of-bounds feature index in cascade nodes
DetectionLoadStringXmlparses untrusted cascade XML and stores each weak-classifier nodesfeatureIdxstraight from theinternalNodestext, with no range check. That index is later used to look a feature up:CreateHidHaarreadsdata.haarFeatures[node.featureIdx]during init, and the LBP predictor indexeshid.features[node->featureIdx]. A cascade whose node points past the parsed feature list (or a negative value) therefore reads off the end of the vector. With ASan a node index of999999against a single feature faults atSimdBaseDetection.cpp:393inCreateHidHaar`.The recently merged rect checks guarded the per-rect value vectors but not this node-to-feature reference, so it was still reachable. Validating the index once in the loader keeps the rejection at the parse boundary and covers both the HAAR and LBP paths. I have kept it to a range check raising the existing
SIMD_EX; valid cascades are unaffected.