mirror of
https://github.com/owasp-modsecurity/ModSecurity.git
synced 2025-09-30 11:44:32 +03:00
Fix quote validation in multipart code
This commit is contained in:
@@ -36,13 +36,13 @@ void validate_quotes(modsec_rec *msr, unsigned char *data) {
|
|||||||
|
|
||||||
for(i = 0; i < len; i++) {
|
for(i = 0; i < len; i++) {
|
||||||
|
|
||||||
if(data[i] == '\'' && (data[0] != '\"' || data[len-1] != '\"'))
|
if(data[i] == '\'' && (data[0] != '\"' || data[len-1] != '\"')) {
|
||||||
msr->mpd->flag_invalid_quoting = 1;
|
if (msr->txcfg->debuglog_level >= 9) {
|
||||||
else if (data[i] == '\"') {
|
msr_log(msr, 9, "Multipart: Invalid quoting detected: %s length %d bytes",
|
||||||
if(i != 0 && i != len-1)
|
log_escape_nq(msr->mp, data), len);
|
||||||
|
}
|
||||||
msr->mpd->flag_invalid_quoting = 1;
|
msr->mpd->flag_invalid_quoting = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -123,8 +123,6 @@ static int multipart_parse_content_disposition(modsec_rec *msr, char *c_d_value)
|
|||||||
* set so the user can deal with it in the rules if they so wish.
|
* set so the user can deal with it in the rules if they so wish.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
validate_quotes(msr, p);
|
|
||||||
|
|
||||||
if ((*p == '"') || (*p == '\'')) {
|
if ((*p == '"') || (*p == '\'')) {
|
||||||
/* quoted */
|
/* quoted */
|
||||||
char quote = *p;
|
char quote = *p;
|
||||||
@@ -183,6 +181,9 @@ static int multipart_parse_content_disposition(modsec_rec *msr, char *c_d_value)
|
|||||||
/* evaluate part */
|
/* evaluate part */
|
||||||
|
|
||||||
if (strcmp(name, "name") == 0) {
|
if (strcmp(name, "name") == 0) {
|
||||||
|
|
||||||
|
validate_quotes(msr, value);
|
||||||
|
|
||||||
if (msr->mpd->mpp->name != NULL) {
|
if (msr->mpd->mpp->name != NULL) {
|
||||||
msr_log(msr, 4, "Multipart: Warning: Duplicate Content-Disposition name: %s",
|
msr_log(msr, 4, "Multipart: Warning: Duplicate Content-Disposition name: %s",
|
||||||
log_escape_nq(msr->mp, value));
|
log_escape_nq(msr->mp, value));
|
||||||
@@ -197,6 +198,9 @@ static int multipart_parse_content_disposition(modsec_rec *msr, char *c_d_value)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
if (strcmp(name, "filename") == 0) {
|
if (strcmp(name, "filename") == 0) {
|
||||||
|
|
||||||
|
validate_quotes(msr, value);
|
||||||
|
|
||||||
if (msr->mpd->mpp->filename != NULL) {
|
if (msr->mpd->mpp->filename != NULL) {
|
||||||
msr_log(msr, 4, "Multipart: Warning: Duplicate Content-Disposition filename: %s",
|
msr_log(msr, 4, "Multipart: Warning: Duplicate Content-Disposition filename: %s",
|
||||||
log_escape_nq(msr->mp, value));
|
log_escape_nq(msr->mp, value));
|
||||||
@@ -215,7 +219,18 @@ static int multipart_parse_content_disposition(modsec_rec *msr, char *c_d_value)
|
|||||||
while((*p == '\t') || (*p == ' ')) p++;
|
while((*p == '\t') || (*p == ' ')) p++;
|
||||||
/* the next character must be a zero or a semi-colon */
|
/* the next character must be a zero or a semi-colon */
|
||||||
if (*p == '\0') return 1; /* this is OK */
|
if (*p == '\0') return 1; /* this is OK */
|
||||||
if (*p != ';') return -12;
|
if (*p != ';') {
|
||||||
|
p--;
|
||||||
|
if(*p == '\'' || *p == '\"') {
|
||||||
|
if (msr->txcfg->debuglog_level >= 9) {
|
||||||
|
msr_log(msr, 9, "Multipart: Invalid quoting detected: %s length %d bytes",
|
||||||
|
log_escape_nq(msr->mp, p), strlen(p));
|
||||||
|
}
|
||||||
|
msr->mpd->flag_invalid_quoting = 1;
|
||||||
|
}
|
||||||
|
p++;
|
||||||
|
return -12;
|
||||||
|
}
|
||||||
p++; /* move over the semi-colon */
|
p++; /* move over the semi-colon */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user