diff options
author | Vijay Dev <vijaydev.cse@gmail.com> | 2013-12-19 22:51:01 +0530 |
---|---|---|
committer | Vijay Dev <vijaydev.cse@gmail.com> | 2013-12-19 22:51:01 +0530 |
commit | 3351c2d466b40e30e0e0d310ae4d6caefe00fc2d (patch) | |
tree | f3c3b69260eace25efbca4a65516175bb142918f | |
parent | 1406630b219b0fcd1c618926aec3019fe4784f84 (diff) | |
download | rails-3351c2d466b40e30e0e0d310ae4d6caefe00fc2d.tar.gz rails-3351c2d466b40e30e0e0d310ae4d6caefe00fc2d.tar.bz2 rails-3351c2d466b40e30e0e0d310ae4d6caefe00fc2d.zip |
Revert "Update security.md"
This reverts commit f4804fafecdc057988575b4516afe9ca1d5f42fc.
[ci skip]
-rw-r--r-- | guides/source/security.md | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/guides/source/security.md b/guides/source/security.md index 25428998f2..595cf7c62c 100644 --- a/guides/source/security.md +++ b/guides/source/security.md @@ -290,7 +290,7 @@ NOTE: _Make sure file uploads don't overwrite important files, and process media Many web applications allow users to upload files. _File names, which the user may choose (partly), should always be filtered_ as an attacker could use a malicious file name to overwrite any file on the server. If you store file uploads at /var/www/uploads, and the user enters a file name like "../../../etc/passwd", it may overwrite an important file. Of course, the Ruby interpreter would need the appropriate permissions to do so - one more reason to run web servers, database servers and other programs as a less privileged Unix user. -When filtering user input file names, _don't try to remove malicious parts_. Think of a situation where the web application removes all "../" in a file name and an attacker uses a string such as "....//" - the result will be "../". It is best to use a whitelist approach, which _checks for the validity of a file name with a set of accepted characters_. This is opposed to a blacklist approach which attempts to remove not allowed characters. In case it isn't a valid file name, reject it (or replace not accepted characters), but don't remove them. Here is the file name sanitizer from the [attachment\_fu plugin](https://github.com/technoweenie/attachment_fu/tree/master): +When filtering user input file names, _don't try to remove malicious parts_. Think of a situation where the web application removes all "../" in a file name and an attacker uses a string such as "....//" - the result will be "../". It is best to use a whitelist approach, which _checks for the validity of a file name with a set of accepted characters_. This is opposed to a blacklist approach which attempts to remove not allowed characters. In case it isn't a valid file name, reject it (or replace not accepted characters), but don't remove them. Here is the file name sanitizer from the [attachment_fu plugin](https://github.com/technoweenie/attachment_fu/tree/master): ```ruby def sanitize_filename(filename) |