Skip to content

fix: remove non-unix commands from unix rce rules (932230 PL-1, 932235 PL-1, 932250 PL-1, 932260 PL-1, 932220 PL-2, 932236 PL-2, 932239 PL-2, 932237 PL-3)#4247

Merged
EsadCetiner merged 13 commits into
coreruleset:mainfrom
EsadCetiner:fix-exclude-non-unix-commands
Jan 26, 2026
Merged

fix: remove non-unix commands from unix rce rules (932230 PL-1, 932235 PL-1, 932250 PL-1, 932260 PL-1, 932220 PL-2, 932236 PL-2, 932239 PL-2, 932237 PL-3)#4247
EsadCetiner merged 13 commits into
coreruleset:mainfrom
EsadCetiner:fix-exclude-non-unix-commands

Conversation

@EsadCetiner
Copy link
Copy Markdown
Member

The Unix RCE rules uses unix-shell.data as a source of truth as to what commands it should be blocking, some entries in that list are not commands (some are /dev/ or /proc/ files) and are as a result being treated as a unix command as can be seen in issues like #4110.

This PR modifies the scripts used to generate unix-shell-upto3.ra and unix-shell-4andup.ra to exclude these entries so non-unix commands are not blocked along with the risk of false positives.

closes: coreruleset/phpmyadmin-rule-exclusions-plugin#31

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Aug 22, 2025

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

@fzipi
Copy link
Copy Markdown
Member

fzipi commented Aug 31, 2025

I see what you did. Makes sense. Now, these are mentions to files instead of commands, are they in another list or do we lose them?

@EsadCetiner
Copy link
Copy Markdown
Member Author

@fzipi Yes they still exist in unix-shell.data, that's where these entries came from. This PR just prevents those entries from being added to unix-shell-.*

@azurit
Copy link
Copy Markdown
Member

azurit commented Jan 25, 2026

@EsadCetiner Can you please explain more what this PR does?

