-
Notifications
You must be signed in to change notification settings - Fork 683
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix Heap-buffer-overflow in __parse_options #1678
base: dev
Are you sure you want to change the base?
Fix Heap-buffer-overflow in __parse_options #1678
Conversation
Close and reopen to run CI after changing base branch. |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## dev #1678 +/- ##
==========================================
- Coverage 83.16% 83.15% -0.02%
==========================================
Files 277 277
Lines 48193 48203 +10
Branches 9966 9975 +9
==========================================
Hits 40081 40081
- Misses 7234 7246 +12
+ Partials 878 876 -2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
actual_length = (opt->option_length % alignment) == 0 ? | ||
opt->option_length : | ||
(opt->option_length / alignment + 1) * alignment; | ||
|
||
if (actual_length > 0) { | ||
if (actual_length > 0 && actual_length <= max_len - 2 * sizeof(*local_memory)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if this is enough to terminate the parsing operation.
If the actual length is out of bounds, the recursion continues.
Also remaining_size
on L69 will underflow from the subtraction.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if this is enough to terminate the parsing operation.
If the actual length is out of bounds, the recursion continues. Also
remaining_size
on L69 will underflow from the subtraction.
Should we terminate immediately when overflow is found? patch similar to L52.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I think terminating immediately is better...
Also @aled-ua please use the // PCPP patch
comment when making changes in LightPcapNg (you can find it in various places in LightPcapNg code), since it's a 3rd-party library and we'd like to contribute it back at some point
[Warning] This PR is generated by AI
PR Title: Fix for Heap-buffer-overflow Vulnerability in pcapplusplus
PR Description:
__parse_options
function in the LightPcapNg library utilized by pcapplusplus.option_length
variable. It ensures that memory operations likememcpy
are only performed within valid memory bounds. This prevents the program from accessing out-of-bounds memory, thereby improving the security and stability of the program.Sanitizer Report Summary: The AddressSanitizer detected a heap-buffer-overflow triggered when the program attempted to read 72 bytes from a 40-byte allocated region. This error originated in the
__parse_options
function in/3rdParty/LightPcapNg/LightPcapNg/src/light_pcapng.c:58:10
, which was called through a chain ultimately leading toLLVMFuzzerTestOneInput
.Full Sanitizer Report:
Files Modified:
/3rdParty/LightPcapNg/LightPcapNg/src/light_pcapng.c
Patch Validation: The patch has been validated and confirmed to resolve the heap-buffer-overflow issue identified in the sanitizer report. The program has been tested using the provided PoC, and no new issues were introduced.
Links: