security-fix-3#462
Merged
Merged
Conversation
Signed-off-by: Shubhangi Shrivastava <shubhangi.shrivastava@intel.com>
There was a problem hiding this comment.
Pull request overview
This PR aims to harden reverse acceleration checks in the NFA runtime, likely to prevent out-of-bounds reads when evaluating reverse double-EOD (two-byte) acceleration.
Changes:
- Added length guards before performing 16-bit loads in
ACCEL_RDEODandACCEL_RDEOD_NOCASEpaths. - Adjusted control flow to skip the accel check when the new guard fails.
Comments suppressed due to low confidence (2)
src/nfa/nfa_rev_api.h:113
- The new bounds check for ACCEL_RDEOD is off by one and doesn’t guarantee the u16 load is in-bounds.
unaligned_load_u16(buffer + length - rAccelOffset)is safe whenlength >= rAccelOffsetandrAccelOffset >= 2; the currentlength < rAccelOffset + 1unnecessarily skips the safelength == rAccelOffsetcase, and still allows an out-of-bounds read if a corrupted NFA ever hasrAccelOffset == 1.
case ACCEL_RDEOD:
DEBUG_PRINTF("ACCEL_RDEOD\n");
if (length < nfa->rAccelOffset + 1) {
break;
}
if (unaligned_load_u16(buffer + length - nfa->rAccelOffset) !=
nfa->rAccelData.dc) {
return 0;
}
src/nfa/nfa_rev_api.h:123
- Same issue as ACCEL_RDEOD: the
length < rAccelOffset + 1check is stricter than necessary (skipslength == rAccelOffset) and doesn’t protect the u16 load ifrAccelOffsetis ever 1 (e.g., corrupted/invalid NFA). For a 16-bit load, explicitly requirerAccelOffset >= 2andlength >= rAccelOffset.
case ACCEL_RDEOD_NOCASE:
DEBUG_PRINTF("ACCEL_RDEOD_NOCASE\n");
if (length < nfa->rAccelOffset + 1) {
break;
}
if ((unaligned_load_u16(buffer + length - nfa->rAccelOffset) &
DOUBLE_CASE_CLEAR) != nfa->rAccelData.dc) {
return 0;
}
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
nirint
approved these changes
Jun 1, 2026
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.
No description provided.