owasp-modsecurity / owasp-modsecurity/ModSecurity
Repeated headers cause problems in json audit logs
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 9.8k
- Forks
- 1.8k
- Avg merge
- 2h 46m
- Merged PRs (30d)
- 1
Description
Describe the bug
Current implementation of json audit logs generates log entries with duplicated keys in the event of repeated headers in either the request or response. This is technically not invalid json per RFC 7159 Section 4, but most implementations silently drop all-but-first or all-but-last instances of duplicated keys. In some cases however, the behavior is undefined and an error is thrown. I found this issue in the nginx repo outlining a similar difficulty. The prevailing idea over there seemed to be to convert repeated header fields into a single array value containing all of the previously enumerated values. The HTTP specification states in RFC 9110 Section 5.2 that field values for repeated headers should be able to be concatenated delimited by commas. I think either of these are reasonable solutions with pros and cons...
Arrays
Pros:
- Can easily handle different data types
Cons:
- Less aligned with typical representations of multiple values for a single header
Comma-delimited concatenated strings
Pros:
- Part of RFC spec for HTTP
Cons:
- Really only applies to string values
To Reproduce
curl -H "test: value" -H "test: another-value" "https://<site-behind-modsec>"
Server (please complete the following information):
- ModSecurity version (and connector): ModSecurity v3.0.4 with envoy connector v0.1.0
- WebServer: envoy 1.19
- OS (and distro): linux ubuntu
Rule Set (please complete the following information):
- Running any public or commercial rule set? OWASP_CRS
- What is the version number? 3.2.0
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the provided curl reproduction using ModSecurity and inspect how JSON audit logs represent repeated request or response headers. Resolve whether repeated fields should become arrays or comma-delimited strings, then verify the generated audit JSON contains no duplicate keys and handles the reported consumer behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- security
- Issue type
- Bug
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100