Skip to content

Commit f86de56

Browse files
florian-eichelbergerFelipe Zimmerle
authored andcommitted
Enables sanitizing of json request bodies in the apache module for native log format
1 parent 4ee1d9c commit f86de56

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

apache2/msc_json.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616

1717
#ifdef WITH_YAJL
1818

19+
char *base_offset=NULL;
20+
1921
int json_add_argument(modsec_rec *msr, const char *value, unsigned length)
2022
{
2123
msc_arg *arg = (msc_arg *) NULL;
@@ -48,6 +50,8 @@ int json_add_argument(modsec_rec *msr, const char *value, unsigned length)
4850
*/
4951
arg->value = apr_pstrmemdup(msr->mp, value, length);
5052
arg->value_len = length;
53+
arg->value_origin_len = length;
54+
arg->value_origin_offset = value-base_offset;
5155
arg->origin = "JSON";
5256

5357
if (msr->txcfg->debuglog_level >= 9) {
@@ -273,6 +277,7 @@ int json_init(modsec_rec *msr, char **error_msg) {
273277
int json_process_chunk(modsec_rec *msr, const char *buf, unsigned int size, char **error_msg) {
274278
if (error_msg == NULL) return -1;
275279
*error_msg = NULL;
280+
base_offset=buf;
276281

277282
/* Feed our parser and catch any errors */
278283
msr->json->status = yajl_parse(msr->json->handle, buf, size);

apache2/msc_logging.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -878,7 +878,7 @@ void sec_audit_logger_json(modsec_rec *msr) {
878878
for(i = 0; i < tarr->nelts; i++) {
879879
msc_arg *arg = (msc_arg *)telts[i].val;
880880
if (arg->origin != NULL &&
881-
strcmp(arg->origin, "BODY") != 0)
881+
( strcmp(arg->origin, "BODY") != 0 && strcmp(arg->origin, "JSON") !=0) )
882882
continue;
883883

884884
if (last_offset == 0) { /* The first time we're here. */

0 commit comments

Comments
 (0)