In which settings is it possible to launch a HTTP Response Splitting Attack but not completely replace the HTTP message?

I wondered in which settings is it possible to launch a HTTP Response Splitting Attack but not completely replace the HTTP message?
The examples I saw all allowed full replacement of the HTTP response, which made me think the attacker coul… Continue reading In which settings is it possible to launch a HTTP Response Splitting Attack but not completely replace the HTTP message?

Cookie is not being set after CRLF Injection in one domain but set in another domain. How can i bypass/set it?

Ok i am facing a very weird behaviour that sets and doesnt set cookie both. So, first i have found CRLF injection in 2 domains, redacted.de and redacted_another.com. When i go to redacted_another.com vulnerable url, the cookie gets set int… Continue reading Cookie is not being set after CRLF Injection in one domain but set in another domain. How can i bypass/set it?

Is use of HttpServletRequest.getQueryString() for a response header vulnerable to response splitting?

I’ve been told that using HttpServletRequest.getQueryString() in a response header makes my application susceptible to HTTP response splitting attacks, but I just don’t see how.

It’s clear in the case of getParameter(String), which decodes percent-encoded values, but getQueryString() does not do that. From the documentation:

The value is not decoded by the container.

Source code snippet illustrating what I’m doing:

String path = "some_url";

String qs = req.getQueryString();
if (qs != null)
    path += "?" + qs;

// response instanceof HttpServletResponse
response.setStatus(HttpServletResponse.SC_MOVED_TEMPORARILY);
response.setHeader("Location", path);

I tried to reproduce the issue, and I just get the percent-encoded newlines echoed back to me in the response. When I change the code to getParameter(…), it works as expected (except that my container is nice enough to strip the newlines from the header value, but in theory at least it works). This similar question on Stack Overflow asks the same, and a comment to the answer pointing out that getQueryString() does not decode got no response.

Am I missing something here? Or is the advice I got wrong?

Continue reading Is use of HttpServletRequest.getQueryString() for a response header vulnerable to response splitting?

Is use of HttpServletRequest.getQueryString() for a response header vulnerable to response splitting?

I’ve been told that using HttpServletRequest.getQueryString() in a response header makes my application susceptible to HTTP response splitting attacks, but I just don’t see how.

It’s clear in the case of getParameter(String), which decodes percent-encoded values, but getQueryString() does not do that. From the documentation:

The value is not decoded by the container.

Source code snippet illustrating what I’m doing:

String path = "some_url";

String qs = req.getQueryString();
if (qs != null)
    path += "?" + qs;

// response instanceof HttpServletResponse
response.setStatus(HttpServletResponse.SC_MOVED_TEMPORARILY);
response.setHeader("Location", path);

I tried to reproduce the issue, and I just get the percent-encoded newlines echoed back to me in the response. When I change the code to getParameter(…), it works as expected (except that my container is nice enough to strip the newlines from the header value, but in theory at least it works). This similar question on Stack Overflow asks the same, and a comment to the answer pointing out that getQueryString() does not decode got no response.

Am I missing something here? Or is the advice I got wrong?

Continue reading Is use of HttpServletRequest.getQueryString() for a response header vulnerable to response splitting?

Is use of HttpServletRequest.getQueryString() for a response header vulnerable to response splitting?

I’ve been told that using HttpServletRequest.getQueryString() in a response header makes my application susceptible to HTTP response splitting attacks, but I just don’t see how.

It’s clear in the case of getParameter(String), which decodes percent-encoded values, but getQueryString() does not do that. From the documentation:

The value is not decoded by the container.

Source code snippet illustrating what I’m doing:

String path = "some_url";

String qs = req.getQueryString();
if (qs != null)
    path += "?" + qs;

// response instanceof HttpServletResponse
response.setStatus(HttpServletResponse.SC_MOVED_TEMPORARILY);
response.setHeader("Location", path);

I tried to reproduce the issue, and I just get the percent-encoded newlines echoed back to me in the response. When I change the code to getParameter(…), it works as expected (except that my container is nice enough to strip the newlines from the header value, but in theory at least it works). This similar question on Stack Overflow asks the same, and a comment to the answer pointing out that getQueryString() does not decode got no response.

Am I missing something here? Or is the advice I got wrong?

Continue reading Is use of HttpServletRequest.getQueryString() for a response header vulnerable to response splitting?