ADR-0033: The `sanitize*` actions are Extended and mask with a fixed string
ADR-0033: The `sanitize*` actions are Extended and mask with a fixed string
- Status: accepted
- Date: 2026-11-09
- Accepted: 2026-11-11
- Deciders: @fzipi, @xanadu, @M4tteoP, @airween, @franbuehler, @theseion
- Category: Divergence
Context
ADR-0011 made the five sanitize* actions Deprecated with the other v2 legacy features,
because only ModSecurity v2 implements them. They are still the only way a rule can keep a
password, token or card number out of the logs, and losing them pushes operators towards
turning off audit logging or request-body parts altogether. The engines today:
- ModSecurity v2 (
v2/master2026-09,apache2/re_actions.cmsre_action_sanitizeArg_execute,msre_action_sanitizeMatched_execute,msre_action_sanitizeMatchedBytes_init;apache2/msc_logging.csanitize_request_lineand the part writers): masks in the audit log only (request line, request headers, URL-encoded and multipart request bodies, response headers), replacing every byte of the value with*, so the value’s length stays visible. The error log is not masked:%{MATCHED_VAR}inmsgorlogdatawrites the clear value. - libmodsecurity v3.0.17: the lexer recognises the names, but
src/parser/seclang-parser.yyrejects them withACTION_NOT_SUPPORTED, so a rule using one fails to load. - Coraza v3.8.1: no such actions (
internal/actions); a rule using one fails to load. - OWASP CRS v4.25.2 does not use them.
Decision
The five actions move from Deprecated to Extended (08-actions.md#sanitizearg and the
four entries after it), spelled sanitize* only: v2’s sanitise* spellings are not aliases
(ADR-0004):
sanitizeArg:NAMEmarks every argument (query string or request body) whose name equalsNAME, compared case-insensitively.sanitizeRequestHeader:NAMEandsanitizeResponseHeader:NAMEmark every request or response header of that name.sanitizeMatchedmarks what the rule matched when the variable isARGS:x,ARGS_GET:x,ARGS_POST:x,ARGS_NAMES:x,REQUEST_HEADERS:x,REQUEST_HEADERS_NAMES:x,RESPONSE_HEADERS:xorRESPONSE_HEADERS_NAMES:x(the value of argument or headerx), and does nothing for any other variable.sanitizeMatchedBytesmarks only the bytes the operator matched inside that value;sanitizeMatchedBytes:N/Mleaves the firstNand the lastMof them in clear.- A marked value is written as the fixed mask
**sanitized**, whatever its length, wherever the engine writes that argument or header, or text derived from it, to the transaction’s audit log entry (request line and URI, headers, request and response bodies, matched-rule messages) or to an error-log line written by the rule that marks it or by a later rule in the same transaction: the URI or query string in a line, a macro inmsgorlogdata, the description of the matched data. The same bytes arriving in another field (aRefererthat repeats the password) are not marked. An engine that cannot locate a marked value inside a body it writes MUST write that whole body as the mask. Error-log lines written before the action ran are not retracted. The debug log is out of scope. - The positive form is fixed only for the audit log: where the value would appear in an
audit part the engine writes
**sanitized**there. Where the mask appears in the error log is engine-specific; only the absence of the clear value is normative. - The actions are non-disruptive, run when the rule matches, and change only logging; the variables keep their values for later rules.
Options considered
- Keep them Deprecated (ADR-0011): leaves rules with no portable way to keep secrets out of the logs; rejected.
ARGS_GETandARGS_POSTadded to v2’s variable list forsanitizeMatched: a rule matchingARGS_POST:passwordis as likely as one matchingARGS:password.sanitise*canonical, as ADR-0011 and the earlier spec entries wrote it, or kept as an alias: v2 registers both spellings alike and names its own functionsmsre_action_sanitize*; one spelling is enough for actions no other engine has yet, and no current ruleset uses either. Rejected in favour ofsanitize*alone.- Specify v2’s behaviour as is: a same-length mask leaks the length, which is enough to tell a PIN from a password and to confirm a guessed value, and v2 leaves the error log in clear; rejected.
- Fixed mask in both logs (chosen): v2 needs a change, but the requirement is testable as the absence of the clear value plus one fixed string in the audit log.
- Mask the debug log too: debug output is for development, has no shared format, and is rarely enabled in production; out of scope.
Consequences
- For ModSecurity v2: write
**sanitized**instead of one*per byte, and apply the marks to error-log lines and to macro expansion inmsgandlogdata. - For libmodsecurity v3: register the actions instead of
ACTION_NOT_SUPPORTEDand apply the marks in the audit log writer and inRuleMessage. - For Coraza: add the actions in
internal/actionsand apply the marks in its audit log writers and its error-log output. - For this repository: the actions are Extended before any engine declares them, so their
profiles are skipped everywhere until one does;
00-conventions.md#status-transitionsgains a row for restoring a Deprecated feature. The test schema gainsaudit_log_contains/no_audit_log_contains(tests/README.md), and the rule of ADR-0021 that log assertions use onlymsgtext or a short[data "…"]field gains one exception:no_log_containsandno_audit_log_containswith a marked value, andaudit_log_containswith the mask. - For rule authors:
sanitizeArg:passwordand its siblings are portable once two engines ship them; until then they load only in v2, and v2 output still shows the length. A rule written withsanitise*loads only in v2 and must be renamed.