mitre / mitre/HTTP-Proxy-Servlet
URL with encoded ":" or "%" cannot be redirected
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 1.5k
- Forks
- 557
- PR merge metrics
- No merged PRs in 30d
Description
Hi,
a URL like the following cannot be redirected to the target uri:
http:localhost:8080/mywebapp/myServletPath/%3Asda%25a
The reason is that the ProxyServlet uses servletRequest.getPathInfo() to create the rewriteURL and getPathInfo() returns the decoded path:
/:sda%a
This decoded path is used to create the redirect URL, which leads to an invalid URL in this case. We get an exception like this:
org.apache.http.ProtocolException: Invalid request URI: http:localhost:8080/mywebapp/myServletPath/:sda%a
org.apache.http.impl.client.RequestWrapper.<init>(RequestWrapper.java:83)
org.apache.http.impl.client.EntityEnclosingRequestWrapper.<init>(EntityEnclosingRequestWrapper.java:64)
org.apache.http.impl.client.DefaultRequestDirector.wrapRequest(DefaultRequestDirector.java:328)
org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:379)
org.apache.http.impl.client.AbstractHttpClient.doExecute(AbstractHttpClient.java:863)
org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:115)
org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:57)
org.mitre.dsmiley.httpproxy.ProxyServlet.service(ProxyServlet.java:245)
Suggestion: Use servletRequest.getRequestURI() instead of servletRequest.getPathInfo() to create the rewriteURL, because servletRequest.getRequestURI() returns the URI not decoded (see also http://stackoverflow.com/questions/966077/java-reading-undecoded-url-from-servlet).
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in ProxyServlet.java around line 245 and compare how getPathInfo() and getRequestURI() are used to build the rewrite URL. Reproduce the encoded-colon and percent URL from the issue, then verify that the redirected request remains a valid URI without the reported ProtocolException.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100