fix(932130): detect ANSI-C quoting hex-encoded commands#4598
Conversation
Add detection for ANSI-C quoting syntax used in shell command evasion: $'\x69\x64' (which evaluates to 'id' in bash). This evasion technique encodes command characters as hex values within $'...' quoting, bypassing string-based command detection. The pattern requires at least 3 consecutive hex pairs to reduce false positives. Refs: coreruleset#4584
|
📊 Quantitative test results for language: |
|
That is a Good PR |
fzipi
left a comment
There was a problem hiding this comment.
Can you add tests? Positive and negative, so we cover both cases. Thanks!
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
also $'\u' can be used @zoutjebot Not just $'\x' |
|
also can be used relunsec@relunsec:~$ $'\103'
C: command not foundWe need a dedicated rule for that one at PL3 for reducing FPs |
|
Thanks for the fix and for adding tests. The approach is clever — leveraging A few gaps worth addressing before merge: 1. Missing ANSI-C escape variantsBash ANSI-C quoting supports more escape forms than just
(@HackingRepo flagged A broader pattern covers all of them:
Note that after 2. Threshold of
|
|
But wait, @fzipi, After deep fuzzing relunsec@relunsec:~$ echo -n $'\U00000043'
Crelunsec@relunsec:~$ relunsec@relunsec:~$ echo -n $'\U00000043'
Crelunsec@relunsec:~$ and relunsec@relunsec:~$ echo -n $'\U000043'
Crelunsec@relunsec:~$ also works, for $'\U', it can be 8 digits or just 4 or 6 and even 2 digits relunsec@relunsec:~$ echo -n $'\U43'
Crelunsec@relunsec:~$ |
|
ping @zoutjebot, can you address that evaison with $'\U', and add tests for that is detected |
|
hey @zoutjebot, care to push this one to the finish line? |
What
Detects $'\x69\x64' style shell evasion where commands are hex-encoded in ANSI-C quoting. Requires 3+ hex pairs to reduce FPs.
Context
Part of CVE-derived payload research FN improvements. See tracking issue #4584 for full context.
Refs: #4584