You are talking only about modifying two scripts, which now excludes keywords ^(dev|proc|etc|#|$|\$) but, in fact, lots of other (not matching that regex) keywords are removed from various lists. Or am i missing something?

@EsadCetiner
Copy link
Copy Markdown
Member Author

EsadCetiner commented Jan 25, 2026

@azurit

You are talking only about modifying two scripts, which now excludes keywords ^(dev|proc|etc|#|$|$) but, in fact, lots of other (not matching that regex) keywords are removed from various lists. Or am i missing something?

The script uses unix-shell.data as a source of truth for what commands to block, the issue is that some entries such as /proc/self , and /dev/null are being interpreted as unix commands which are then added as self and null to unix-shell-*.ra. This has resulted in false positives such as with coreruleset/phpmyadmin-rule-exclusions-plugin#31 and #4110. This PR removes those non-unix commands and modifies the scripts to exclude those entries to prevent them from being added back again in the future.

Comment thread regex-assembly/include/unix-shell-4andup.ra Outdated
Comment thread regex-assembly/include/unix-shell-upto3.ra Outdated
@azurit
Copy link
Copy Markdown
Member

azurit commented Jan 25, 2026

@azurit

You are talking only about modifying two scripts, which now excludes keywords ^(dev|proc|etc|#|$|$) but, in fact, lots of other (not matching that regex) keywords are removed from various lists. Or am i missing something?

The script uses unix-shell.data as a source of truth for what commands to block, the issue is that some entries such as /proc/self , and /dev/null are being interpreted as unix commands which are then added as self and null to unix-shell-*.ra. This has resulted in false positives such as with coreruleset/phpmyadmin-rule-exclusions-plugin#31 and #4110. This PR removes those non-unix commands and modifies the scripts to exclude those entries to prevent them from being added back again in the future.

@EsadCetiner Ok, got it, thanks.

@azurit
Copy link
Copy Markdown
Member

azurit commented Jan 25, 2026

Wouldn't it be safer to use proc/|dev/|etc/ ?

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR refines the Unix RCE detection rules to stop treating non-command entries (notably /dev, /etc, /proc paths and similar) from unix-shell.data as shell commands, thereby reducing false positives such as the | SELF case reported in #4110 and in the linked phpMyAdmin plugin issue.

Changes:

  • Updated the Unix shell regex assembly inputs (unix-shell-upto3.ra, unix-shell-4andup.ra) to exclude non-command entries from rules/unix-shell.data and rules/unix-shell-builtins.data, and refreshed the generated command lists accordingly.
  • Regenerated the large assembled regexes in REQUEST-932-APPLICATION-ATTACK-RCE.conf for several RCE rules (932230, 932235, 932250, 932260, 932220, 932236, 932239, 932237) to align with the cleaned command lists.
  • Tightened regression tests for rule 932235 by adding a new FP test for the null token and simplifying the PL1/PL2 false-positive exclusion lists that are now redundant with the cleaned sources.

Reviewed changes

Copilot reviewed 6 out of 7 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
tests/regression/tests/REQUEST-932-APPLICATION-ATTACK-RCE/932235.yaml Adds a regression test ensuring time null space is no longer flagged by rule 932235, covering the null-token change in the command lists.
rules/REQUEST-932-APPLICATION-ATTACK-RCE.conf Regenerates several RCE detection regexes so they no longer include non-command entries derived from /dev, /etc, /proc, and similar sources.
regex-assembly/include/unix-shell-upto3.ra Adjusts the regeneration script to pre-filter non-command entries and updates the short-command list to drop items such as fd@, tcp@, and udp@.
regex-assembly/include/unix-shell-4andup.ra Modifies the regeneration script to filter out non-command paths before assembling long-command patterns, updates the English-word suffixing step, and removes non-command tokens like group, null, shadow, zero, etc.
regex-assembly/exclude/unix-shell-fps-pl2.ra Cleans up PL2 false-positive exclusions (e.g., removing null variants) that are now handled at the source list level.
regex-assembly/exclude/unix-shell-fps-pl1.ra Simplifies PL1 FP exclusions by dropping entries (group, null, shadow, shells, tcp, zero, etc.) that no longer appear in the assembled command lists.
regex-assembly/exclude/unix-shell-fps-pl1-curated.ra Removes now-redundant curated FP exclusions for group that are covered by the updated source filtering.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread regex-assembly/include/unix-shell-4andup.ra Outdated
@fzipi
Copy link
Copy Markdown
Member

fzipi commented Jan 26, 2026

@azurit You got this one? Can I count on you for pushing it to the finish line?

@azurit
Copy link
Copy Markdown
Member

azurit commented Jan 26, 2026

@fzipi Sure thing.

@azurit
Copy link
Copy Markdown
Member

azurit commented Jan 26, 2026

@EsadCetiner There are still some invalid commands in the lists, at least:
GET
POST
HEAD

They were added in #3735 and maybe they can be completely removed.

@EsadCetiner
Copy link
Copy Markdown
Member Author

@azurit No those entries were not added in that PR, and no they are not invalid commands.
See:

$ which head --help
Usage: head [OPTION]... [FILE]...
Print the first 10 lines of each FILE to standard output.
With more than one FILE, precede each with a header giving the file name.

@azurit
Copy link
Copy Markdown
Member

azurit commented Jan 26, 2026

Wouldn't it be safer to use proc/|dev/|etc/ ?

What about this?

@EsadCetiner
Copy link
Copy Markdown
Member Author

@azurit Sorry, I missed that. It's fixed now.

@azurit
Copy link
Copy Markdown
Member

azurit commented Jan 26, 2026

@EsadCetiner Good work, thank you!

@EsadCetiner EsadCetiner added this pull request to the merge queue Jan 26, 2026
Merged via the queue into coreruleset:main with commit 0d2f083 Jan 26, 2026
9 of 10 checks passed
@EsadCetiner EsadCetiner deleted the fix-exclude-non-unix-commands branch January 26, 2026 10:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SQL query with "NULL" matches REQUEST-932-APPLICATION-ATTACK-RCE

4 participants