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.
[Warning] This PR is generated by AI
Pull Request Description for Fixing Vulnerability - OSV-2024-343
pcapplusplus
- OSV-2024-343pcapplusplus
project where a heap-buffer-overflow occurred due to an out-of-bounds memory access in theBgpUpdateMessageLayer
class. This issue was detected in the functiongetPathAttributesLength()
which is part ofBgpLayer.cpp
. The vulnerability allows memory access outside of allocated bounds, potentially leading to undefined behavior or program crashes.getPathAttributesLength()
function to ensure that the memory access remains within the allocated buffer's limits. Specifically, the fix checks the calculated offset against the total buffer size (headerLen
) and returns0
if the access is invalid. This modification effectively prevents the heap-buffer-overflow by ensuring all accesses are safe and within bounds.pcapplusplus
program by ensuring robust handling of invalid memory access scenarios.The sanitizer detected a heap-buffer-overflow error in the function
getPathAttributesLength()
located inBgpLayer.cpp:546
. The issue was caused by accessing heap memory beyond its allocated size, and the error was triggered during fuzz testing. The stack trace indicated that the vulnerability propagates through thesetPathAttributes
andclearPathAttributes
functions, leading to an invalid memory access in thereadParsedPacket
function during fuzzing.Files Modified:
The patch modifies the following file:
Packet++/src/BgpLayer.cpp
The patch has been validated using the provided PoC and fuzzing tools. The heap-buffer-overflow issue reported in the sanitizer report has been resolved. Additionally, no new issues or regressions were introduced during the testing process.
Please review and merge the patch to ensure that the program is secure and stable. Thank you!