8000 Detect RCE in fragments of URLs in Referer header (932205) · Issue #3498 · coreruleset/coreruleset · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Detect RCE in fragments of URLs in Referer header (932205) #3498

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

Open
theseion opened this issue Jan 20, 2024 · 6 comments · May be fixed by #3993
Open

Detect RCE in fragments of URLs in Referer header (932205) #3498

theseion opened this issue Jan 20, 2024 · 6 comments · May be fixed by #3993
Labels
🚀 enhancement New feature or request

Comments

@theseion
Copy link
Contributor

According to the URL specification, the Referer header must not contain URL fragments (the part of the URL beginning with #). However, in practice many clients will simply copy the current URL into the Referer header. Since web servers have to allow fragments in the Referer header, this opens the door to attacks in the fragment part (we already detect attacks in the path and query parts of URLs in the Referer header).

We should add a new rule that targets the fragment part or URLs in the Referer header only and applies RCE detection as 932205 does to path and query.

See also the discussion in #3485.

@dune73
Copy link
Member
dune73 commented Mar 1, 2024

Thank you for creating this issue. I think this is exactly to the point.

@Xhoenix
Copy link
Member
Xhoenix commented Feb 3, 2025

SecRule REQUEST_HEADERS:Referer "@rx ^[^#]+" \

I think creating a new rule with ^[^#]+\#[^#]+ willl be sufficient, only need to add tests. Should I send a PR?

@theseion
Copy link
Contributor Author
theseion commented Feb 8, 2025

Yes please!

@Xhoenix
Copy link
Member
Xhoenix commented Feb 8, 2025

The rule 932205 never gets triggered, as it's basically rule 932206 in the chain, and rule 932206 gets triggered instead, as we are targeting the uri in referrer header. Is there any way we can log 932205, or is this expected behavior?

@Xhoenix
Copy link
Member
Xhoenix commented Feb 8, 2025

Hey @theseion , can you provide some resources showing an exploit for RCE in URL fragments, need some info for tests.

@theseion
Copy link
Contributor Author
theseion commented Feb 8, 2025

There's a remark in the comment to 932205 about "Scroll to text fragment". That comment is actually obsolete rule. It was part of an FP fix (cf0bb6e). We had added that when the rule was still targeting all referrer values, including fragments. Since the rule now exclude fragments, that fix was no longer necessary. Of course it would make sense for a new rule.

I can't give you any references, but the same exploits that are possible in other places of the Referer are possible in the fragment as well. For example, the following is a modified version of the first test for 932205: www.google.com?param=something#x=;/bin/ca?+/et*/passwd.

Note that there are three variants of fragments: id, text, and media (https://developer.mozilla.org/en-US/docs/Web/URI/Fragment). If you look at the RFC you'll notice that the allowed characters consist of percent encoding, ASCII, and a couple of special symbols like @, ?, *, /, ; and + (most of those symbols come from the sub-delims production).

HTH.

@Xhoenix Xhoenix linked a pull request Feb 9, 2025 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🚀 enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants
2AB6
0