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.11% 83.10% -0.02%
==========================================
Files 277 277
Lines 48207 48212 +5
Branches 10192 9919 -273
==========================================
- Hits 40069 40065 -4
- Misses 7243 7251 +8
- Partials 895 896 +1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
| (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.
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.
Not sure if this is enough to terminate the parsing operation.
If the actual length is out of bounds, the recursion continues. Also
remaining_sizeon 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.
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
There was a problem hiding this comment.
@Dimi1010 can you re-review the PR before merging? It looks good to me but it'd be good to have another pair of eyes looking at it
1fbb74c to
6c5d27f
Compare
[Warning] This PR is generated by AI
PR Title: Fix for Heap-buffer-overflow Vulnerability in pcapplusplus
PR Description:
__parse_optionsfunction in the LightPcapNg library utilized by pcapplusplus.option_lengthvariable. It ensures that memory operations likememcpyare 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_optionsfunction 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.cPatch 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: