You are viewing a plain text version of this content. The canonical link for it is here.
Posted to bugs@httpd.apache.org by bu...@apache.org on 2023/04/27 09:25:31 UTC

[Bug 66580] New: url contain %25(encoded for %) in path, httpd will return 400(bad request) if set AllowEncodedSlashes NoDecode

https://bz.apache.org/bugzilla/show_bug.cgi?id=66580

            Bug ID: 66580
           Summary: url contain %25(encoded for %) in path, httpd will
                    return 400(bad request) if set AllowEncodedSlashes
                    NoDecode
           Product: Apache httpd-2
           Version: 2.4.57
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: major
          Priority: P2
         Component: mod_proxy
          Assignee: bugs@httpd.apache.org
          Reporter: yongqiang.liu@nokia-sbell.com
  Target Milestone: ---

Hi, we met a problem that if our url contain %25(encoded %) in path, then httpd
which act as a reverse proxy server will return 400(bad request) to client
after we upgrade to httpd-2.4.57, we use the flag AllowEncodedSlashes as
NoDecode to enable the slashes not decoded by httpd.

Below steps is about how to produce this problem:

I test it with manually with apache official docker image: httpd: 2.4.57, below
is my test steps:

1. Start a container from this image:
docker create --name apache -p 8080:80 httpd:2.4.57
docker start apache

2. Attach in to it and edit the httpd.conf
docker exec -ti apache bash
# add the configuration to file /usr/local/apache2/conf/httpd.conf 
LogLevel debug
AllowEncodedSlashes NoDecode
# load proxy module
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_http_module modules/mod_proxy_http.so
# include the proxy configuration
Include conf/extra/httpd-proxy.conf

3. Add a new configuration httpd-proxy.conf
# add new configuration file to /usr/local/apache2/conf/extra/
$ cat conf/extra/httpd-proxy.conf
<VirtualHost *:80>

    # Proxy the requests to the backend server
    ProxyPass / http://127.0.0.1:8080/
    ProxyPassReverse / http://127.0.0.1:8080/
</VirtualHost>

4. Start a simple python http server like below
# cat app.py
from bottle import Bottle, response

app = Bottle()

@app.route('/api')
def hello_world():
    response.content_type = 'application/json'
    return '{"message": "Hello, World!"}'

if __name__ == '__main__':
    app.run(debug=True)

5. Reload httpd
Kill -s SIGHUP 1

6. Send request via curl
$ curl http://localhost:80/xxxx%25xxxxx
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>400 Bad Request</title>
</head><body>
<h1>Bad Request</h1>
<p>Your browser sent a request that this server could not understand.<br />
</p>
</body></html>

But this request can reach to endpoint, this 404 is returned by endpoint server
# curl http://localhost:80/xxxx%20xxxxx

    <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
    <html>
        <head>
            <title>Error: 404 Not Found</title>
            <style type="text/css">
              html {background-color: #eee; font-family: sans;}
              body {background-color: #fff; border: 1px solid #ddd;
                    padding: 15px; margin: 15px;}
              pre {background-color: #eee; border: 1px solid #ddd; padding:
5px;}
            </style>
        </head>
        <body>
            <h1>Error: 404 Not Found</h1>
            <p>Sorry, the requested URL
<tt>&#039;http://localhost/xxxx%20xxxxx&#039;</tt>
               caused an error:</p>
            <pre>Not found: &#039;/xxxx xxxxx&#039;</pre>
        </body>
    </html>


I also try to revert the changes in httpd-2.4.57, I found the problem is in
this change:
https://github.com/apache/httpd/commit/9b8cf1746bb004050b02a30bf0222479fbe405c2
When I revert this change, then the problem was gone.

I think this maybe is a bug for mod_proxy introduced by this change.

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: bugs-unsubscribe@httpd.apache.org
For additional commands, e-mail: bugs-help@httpd.apache.org


[Bug 66580] url contain %25(encoded for %) in path, httpd will return 400(bad request) if set AllowEncodedSlashes NoDecode

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=66580

--- Comment #3 from Liu Yongqiang <yo...@nokia-sbell.com> ---
(In reply to Ruediger Pluem from comment #2)
> Created attachment 38547 [details]
> Possible fix
> 
> Does the attached patch fix your issue?

Yes, I tested your patch, and indeed it works, thanks.

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: bugs-unsubscribe@httpd.apache.org
For additional commands, e-mail: bugs-help@httpd.apache.org


[Bug 66580] url contain %25(encoded for %) in path, httpd will return 400(bad request) if set AllowEncodedSlashes NoDecode

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=66580

--- Comment #1 from Liu Yongqiang <yo...@nokia-sbell.com> ---
Created attachment 38546
  --> https://bz.apache.org/bugzilla/attachment.cgi?id=38546&action=edit
Producing steps

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: bugs-unsubscribe@httpd.apache.org
For additional commands, e-mail: bugs-help@httpd.apache.org


[Bug 66580] url contain %25(encoded for %) in path, httpd will return 400(bad request) if set AllowEncodedSlashes NoDecode

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=66580

--- Comment #2 from Ruediger Pluem <rp...@apache.org> ---
Created attachment 38547
  --> https://bz.apache.org/bugzilla/attachment.cgi?id=38547&action=edit
Possible fix

Does the attached patch fix your issue?

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: bugs-unsubscribe@httpd.apache.org
For additional commands, e-mail: bugs-help@httpd.apache.org


[Bug 66580] url contain %25(encoded for %) in path, httpd will return 400(bad request) if set AllowEncodedSlashes NoDecode

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=66580

Ruediger Pluem <rp...@apache.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |FixedInTrunk,
                   |                            |PatchAvailable
             Status|NEEDINFO                    |RESOLVED
         Resolution|---                         |LATER

--- Comment #4 from Ruediger Pluem <rp...@apache.org> ---
Committed to trunk as r1909464.

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: bugs-unsubscribe@httpd.apache.org
For additional commands, e-mail: bugs-help@httpd.apache.org


[Bug 66580] url contain %25(encoded for %) in path, httpd will return 400(bad request) if set AllowEncodedSlashes NoDecode

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=66580

Ruediger Pluem <rp...@apache.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |NEEDINFO

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: bugs-unsubscribe@httpd.apache.org
For additional commands, e-mail: bugs-help@httpd.apache.org