Skip to content

fix: add bounds check for boundary= value in MultipartStreamParser - #2649

Closed
bararchy wants to merge 1 commit into
drogonframework:masterfrom
bararchy:fix/boundary-oob-check
Closed

bararchy wants to merge 1 commit into
drogonframework:masterfrom
bararchy:fix/boundary-oob-check

Conversation

@bararchy

Copy link
Copy Markdown
Contributor

When Content-Type ends exactly at boundary= with no value, pos equals contentType.size() after the offset advance. The subsequent contentType[pos] access at line 44 reads one byte past the string (OOB).

Adds a pos >= contentType.size() guard that marks the parser invalid and returns early.

Fixes the remaining bug (1 of 3) from GHSA-hv4q-wjv9-x524. Bugs 2 and 3 were fixed in #2625.

When Content-Type ends exactly at "boundary=" with no value after it,
pos equals contentType.size() after the offset advance. The subsequent
contentType[pos] access reads one byte past the string, causing
undefined behavior (OOB read).

Add a pos >= contentType.size() guard that marks the parser invalid
and returns early, consistent with the other missing-boundary check
above it.

Fixes the remaining issue from GHSA-hv4q-wjv9-x524 (bug 1 of 3).
@bararchy

Copy link
Copy Markdown
Contributor Author

Closing -- submitted to wrong branch. Will resubmit to the correct location.

@bararchy bararchy closed this Oct 29, 2026
@bararchy
bararchy deleted the fix/boundary-oob-check branch October 29, 2026 13:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant