Skip to content

Commit be1fbdf

Browse files
committed
Copy possible \0 contained string before use it; remote possible sensitive data from log
1 parent fc65775 commit be1fbdf

1 file changed

Lines changed: 7 additions & 6 deletions

File tree

apache2/re_operators.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2303,6 +2303,7 @@ static int msre_op_detectSQLi_execute(modsec_rec *msr, msre_rule *rule, msre_var
23032303
char fingerprint[8];
23042304
injection_result_t issqli;
23052305
int capture;
2306+
char *input_copy;
23062307

23072308
issqli = libinjection_sqli(var->value, var->value_len, fingerprint);
23082309
capture = apr_table_get(rule->actionset->actions, "capture") ? 1 : 0;
@@ -2320,16 +2321,17 @@ static int msre_op_detectSQLi_execute(modsec_rec *msr, msre_rule *rule, msre_var
23202321
}
23212322
break;
23222323
case LIBINJECTION_RESULT_ERROR:
2323-
set_match_to_tx(msr, capture, var->value, 0);
2324-
*error_msg = apr_psprintf(msr->mp, "libinjection parser error: '%s'",
2325-
log_escape_ex(msr->mp, var->value, var->value_len));
2324+
input_copy = apr_pmemdup(msr->mp, var->value, var->value_len);
2325+
set_match_to_tx(msr, capture, input_copy, 0);
2326+
*error_msg = apr_psprintf(msr->mp, "libinjection parser error");
23262327
if (msr->txcfg->debuglog_level >= 9) {
23272328
msr_log(msr, 9, "ISSQL: libinjection's input '%s' caused a parser error",
23282329
log_escape_ex(msr->mp, var->value, var->value_len));
23292330
}
23302331
break;
23312332
default:
2332-
set_match_to_tx(msr, capture, var->value, 0);
2333+
input_copy = apr_pmemdup(msr->mp, var->value, var->value_len);
2334+
set_match_to_tx(msr, capture, input_copy, 0);
23332335
*error_msg = apr_psprintf(msr->mp, "unexpected libinjection result: (%d)", issqli);
23342336
if (msr->txcfg->debuglog_level >= 9) {
23352337
msr_log(msr, 9, "ISSQL: libinjection's input '%s' caused an unexpected result: (%d)",
@@ -2375,8 +2377,7 @@ static int msre_op_detectXSS_execute(modsec_rec *msr, msre_rule *rule, msre_var
23752377
}
23762378
break;
23772379
case LIBINJECTION_RESULT_ERROR:
2378-
*error_msg = apr_psprintf(msr->mp, "libinjection parser error: '%s'",
2379-
log_escape_ex(msr->mp, var->value, var->value_len));
2380+
*error_msg = apr_psprintf(msr->mp, "libinjection parser error");
23802381
if (msr->txcfg->debuglog_level >= 9) {
23812382
msr_log(msr, 9, "IS_XSS: libinjection's input '%s' caused a parser error",
23822383
log_escape_ex(msr->mp, var->value, var->value_len));

0 commit comments

Comments
 (0)