We help IT Professionals succeed at work.

We've partnered with Certified Experts, Carl Webster and Richard Faulkner, to bring you a podcast all about Citrix Workspace, moving to the cloud, and analytics & intelligence. Episode 2 coming soon!Listen Now


How to HTTP response splitting problem..??

ncsvietnam asked
Medium Priority
Last Modified: 2010-04-11
Help me this problem:
How to HTTP response splitting problem: solution and example..i'm using java, Struts framework, MySQL
Watch Question

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.

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts


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>
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.


Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.