Transformation reference

ModSecurity transformations

Normalize encoded and evasive input before matching while preserving the original transaction data.

Adapted ModSecurity documentationThis page has been reorganized, rewritten, and supplemented by Atomicorp from upstream ModSecurity reference material. Source, license, and attribution details.

Transformations create a changed copy of variable data before the operator evaluates it. They do not rewrite the HTTP request. A transformation pipeline runs from left to right, and order is security-significant.

SecRule ARGS "@contains select" \
  "id:100030,phase:2,deny,t:none,t:urlDecodeUni,t:htmlEntityDecode,t:lowercase"

Decoding and encoding

TransformationPurpose
urlDecodeDecodes standard URL encoding.
urlDecodeUniDecodes URL and supported Unicode-style encoding.
htmlEntityDecodeDecodes HTML entities.
jsDecodeDecodes JavaScript escape sequences.
cssDecodeDecodes CSS escapes.
escapeSeqDecodeDecodes common escape sequences.
base64Decode / base64DecodeExtDecodes Base64 input.
hexDecodeDecodes hexadecimal representation.
urlEncode, base64Encode, hexEncodeEncode a transformed copy.

Repeated decoding can create ambiguity. Apply only the pipeline required by the rule and test nested encoding deliberately.

Case, whitespace, and comments

lowercase and uppercase normalize case. compressWhitespace, removeWhitespace, trim, trimLeft, and trimRight normalize spacing. Comment transformations remove or replace comment syntax to make split attack tokens visible.

Paths and command lines

normalizePath resolves path navigation and separators; normalizePathWin applies Windows path behavior. cmdLine normalizes common command-line evasions. Use the platform-appropriate transformation and keep raw-path validation separate where ambiguity matters.

Nulls and byte representation

removeNulls removes null bytes; replaceNulls substitutes spaces. Hash and length transformations produce derived representations. Know whether a downstream operator expects text, bytes, a digest, or a length.

Clear inherited transformations

t:none clears transformations inherited from SecDefaultAction or context. Put it before the explicit pipeline:

"t:none,t:urlDecodeUni,t:lowercase"

Common mistakes

See the exhaustive upstream transformation reference.