Skip to content
This repository was archived by the owner on May 14, 2020. It is now read-only.

Conversation

@lifeforms
Copy link
Contributor

@lifeforms lifeforms commented May 20, 2018

If a web application allows unrestricted file uploads, and the web root/application source tree is writable, uploading configuration files might cause remote code execution.

The case for adding this rule was to block uploads of files named .htaccess, but I have also included some other common configuration files. More file names can be added in the future.

The rule cannot reuse the existing restricted-files.data file, since some of its entries contain file paths (to lower false positives), while this rule only checks bare file names.

Since this rule is not language specific, I've put it in the RCE conf file.

Some of the entries would also trigger 933110 (PHP Injection Attack: PHP Script File Upload Found).

Resolves #817.

@lifeforms lifeforms changed the title Restricted upload Check uploads for restricted file names May 20, 2018
@lifeforms lifeforms added this to the CRS v3.1.0 milestone May 20, 2018
@emphazer
Copy link
Contributor

for drupal 8 settings.local.php is missing

@lifeforms
Copy link
Contributor Author

@emphazer Awesome, added this. Also added it to lfi-os-files.data and restricted-files.data while we're at it.

@emphazer
Copy link
Contributor

@lifeforms
what about this ones
for lfi-os-files.data

# limited shell history
.lhistory
# networker backup configuration file
.nsr
# vim history
.viminfo
# less history
.lesshst
.pearrc
.vimrc
.bash_profile
.rediscli_history
.tcshrc
/.subversion/
/.pki/
/.local/share/mc/
/etc/redis.conf
/etc/redis-sentinel.conf

and for restricted files

/.drush/

@emphazer
Copy link
Contributor

@lifeforms are you planning to implement some of the stuff from #961 too?

@lifeforms
Copy link
Contributor Author

@emphazer Thanks for the suggestions. I've added them, and also added some new stuff myself. I've also synced up the dotfiles in lfi-os-files.data and restricted-files.data.

@lifeforms
Copy link
Contributor Author

@emphazer As for #961, it touches on a different part of the CRS. I would definitely love to add more commands to the RCE detection, but I'm a little short on time myself. Do you want to take a stab at a PR?

@lifeforms lifeforms changed the title Check uploads for restricted file names Add uploaded file name check; refresh LFI / filename checks May 27, 2018
@emphazer
Copy link
Contributor

@lifeforms sure

@dune73
Copy link
Contributor

dune73 commented Jun 2, 2018

Wow. I really like this PR.

@dune73 dune73 self-assigned this Jun 4, 2018
@dune73
Copy link
Contributor

dune73 commented Jun 5, 2018

There is now a conflict with restricted-files.data.

As decided yesterday in the chat, @lifeforms will resolve the conflict, I will run the PR and merge afterwards.

@lifeforms
Copy link
Contributor Author

Resolved the conflict.

@dune73
Copy link
Contributor

dune73 commented Jun 12, 2018

I tested the PR and triggered 932180 via

curl -F "f=@/tmp/.htaccess" http://localhost/

The PR works as intended.

Thank you for submitting. Merging now.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants