-
Notifications
You must be signed in to change notification settings - Fork 721
Add boundary checks to prevent memory safety issues in BgpLayer::getHeaderLen #1954
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
Open
danasana
wants to merge
8
commits into
seladb:dev
Choose a base branch
from
danasana:bugfix/bgp-headerlen-memory-safety
base: dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 2 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
7a836de
Add boundary checks to prevent out-of-bounds access in BgpLayer::getH…
danasana 8e73f57
Add poc files to regression_samples
danasana 913e63c
Move common validation before branch point to avoid redundancy
danasana ae1ed33
Change C-style casts to static_cast
danasana 4c839c7
Remove mistakenly added files
danasana 936c316
Add check to ensure offsetInLayer is not negative in Layer::extend/sh…
danasana f27a0a6
Fix pre-commit hook failures
danasana 075bb45
Merge branch 'dev' into bugfix/bgp-headerlen-memory-safety
Dimi1010 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -619,6 +619,8 @@ namespace pcpp | |
// assuming header length of the layer that requested to be extended hasn't been enlarged yet | ||
size_t headerLen = curLayer->getHeaderLen() + (curLayer == layer ? numOfBytesToExtend : 0); | ||
dataPtr += headerLen; | ||
if (dataPtr > m_RawPacket->getRawData() + m_RawPacket->getRawDataLen()) | ||
break; | ||
Comment on lines
+613
to
+614
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How can such a thing happen? |
||
curLayer = curLayer->getNextLayer(); | ||
} | ||
|
||
|
@@ -671,6 +673,8 @@ namespace pcpp | |
// assuming header length of the layer that requested to be extended hasn't been enlarged yet | ||
size_t headerLen = curLayer->getHeaderLen() - (curLayer == layer ? numOfBytesToShorten : 0); | ||
dataPtr += headerLen; | ||
if (dataPtr > m_RawPacket->getRawData() + m_RawPacket->getRawDataLen()) | ||
break; | ||
Comment on lines
+666
to
+667
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ditto |
||
curLayer = curLayer->getNextLayer(); | ||
} | ||
|
||
|
Binary file added
BIN
+624 Bytes
...Tests/regression_samples/047c56c3504ad04232497c903af06c0bc4b5c6f73927ad07cde79cfa28d94f8b
Binary file not shown.
3 changes: 3 additions & 0 deletions
3
..._samples/047c56c3504ad04232497c903af06c0bc4b5c6f73927ad07cde79cfa28d94f8b:Zone.Identifier
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[ZoneTransfer] | ||
ZoneId=3 | ||
ReferrerUrl=C:\Users\dashka\Downloads\pocs.tar.gz |
Binary file added
BIN
+1.61 KB
...Tests/regression_samples/1eb005b8d62599b6561acf7e778f51603ccbc5ddf948c0b081617668bb56cee4
Binary file not shown.
3 changes: 3 additions & 0 deletions
3
..._samples/1eb005b8d62599b6561acf7e778f51603ccbc5ddf948c0b081617668bb56cee4:Zone.Identifier
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[ZoneTransfer] | ||
ZoneId=3 | ||
ReferrerUrl=C:\Users\dashka\Downloads\pocs.tar.gz |
Binary file added
BIN
+444 Bytes
...Tests/regression_samples/39d92632b6a92f1c682c052febfbc74b0561536687be3b7ce7b9508e8b9726d6
Binary file not shown.
3 changes: 3 additions & 0 deletions
3
..._samples/39d92632b6a92f1c682c052febfbc74b0561536687be3b7ce7b9508e8b9726d6:Zone.Identifier
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[ZoneTransfer] | ||
ZoneId=3 | ||
ReferrerUrl=C:\Users\dashka\Downloads\pocs.tar.gz |
Binary file added
BIN
+624 Bytes
...Tests/regression_samples/6f6fd63a9a6d8dd1a206eff00c915ed4b643034dad7e9986fd89a43244d6be97
Binary file not shown.
3 changes: 3 additions & 0 deletions
3
..._samples/6f6fd63a9a6d8dd1a206eff00c915ed4b643034dad7e9986fd89a43244d6be97:Zone.Identifier
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[ZoneTransfer] | ||
ZoneId=3 | ||
ReferrerUrl=C:\Users\dashka\Downloads\pocs.tar.gz |
Binary file added
BIN
+624 Bytes
...Tests/regression_samples/6fda21d7ebaa0391434f17eecf25b1d7c58633f96b6906183c626cbdfc35b325
Binary file not shown.
3 changes: 3 additions & 0 deletions
3
..._samples/6fda21d7ebaa0391434f17eecf25b1d7c58633f96b6906183c626cbdfc35b325:Zone.Identifier
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[ZoneTransfer] | ||
ZoneId=3 | ||
ReferrerUrl=C:\Users\dashka\Downloads\pocs.tar.gz |
Binary file added
BIN
+624 Bytes
...Tests/regression_samples/a7a658b6e51576eafe7990dbc35c5bfff991d914c9ead914e26e3bfc3e88221c
Binary file not shown.
3 changes: 3 additions & 0 deletions
3
..._samples/a7a658b6e51576eafe7990dbc35c5bfff991d914c9ead914e26e3bfc3e88221c:Zone.Identifier
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[ZoneTransfer] | ||
ZoneId=3 | ||
ReferrerUrl=C:\Users\dashka\Downloads\pocs.tar.gz |
Binary file added
BIN
+444 Bytes
...Tests/regression_samples/adb739b5829aacedbec6cf3969413997d23b6f2e3350ddf0b1cc3b4d1c335a95
Binary file not shown.
3 changes: 3 additions & 0 deletions
3
..._samples/adb739b5829aacedbec6cf3969413997d23b6f2e3350ddf0b1cc3b4d1c335a95:Zone.Identifier
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[ZoneTransfer] | ||
ZoneId=3 | ||
ReferrerUrl=C:\Users\dashka\Downloads\pocs.tar.gz |
Binary file added
BIN
+444 Bytes
...Tests/regression_samples/e0c0f8fea6e931d9671384a66f4e1ab02d84e27a5f091e9c7b1fce89d9c18837
Binary file not shown.
3 changes: 3 additions & 0 deletions
3
..._samples/e0c0f8fea6e931d9671384a66f4e1ab02d84e27a5f091e9c7b1fce89d9c18837:Zone.Identifier
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[ZoneTransfer] | ||
ZoneId=3 | ||
ReferrerUrl=C:\Users\dashka\Downloads\pocs.tar.gz |
Binary file added
BIN
+444 Bytes
...Tests/regression_samples/ec4b17a4e7b994548f03ae05d8d8924a515a236892959f3300e1c9e8a9c56ba7
Binary file not shown.
3 changes: 3 additions & 0 deletions
3
..._samples/ec4b17a4e7b994548f03ae05d8d8924a515a236892959f3300e1c9e8a9c56ba7:Zone.Identifier
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[ZoneTransfer] | ||
ZoneId=3 | ||
ReferrerUrl=C:\Users\dashka\Downloads\pocs.tar.gz |
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.