• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 305
  • Last Modified:

How to HTTP response splitting problem..??

Help me this problem:
How to HTTP response splitting problem: solution and example..i'm using java, Struts framework, MySQL
  • 2
1 Solution
So just what _is_ your question?  What is the "HTTP response splitting problem" you are referring to?
HTTP resposne splitting attack is the injection of %0d%0a into a string that later gets passed into HTTP headers. The attacker can then spoof the page output, set cookies, redirect the user somewhere else, etc.

Here is an article with a pretty good description of this problem in PHP, that could be adapted to Java:

You are only vulnerable to this problem if you somehow take user input that later gets inserted into the headers. For example, websites often have a Next= url passed in via the query string. You'd later use a client-side redirect to send the user to the location specified by Next=. In this case, you want to make sure to filter out any cases of ascii 10 and ascii 13 characters from the URL.

If the URL hasn't been encoded (i.e. it looks like "a b"), you would use:
url.replace('\n', ' ');
url.replace('\r', ' ');

If the URL has been encoded (i.e. it looks like "a%20b"), you would use

url.replace("/%0a/ig", "");
url.replace("/%0d/ig", "");

Hope that helps.
ncsvietnamAuthor Commented:
but i can't understand code php. If have code example login about java.. is better.
Sure, the example above I gave in Java (the url.replace one).

Or, you could simply use Javascript code to redirect the user instead of sending a Location header.  That way you won't be vulnerable to HTTP splitting since you're not sending any custom headers.

<script language="JavaScript">window.location.href="http://newurl"></script>

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now