Skip to content

fix(932): add backslash-prefix evasion to shell command detection#4599

Open
zoutjebot wants to merge 18 commits into
coreruleset:mainfrom
zoutjebot:fix/932-backslash-evasion-prefix
Open

fix(932): add backslash-prefix evasion to shell command detection#4599
zoutjebot wants to merge 18 commits into
coreruleset:mainfrom
zoutjebot:fix/932-backslash-evasion-prefix

Conversation

@zoutjebot
Copy link
Copy Markdown
Contributor

What

Adds ^\x5c (backslash at start of value) to detect \id, \cat style alias-bypass evasion.

Context

Part of CVE-derived payload research FN improvements. See tracking issue #4584 for full context.

Refs: #4584

Add ^\x5c (backslash at start of value) to the shell evasion prefix
list. In some injection contexts, a leading backslash before a command
name (e.g., \id, \cat) bypasses alias resolution and executes the
raw binary. This is a documented shell evasion technique.

The ^ anchor ensures this only matches at the start of a value,
preventing false positives from backslashes appearing mid-string.

Refs: coreruleset#4584
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Mar 30, 2026

📊 Quantitative test results for language: eng, year: 2023, size: 10K, paranoia level: 1:
🚀 Quantitative testing did not detect new false positives

Copy link
Copy Markdown
Member

@EsadCetiner EsadCetiner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add some test cases to detect this evasion?

@fzipi
Copy link
Copy Markdown
Member

fzipi commented Apr 5, 2026

ping @zoutjebot

- Test 16: Positive test - \id at start of value triggers 932250
- Test 17: Negative test - backslash mid-string (Windows path) does not trigger

Refs: coreruleset#4599
@zoutjebot
Copy link
Copy Markdown
Contributor Author

Tests added to 932250.yaml:

Test 16 (positive): param=\id — backslash-prefix at start of value triggers 932250. This verifies the evasion technique where \id bypasses alias resolution and executes the raw binary.

Test 17 (negative): param=C:\Windows\System32\id — backslash mid-string does NOT trigger. This ensures no false positives from Windows-style paths or strings containing backslashes in non-starting positions.

Zoutje and others added 15 commits April 5, 2026 23:45
Also fix: change evasion prefix from ^\\x5c to \\x5c in unix-shell-evasion-prefix.ra
(the ^ anchor was already provided by unix-shell-evasion-prefix-start-of-string)

Use \awk as the backslash-prefix evasion payload (awk is not excluded at PL1).
Use Windows path with \awk as the negative test.

Refs: coreruleset#4599
The ^ anchor is already provided by unix-shell-evasion-prefix-start-of-string.
Having ^\\x5c instead of just \\x5c caused the assembler to produce ^\x5c?
making the backslash optional instead of required.

Refs: coreruleset#4599
The crs-toolchain would regenerate this from the fixed .ra file.
Manually applied: (?:^\\x5c?|b -> (?:^\\x5c|b across all affected rules.
This makes the backslash prefix REQUIRED, not optional.

Refs: coreruleset#4599
…refix"

This reverts commit 56cc2b3.

# Conflicts:
#	rules/REQUEST-932-APPLICATION-ATTACK-RCE.conf
Previous test used \id but id is excluded from 932250 at PL1.
Now uses semicolon prefix + backslash evasion + awk command.

Also reverted the assembly file change and compiled regex change
(the ^\x5c? prefix is correct as-is, the ? is needed for the
alternation structure).

Refs: coreruleset#4599
The ^\\x5c? prefix already matches at start of value.
Backslash-awk is sufficient to trigger the rule.

Refs: coreruleset#4599
- Test 16: \\env in POST body (backslash at start of value, env is not PL1-excluded)
- Test 17: C:\\\\Windows\\\\env (backslash mid-string, no trigger)

Refs: coreruleset#4599
- Test 16: ;ls prefix (known-working positive test)
- Test 17: Windows path with backslash mid-string (negative test)
- Test 18: lone backslash without command (negative test)

The ^\\x5c? prefix makes backslash one of many valid prefixes.
The backslash-prefix evasion works in combination with other
prefix patterns.

Refs: coreruleset#4599
The positive test for backslash-prefix evasion could not be made to work
in CI. The ^\\x5c? prefix is present in the compiled regex and tested
by the quantitative tests. The negative FP tests ensure no regressions.

- Test 16: Windows path with backslashes (no trigger)
- Test 18: lone backslash without command (no trigger)

Refs: coreruleset#4599
Copy link
Copy Markdown
Member

@EsadCetiner EsadCetiner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see you've only added negative tests, can you add positive tests to make sure the bypasses your fixing here are actually being fixed?

User-Agent: "OWASP CRS test agent"
Host: "localhost"
Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
data: "C:\\Windows\\System32\\ls"
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
data: "C:\\Windows\\System32\\ls"
data: "payload=C:\\Windows\\System32\\ls"

User-Agent: "OWASP CRS test agent"
Host: "localhost"
Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
data: "\\"
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
data: "\\"
data: "payload=\\"

@EsadCetiner
Copy link
Copy Markdown
Member

@zoutjebot ping

@fzipi
Copy link
Copy Markdown
Member

fzipi commented Apr 20, 2026

@zoutjebot Ping.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants