Note that there are some explanatory texts on larger screens.

plurals
  1. POWhy is it a security risk to allow encoded slashes in a URI?
    primarykey
    data
    text
    <p>I have a situation where I want encoded slashes in a URI (<code>%2F</code>), but my <code>.htaccess</code> rules are ignored when I make the request, sending me instead to a 404 page. I quickly found the Apache directive <a href="http://httpd.apache.org/docs/2.2/mod/core.html#allowencodedslashes" rel="noreferrer"><code>AllowEncodedSlashes</code></a>, which I plan to turn on, but I still don't understand why it's a security risk in the first place. Couldn't anyone manually transform the encoded slashes to real slashes, if they were trying to be nefarious? (Although I can't see what harm they could do...)</p> <p>The application I'm testing is written in PHP, and the mod_rewrite rule that interfaces with it looks like:</p> <pre><code>RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^test/(.*)$ /test.php?_escaped_fragment_=$1 [NE,QSA,L] </code></pre> <p>I just want to make sure I understand the risks before proceeding.</p> <hr> <p>To clarify: Apache does not allow encoded slashes in the <em>path</em>, but they are allowed in the query string. The query string is just as susceptible to the exploits listed by Christian below ("Remote Code Execution, Local File Access and Directory Traversal").</p> <p>So why did the ASF go so far as to create a special directive just to allow this behavior? I'm not trying to be difficult, I just really don't understand. I think it goes without saying that any user input (including the URI) needs to be verified before using it in any database or file system function.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload