fix: NULL pointer dereference in multipart parser (GHSA-8m8p-vhxc-jmjw)#450
Merged
Merged
Conversation
When the multipart parser matched '--<boundary>' inside file data, it freed _itemBuffer but left _itemIsFile = true. If the next byte was neither the closing '--' nor a clean '\r\n', the rewind logic in DASH3_OR_RETURN2 / EXPECT_FEED2 called itemWriteByte(), which dereferenced the now-NULL _itemBuffer via _handleUploadByte, causing a StoreProhibited crash on ESP32 (remote DoS, CWE-476 / CWE-672). Fix: - Reset _itemIsFile = false immediately after freeing _itemBuffer in BOUNDARY_OR_DATA, so the rewind logic writes to _itemValue (String) instead of the freed buffer. - Add a NULL guard in _handleUploadByte as defense-in-depth. Added test case 11 in MultiPart.ino to reproduce and verify the fix.
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.
Fix for security advisory: GHSA-8m8p-vhxc-jmjw
When the multipart parser matched '--' inside file data, it freed _itemBuffer but left _itemIsFile = true. If the next byte was neither the closing '--' nor a clean '\r\n', the rewind logic in DASH3_OR_RETURN2 / EXPECT_FEED2 called itemWriteByte(), which dereferenced the now-NULL _itemBuffer via _handleUploadByte, causing a StoreProhibited crash on ESP32 (remote DoS, CWE-476 / CWE-672).
Fix:
Added test case 11 in MultiPart.ino to reproduce and verify the fix.