File tree Expand file tree Collapse file tree 3 files changed +68
-1
lines changed
src/request_body_processor
test/test-cases/regression Expand file tree Collapse file tree 3 files changed +68
-1
lines changed Original file line number Diff line number Diff line change 11v3.x.y - YYYY-MMM-DD (to be released)
22-------------------------------------
33
4+ - Tolerate other parameters after boundary in multipart C-T
5+ [Issue #1900 - @martinhsv]
46 - Add DebugLog message for bad pattern in rx operator
57 [Issue #2723 - @martinhsv]
68 - Support PCRE2
Original file line number Diff line number Diff line change @@ -1375,6 +1375,16 @@ bool Multipart::init(std::string *error) {
13751375 return false ;
13761376 }
13771377
1378+ /* Some frameworks are known to incorrectly include a charset= parameter */
1379+ /* after the boundary. Doing so is not RFC-compliant, but we will tolerate it.*/
1380+ if (boundary_characters_valid (m_boundary.c_str ()) != 1 ) {
1381+ size_t semicolon_after_boundary = m_boundary.find (' ;' );
1382+ if (semicolon_after_boundary != std::string::npos) {
1383+ ms_dbg_a (m_transaction, 3 ,
1384+ " Multipart: Invalid parameter after boundary in C-T (tolerated)." );
1385+ m_boundary = m_boundary.substr (0 , semicolon_after_boundary);
1386+ }
1387+ }
13781388 /* Validate the characters used in the boundary. */
13791389 if (boundary_characters_valid (m_boundary.c_str ()) != 1 ) {
13801390 m_flag_error = 1 ;
Original file line number Diff line number Diff line change 32393239 " SecRuleEngine On" ,
32403240 " SecRule MULTIPART_UNMATCHED_BOUNDARY \" @eq 1\" \" phase:2,deny,id:500095\" "
32413241 ]
3242- }
3242+ },
3243+ {
3244+ "enabled" :1 ,
3245+ "version_min" :300000 ,
3246+ "title" :" multipart parser (C-T parm after boundary -- invalid but tolerated)" ,
3247+ "client" :{
3248+ "ip" :" 200.249.12.31" ,
3249+ "port" :123
3250+ },
3251+ "server" :{
3252+ "ip" :" 200.249.12.31" ,
3253+ "port" :80
3254+ },
3255+ "request" :{
3256+ "headers" :{
3257+ "Host" :" localhost" ,
3258+ "User-Agent" :" curl/7.38.0" ,
3259+ "Accept" :" */*" ,
3260+ "Content-Length" :" 145" ,
3261+ "Content-Type" :" multipart/form-data; boundary=00000000; charset=UTF-8" ,
3262+ "Expect" :" 100-continue"
3263+ },
3264+ "uri" :" /" ,
3265+ "method" :" POST" ,
3266+ "body" :[
3267+ " --00000000\r " ,
3268+ " Content-Disposition: form-data; name=\" namea\"\r " ,
3269+ " \r " ,
3270+ " 111\r " ,
3271+ " --00000000\r " ,
3272+ " Content-Disposition: form-data; name=\" nameb\"\r " ,
3273+ " \r " ,
3274+ " 222\r " ,
3275+ " --00000000--\r "
3276+ ]
3277+ },
3278+ "response" :{
3279+ "headers" :{
3280+ "Date" :" Mon, 13 Jul 2015 20:02:41 GMT" ,
3281+ "Last-Modified" :" Sun, 26 Oct 2014 22:33:37 GMT" ,
3282+ "Content-Type" :" text/html"
3283+ },
3284+ "body" :[
3285+ " no need."
3286+ ]
3287+ },
3288+ "expected" :{
3289+ "http_code" : 403 ,
3290+ "debug_log" :" Multipart: Invalid parameter after boundary in C-T \\ (tolerated\\ ).*Added data"
3291+ },
3292+ "rules" :[
3293+ " SecRuleEngine On" ,
3294+ " SecRequestBodyAccess On" ,
3295+ " SecRule ARGS:namea \" @streq 111\" \" phase:2,deny,id:500096\" "
3296+ ]
3297+ }
32433298]
You can’t perform that action at this time.
0 commit comments