8000 feat(ssrf): adds rules to check for IP based SSRF by fzipi · Pull Request #2259 · coreruleset/coreruleset · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

feat(ssrf): adds rules to check for IP based SSRF #2259

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 19, 2022

Conversation

fzipi
Copy link
Member
@fzipi fzipi commented Oct 28, 2021
  • extends the original IPs handled in RFI rules to IPv6 and other IPv4 evasions
  • added the regular expressions used to data file
  • tests check the expressions

Signed-off-by: Felipe Zipitria felipe.zipitria@owasp.org

@fzipi fzipi added the 🚀 enhancement New feature or request label Oct 28, 2021
@lifeforms
Copy link
Member
lifeforms commented Oct 28, 2021

This is gonna be nice rules! There are some small formatting problems to resolve.

@RedXanadu
Copy link
Member

For clarity, can "(covered by RFI)" be changed to something like "(already covered by RFI rule 931100)"?

@fzipi fzipi force-pushed the add-ssrf-rules branch 2 times, most recently from 95a5a5b to 96e0907 Compare October 28, 2021 15:30
@spartantri
Copy link
Contributor

Hi, it seems the regex is not anchored to any schema, so the odds of false positives aren't good.
/test?pi=3.1415926535 the schemas are in the data file as comments but the rule file doesn't have any.

@dune73
Copy link
Member
dune73 commented Oct 28, 2021

For the record, this is a work-in-progress and we'll add more rules to this file? I'm asking because I am unsure we need a separate rules file for this. The 93x and 94x are usually meant for application defects and this is more a protocol attack in the 92x range, possibly even integrated into 920 or 921.

@fzipi
Copy link
Member Author
fzipi commented Oct 29, 2021

Hi, it seems the regex is not anchored to any schema, so the odds of false positives aren't good. /test?pi=3.1415926535 the schemas are in the data file as comments but the rule file doesn't have any.

Yeah, I'm adding negative tests and seeing that. Probably related to the script for building regexp.

@dune73
Copy link
Member
dune73 commented Nov 1, 2021

I'd like to see this into the rules file that #2163 renames.

@fzipi
Copy link
Member Author
fzipi commented Nov 2, 2021

Is this is a generic attack now, or is it because two rules are not too much to throw in new files?

@fzipi
Copy link
Member Author
fzipi commented Nov 2, 2021

What about the new ssrf_score? Does it make sense to people here?

@dune73
Copy link
Member
dune73 commented Nov 2, 2021

I'm personally not a fan of the separate scores, but some people are. In this particular case I doubt it makes much sense, unless it's really a separate rule group.

Generic or not: There are a lot of different rule categories. Adding a new rule category / group brings at least 8 administrative rules. That's a lot if it's only going to be 2-3 rules. So I think we need a group for "various rules". In my eyes, the new generic rules group was such a place.

@franbuehler
Copy link
Contributor

Meeting decision December: This PR will be shifted into the new category "generic attacks" after #2163 is merged.

@fzipi fzipi added ⏹️ blocked Blocked PRs waiting on others and removed 👀 Needs action labels Dec 11, 2021
@fzipi
Copy link
Member Author
fzipi commented Dec 24, 2021

SSRF rules, 🎄 edition! 🎉

  • moved rules to "generic attacks"
  • added all tests for each bypass

Before merge, we just need to think:

  • right now it is applying only to ARGS: do we need additional variables?
  • any other transformation to prevent evasions?

@fzipi fzipi force-pushed the add-ssrf-rules branch 6 times, most recently from ee1d977 to e891353 Compare December 28, 2021 12:18
@franbuehler franbuehler self-assigned this Jan 3, 2022
@franbuehler
Copy link
Contributor

Meeting decision January: @franbuehler will review it and pass it to @lifeforms for testing.

@fzipi
Copy link
Member Author
fzipi commented Feb 3, 2022

We're you able to review this one @franbuehler ?

@franbuehler
Copy link
Contributor

Hi @fzipi,
Sorry for my late reply. I didn't see your ping.
No, unfortunately not yet...

fzipi added 2 commits February 7, 2022 16:23
- extends the original IPs handled in RFI rules to IPv6 and other IPv4 evasions
- added the regular expressions used to data file
- tests check the expressions
- add negative tests

Signed-off-by: Felipe Zipitria <felipe.zipitria@owasp.org>
Signed-off-by: Felipe Zipitria <felipe.zipitria@owasp.org>
Copy link
Contributor
@franbuehler franbuehler left a comment

Choose a reason for hiding this comment

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

If it's just me getting this error while generating the regex (I wanted to check the output against the rule), this MR is ready to be tested by @lifeforms.
Nice rule, a nice extension, thank you!

@lifeforms lifeforms assigned lifeforms and unassigned franbuehler Feb 7, 2022
@fzipi fzipi added this to the CRS v4.0 milestone Feb 7, 2022
@lifeforms
Copy link
Member

I will run the rule on traffic starting next Wednesday.

@lifeforms
Copy link
Member

So far no false positives reported! 🥳 Let's wait for a few more days. I plan to merge this on Saturday, and then continue work on my prototype pollution PR which will conflict with this.

@dune73
Copy link
Member
dune73 commented Feb 17, 2022

Can you give us an estimate on the number of requests for this?

@lifeforms
Copy link
Member
lifeforms commented Feb 18, 2022

I should improve my logging, but if I look at some access_logs from yesterday and extrapolate, I think something like 2 million requests.

@dune73
Copy link
Member
dune73 commented Feb 18, 2022

Thank you.

And I can recommend this format: https://www.netnea.com/cms/apache-tutorial-5_extending-access-log/#step_4_configuring_the_new,_extended_log_format

LogFormat "%h %{GEOIP_COUNTRY_CODE}e %u [%{%Y-%m-%d %H:%M:%S}t.%{usec_frac}t] \"%r\" %>s %b \
\"%{Referer}i\" \"%{User-Agent}i\" \"%{Content-Type}i\" %{remote}p %v %A %p %R \
%{BALANCER_WORKER_ROUTE}e %X \"%{cookie}n\" %{UNIQUE_ID}e %{SSL_PROTOCOL}x %{SSL_CIPHER}x \
%I %O %{ratio}n%% %D %{ModSecTimeIn}e %{ApplicationTime}e %{ModSecTimeOut}e \
%{ModSecAnomalyScoreInPLs}e %{ModSecAnomalyScoreOutPLs}e \
%{ModSecAnomalyScoreIn}e %{ModSecAnomalyScoreOut}e" extended

Comes with a handy set of aliases too: https://raw.githubusercontent.com/Apache-Labor/labor/master/bin/.apache-modsec.alias

@lifeforms lifeforms merged commit 014a882 into coreruleset:v3.4/dev Feb 19, 2022
@lifeforms
Copy link
Member

Merged 🍴 because this rule is cool 😎 and I've got no false positives. (Sadly also no true positives)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants
0