Skip to content

Commit 2bbc262

Browse files
committed
WebServer: Fix OOB write
Successful exploitation could lead to arbitrary code execution. The bug can be reproduced by running the following in a browser: ``` const formData = new FormData(); for (let i = 0;i < 33;++i) { formData.append("foo", i.toString()); } await fetch("http://esp.local", { method: 'POST', body: formData }); ```
1 parent b92c58d commit 2bbc262

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

Diff for: libraries/WebServer/src/Parsing.cpp

+6-3
Original file line numberDiff line numberDiff line change
@@ -356,9 +356,9 @@ bool WebServer::_parseForm(WiFiClient& client, String boundary, uint32_t len){
356356
client.readStringUntil('\n');
357357
//start reading the form
358358
if (line == ("--"+boundary)){
359-
if(_postArgs) delete[] _postArgs;
360-
_postArgs = new RequestArgument[WEBSERVER_MAX_POST_ARGS];
361-
_postArgsLen = 0;
359+
if(_postArgs) delete[] _postArgs;
360+
_postArgs = new RequestArgument[WEBSERVER_MAX_POST_ARGS];
361+
_postArgsLen = 0;
362362
while(1){
363363
String argName;
364364
String argValue;
@@ -413,6 +413,9 @@ bool WebServer::_parseForm(WiFiClient& client, String boundary, uint32_t len){
413413
if (line == ("--"+boundary+"--")){
414414
log_v("Done Parsing POST");
415415
break;
416+
} else if (_postArgsLen >= WEBSERVER_MAX_POST_ARGS) {
417+
log_v("Too many PostArgs (max: %d) in request.", WEBSERVER_MAX_POST_ARGS);
418+
return false;
416419
}
417420
} else {
418421
_currentUpload.reset(new HTTPUpload());

0 commit comments

Comments
 (0)