owasp-modsecurity / owasp-modsecurity/ModSecurity

New operator: Check if transformation changed input

Open
#1,293 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement RIP - Type - Feature TBF by libmodsec
Dominant language
C++
Stars
9.8k
Forks
1.8k
Avg merge
2h 46m
Merged PRs (30d)
1

Description

I propose a new operator that checks if the transformation pipeline ended up with a different result than the original parameter. One idea with this operator would be to check for (multi-)encoded payloads.

Usage example:

SecRule ARGS:comment "@checkTransform" "id:1000,deny,phase:2,t:hexDecode"

Rule 1000 rule would thus trigger, if ARGS:comment contains hex encoded stuff.

If you are OK with strings with a single hex encoding, but you want to block double-encoded payloads, then this is the recipe:

SecRule ARGS:comment "@unconditionalMatch" "id:1001,pass,phase:2,t:hexDecode,setvar:TX.comment_decoded=%{MATCHED_VAR}"
SecRule TX:comment_decoded "@checkTransform" "id:1002,deny,phase:2,t:hexDecode"

This can all be done with complicated regexes for every encoding type, I guess. But this proposed operator leverages the transformation in a very simple way.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating the operator implementations and transformation pipeline used by SecRule, then trace how t:hexDecode changes the matched value. Define the operator's behavior for unchanged versus transformed input, including the double-encoding examples, and add coverage for the supplied SecRule scenarios before considering the work done.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
security
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
28/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.