8000 fix: remove .env from lfi-os-files.data by theseion · Pull Request #4024 · coreruleset/coreruleset · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

fix: remove .env from lfi-os-files.data #4024

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

Conversation

theseion
Copy link
Contributor
@theseion theseion commented Mar 1, 2025

.env is probably the most generic entry in lfi-os-files.data. Unfortunatlye, since the words are matched using @pmFromFile, .env is easily matched as a substring. Most other entries are fairly unique or have a prefix or suffix that makes it unlikely for them to become FPs.

Note that .env is only commented out on purpose. lfi-os-files.data is also used as the base for other word files (e.g., restricted-files.data and since .env hasn't been an issue there until now, we don't want to remove it from those lists.

Fixes #3775

`.env` is probably the most generic entry in `lfi-os-files.data`.
Unfortunatlye, since the words are matched using `@pmFromFile`, `.env`
is easily matched as a substring. Most other entries are fairly unique
or have a prefix or suffix that makes it unlikely for them to become
FPs.

Note that `.env` is only commented out on purpose. `lfi-os-files.data`
is also used as the base for other word files (e.g.,
`restricted-files.data` and since `.env` hasn't been an issue there
until now, we don't want to remove it from those lists.

Fixes coreruleset#3775
@theseion theseion requested review from fzipi and EsadCetiner March 1, 2025 07:59
Copy link
Contributor
github-actions bot commented Mar 1, 2025

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

@EsadCetiner
Copy link
Member

You haven't added another rule to detect env files, or will it still be detected on REQUEST_FILENAME? It's really common for bots to scan for env files.

I'm on mobile so it's a bit hard for me to check

@theseion
Copy link
Contributor Author
theseion commented Mar 1, 2025

930130 checks REQUEST_FILENAME. That's why I took care to make sure that .env will still be included in restricted-files.data, even though it's commented now in lfi-os-files.data.

@EsadCetiner
Copy link
Member

Everything else LGTM then, can you add a test to make sure it's not accidently uncommented?

@theseion
Copy link
Contributor Author
theseion commented Mar 1, 2025

Done

@airween
Copy link
Contributor
airween commented Mar 1, 2025

The intention is understandable (reduce the number of false positives), but during the log analysis I usually found attempts to access to .env files.

Would it be possible to reorganize the data file, split it into two parts and create a sibling rule which is more strict on a higher PL?

@theseion
Copy link
Contributor Author
theseion commented Mar 1, 2025

Yes, I just figured, it wasn't worth the effort. .env will still be recognised in headers and REQUEST_FILENAME. REQUEST_FILENAME is probably the attack vector you're seeing in your logs?

@airween
Copy link
Contributor
airween commented Mar 1, 2025

REQUEST_FILENAME is probably the attack vector you're seeing in your logs?

Not necessarily. Here is an example:

ModSecurity: Warning. Matched phrase "/.env" at REQUEST_FILENAME.

This is the most frequent match.

And now I see it's still covered by 930130 - so sorry for the noise :).

@theseion theseion added this pull request to the merge queue Mar 1, 2025
Merged via the queue into coreruleset:main with commit 78d45b0 Mar 1, 2025
6 checks passed
@theseion theseion deleted the 3775-remove-dot-env-from-lfi-os-files branch March 1, 2025 10:25
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.

False positive for rule 930120 for test.Enviro
3 participants
0