Skip to content

Fix CWE-190 - DoS could happen with a specially crafted boundary parameter in a multipart request#445

Open
mathieucarbou wants to merge 2 commits into
mainfrom
CWE-190
Open

Fix CWE-190 - DoS could happen with a specially crafted boundary parameter in a multipart request#445
mathieucarbou wants to merge 2 commits into
mainfrom
CWE-190

Conversation

@mathieucarbou
Copy link
Copy Markdown
Member

@mathieucarbou mathieucarbou commented Jun 6, 2026

Fix integer overflow.

See advisory: GHSA-4phx-fcj6-46r4

Tested with our UploadFlash example.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR addresses a security issue (CWE-190) in multipart request handling by constraining and hardening boundary parsing to prevent integer overflow / DoS scenarios during multipart body parsing.

Changes:

  • Add validation to reject multipart boundaries that are empty or exceed RFC 2046’s 70-character limit.
  • Change multipart boundary parsing state tracking (_boundaryPosition) to size_t and update a related loop to avoid overflow issues.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
src/WebRequest.cpp Adds boundary length validation and updates multipart parsing loop indexing to use size_t.
src/ESPAsyncWebServer.h Updates _boundaryPosition type to size_t to safely track boundary parsing progress.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/WebRequest.cpp
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

Comment thread src/WebRequest.cpp
Comment on lines +487 to +488
_boundary = value.substring(bpos + 9);
int semi = _boundary.indexOf(';');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants