Closed (fixed)
Project:
Drupal core
Version:
6.x-dev
Component:
documentation
Priority:
Normal
Category:
Task
Assigned:
Reporter:
Created:
10 Feb 2010 at 20:15 UTC
Updated:
25 Aug 2010 at 17:50 UTC
Jump to comment: Most recent file
In #594518: file_munge_filename() doc mentions watchdog but shouldn't the Doxygen documentation for file_munge_filename() was improved. However, it still does not answer the obvious questions:
I don't know the answers to these questions myself.
| Comment | File | Size | Author |
|---|---|---|---|
| #13 | file-munge-D6.patch | 1.77 KB | rdrh555 |
| #9 | 710640-9-munge.patch | 1.79 KB | dale42 |
| #4 | 710640-munge.patch | 1.67 KB | jhodgdon |
Comments
Comment #1
jhodgdonMe neither, but I'll see what I can find out.
Comment #2
robeano commenteddww describes the reason #693084-73: Regression: file_munge_filename() extension handling broken by move to File Field which I am copying and pasting here for ease of use:
If Apache doesn't recognize the file type it'll skip the extension and keep moving on until it finds one it recognizes. If filename is filename.php.pps and Apache doesn't recognize pps then it'll execute the file as a PHP file resulting in a possible hacked server. My understanding is that file munging is done to protect such a scenario.
This answers #2 in the Description.
Comment #3
jhodgdonAnd it answers #1 as well. That seems like a good thing to add to the doc.
It also answers #3: anything Apache recognizes should be added to $extensions.
Good thing to add to the doc...
Comment #4
jhodgdonHere's a patch for the doc for file_munge_filename(), which incorporates the information from #2 to answer the questions posed in this issue report. Hopefully.
Comment #5
dale42This information is excellent and answers the questions to the degree they need answering. #3 isn't explicitly answered, but I think that's OK in this context.
The voice is somewhat passive, I suggest changing to active form:
Munging a file name prevents unknown file extensions from masking
exploit files. When web servers such as Apache
decide how to process a URL request, they use the file extension. If
the extension is not recognized, Apache skips that extension and uses
the previous file extension. For example, if the file being requested
is exploit.php.pps, and Apache does not recognize the '.pps' extension, it
treats the file as PHP and executes it. To make this file name safe for
Apache and prevent it from executing as PHP, the .php extension is "munged"
into .php_, making the safe file name exploit.php_.pps.
Specifically, this function adds an underscore to all extensions that are between 2 and 5
characters in length, internal to the file name, and not included in
$extensions. If variable 'allow_insecure_uploads' evaluates to TRUE, no
alterations will be made.
Last line seems like it's just tacked on, and it's important. Maybe:
Specifically, this function adds an underscore to all extensions that are between 2 and 5
characters in length, internal to the file name, and not included in
$extensions.
Function behavior is controlled by the variable 'allow_insecure_uploads'. If 'allow_insecure_uploads' evaluates to TRUE, no
alterations will be made, if it evaluates to FALSE, the filename is 'munged'.
Comment #6
jhodgdonSo make a new patch?
Comment #7
dale42Sorry for being wishy-washy. It could go in as-is, but I think would be even better in a more active voice. So I guess that's a yes?
Comment #8
jhodgdonPlease make a new patch. Active voice is better.
Comment #9
dale42New patch with active voice per #5/#8
Comment #10
jhodgdonLooks good, thanks!
Comment #11
dries commentedCommitted to CVS HEAD. Thanks.
Comment #12
jhodgdonWe should probably port this to D6 as well.
Comment #13
rdrh555 commentedDone!
Comment #14
jhodgdonLooks good to me. Thanks!
Comment #15
gábor hojtsyCommitted, thanks.