HTTP Response Splitting (CRLF injection) in report_story
The report_story page set a cookie using the reported_tweet_id parameter without strictly validating it as a number. An attacker could inject arbitrary headers and response content via a CRLF injection bypass using UTF-8 encoded characters.
Originally disclosed on HackerOne
- Triaged in 35 hours
- Fixed in 13 days
- Paid in 6 days
- Disclosed after 37 days
Summary by the researcher
Write-up: https://blog.innerht.ml/twitter-crlf-injection/
The report
Hi,
I would like to report a HTTP Response Splitting vulnerability in https://twitter.com/i/safety/report_story that allows attackers to inject arbitrary headers and contents in the response.
PoC:
Details:
The page will set cookie for the parameter reported_tweet_id. However, it doesn't validate strictly if it is a number. Although there is a protection against CRLF injection by detecting the presence of any NewLine character (0x0a), it can be bypassed with characters encoded in UTF-8 as the the page will try to convert them back to the original Unicode form and extract the last byte. For example, %E5%98%8A => U+560A => 0A.
Attachments

Context
The target is X (Twitter), and the feature in question is the safety reporting flow at https://twitter.com/i/safety/report_story. That page is where a user reports a tweet, and it takes a number of query parameters to describe the report: which view to show, the source of the report, the reported user, the reporter, whether the content is media or promoted, and the ID of the reported tweet.
The researcher found that the page sets a cookie for the reported_tweet_id parameter, and that the value is not strictly validated as a number. That makes the endpoint a candidate for HTTP response splitting (CRLF injection): if an attacker can get a newline into the header value, they can terminate the header and start writing arbitrary headers and body content into the response.
Setup
No accounts, roles, tools or versions are described in the report. The only precondition that matters is that the endpoint accepts the reported_tweet_id parameter and uses it when building the response, which the researcher demonstrated with a single crafted URL. The report links to https://blog.innerht.ml/twitter-crlf-injection/.
Finding it
The researcher noticed that the page sets a cookie based on the reported_tweet_id parameter. Because that value ends up in a response header, any newline the attacker can smuggle into it would let them inject additional headers and even response body content.
The page does have a defence: it checks for the presence of any newline character (0x0a) and rejects the input if one is found. The researcher's insight was that the newline check can be bypassed with characters encoded in UTF-8, because the page converts them back to the original Unicode form and extracts the last byte. A multi-byte UTF-8 sequence whose final byte is 0x0a therefore passes the newline check but still produces a newline once decoded.
Exploitation
Step 1: Send the crafted request
The researcher supplied a URL with the reported_tweet_id parameter set to a UTF-8 encoded character followed by an injected Set-Cookie header:
https://twitter.com/i/safety/report_story?next_view=report_story_start&source=reporttweet&reported_user_id=1&reporter_user_id=1&is_media=true&is_promoted=true&reported_tweet_id=%E5%98%8A%E5%98%8DSet-Cookie:%20test
The other parameters (next_view, source, reported_user_id, reporter_user_id, is_media, is_promoted) are the normal parameters the reporting page expects. The interesting part is reported_tweet_id, which contains %E5%98%8A%E5%98%8D followed by Set-Cookie:%20test.
Step 2: Understand the encoding bypass
The first percent-encoded sequence decodes to the UTF-8 bytes for U+560A. The newline check does not catch the encoded sequence, so it passes the filter. When the page converts the value back to its original Unicode form and extracts the last byte, that byte is 0x0a, a newline. The researcher gives the mapping explicitly:
%E5%98%8A => U+560A => 0A
So the injected value yields a newline followed by Set-Cookie: test.
Step 3: Observe the result
The report includes a screenshot as an attachment:

Because the newline terminates the original header, everything after it is interpreted as new headers. The researcher states that this allows attackers to inject arbitrary headers and contents in the response.
Root cause
The mistake is a mismatch between the validation and the decoding. The newline check runs against the raw input, looking for 0x0a, but the value is subsequently decoded from UTF-8 back to Unicode and its last byte is taken. A multi-byte sequence such as %E5%98%8A passes the raw check because it contains no 0x0a byte, yet its decoded form ends in 0x0a. The filter and the sink therefore disagree about what the value is, and the newline reaches the header.
A second contributing factor is that reported_tweet_id is not strictly validated as a number. If the parameter were parsed as an integer, the non-numeric payload would never reach the header. The report does not show the server-side code, so the exact decoding routine is likely as described rather than confirmed.
Impact
The researcher states that the vulnerability allows attackers to inject arbitrary headers and contents in the response. The report does not describe a specific attack chain, victim population or preconditions beyond the crafted URL, and no severity or CVSS score is given.
Fix
The obvious direction, based on the root cause, is to validate reported_tweet_id strictly as a number before it is used in any header, and to perform the newline check after decoding rather than before, so that multi-byte sequences cannot smuggle a 0x0a past the filter.
Variants to test
- Other parameters reflected into headers. Try every query parameter that ends up in a
Set-Cookie,Locationor other response header, and send a UTF-8 sequence whose last byte is0x0a(for example%E5%98%8A). A positive result is a response containing an extra header you supplied. - Other newline encodings. Try sequences whose last byte is
0x0das well, and combinations that produce\r\n. A positive result is a header injection or a split response. - Numeric parameters that are not validated. Look for ID-like parameters that are used in headers or redirects and are not parsed as integers. A positive result is any non-numeric value appearing verbatim in a header.
- Double decoding. Try values that only become a newline after a second decode, such as
%25E5%2598%258A. A positive result is the same injected header appearing after the second decode.
Hunting notes
This kind of bug tends to hide in endpoints that take user-controlled values and place them into response headers: cookie setters, redirect builders, and pages that echo request parameters into Location or Set-Cookie. During recon, look for parameters whose values appear in headers rather than only in the body, and for filters that check for 0x0a or 0x0d on the raw input. The signal is a parameter that is described as an ID but is not strictly parsed as a number.
What happened, in plain words
X (the site formerly known as Twitter) has a page where you can report a tweet that breaks the rules. The address of that page is https://twitter.com/i/safety/report_story. When you open it, the page needs to know things like which tweet you are reporting and who is reporting it, so those details are passed along in the address itself, after a question mark. Those extra pieces of the address are called query parameters.
One of those parameters is called reported_tweet_id, and it is meant to hold the number that identifies the reported tweet. The researcher found that the page sets a cookie for that parameter, specifically a Set-Cookie header. A response header is a small line of information that the web server sends back to your browser alongside the page. The Set-Cookie header is the one that tells the browser to store a small piece of data called a cookie.
Headers are separated from each other by invisible line breaks (newline characters). If an attacker can sneak a line break into a value that ends up in a header, they can end the real header early and start writing their own extra headers, and even page content, into the response. That trick is called HTTP response splitting, or CRLF injection (CR and LF are the two characters that make a line break).
The page did try to stop this: it checked the input for a newline character and rejected it if one was found. But the researcher found a way around that check by using a character that looks harmless when it arrives but turns into a newline later, after the page has processed it.
The report
The researcher opened the report by saying they wanted to report an HTTP response splitting vulnerability in https://twitter.com/i/safety/report_story, and that it allows attackers to inject arbitrary headers and contents in the response. In plain terms: an attacker can make the server's reply contain lines that the server never intended to send.
PoC:
A PoC (proof of concept) is a small, concrete demonstration that a bug is real. Instead of just describing the problem, you show a request that triggers it. Here is the one from the report:
https://twitter.com/i/safety/report_story?next_view=report_story_start&source=reporttweet&reported_user_id=1&reporter_user_id=1&is_media=true&is_promoted=true&reported_tweet_id=%E5%98%8A%E5%98%8DSet-Cookie:%20test
Line by line, in plain words:
https://twitter.com/i/safety/report_storyis the reporting page. Everything after the?is extra information handed to that page.next_view=report_story_starttells the page which view to show. It is one of the normal parameters the page expects.source=reporttweetsays where the report came from. Also normal.reported_user_id=1is the ID of the user being reported. Normal.reporter_user_id=1is the ID of the person doing the reporting. Normal.is_media=truesays whether the reported content is media. Normal.is_promoted=truesays whether the content is promoted. Normal.reported_tweet_id=is the interesting one. It is supposed to be the number of the reported tweet, but here it holds%E5%98%8A%E5%98%8DSet-Cookie:%20test.%E5%98%8A%E5%98%8Dis a percent-encoded sequence. When a browser sends special characters in a web address, it writes them as a percent sign followed by two hexadecimal digits, so that the address stays plain text. This particular sequence is the smuggled trick, explained in the next section.Set-Cookie:%20testis the text the attacker wants the server to treat as a brand new header.%20is the percent-encoded form of a space, so this readsSet-Cookie: test.
So the whole URL is a normal reporting request with one parameter carrying an encoded sequence and a Set-Cookie string.
Details:
The report explains that the page will set a cookie for the parameter reported_tweet_id. In other words, the page sets a cookie based on that parameter. However, the page does not validate strictly that the value is a number. A tweet ID is a number, so a strict check would reject anything that is not digits. Because that check is missing, arbitrary text can travel through the parameter.
There is still a defence against CRLF injection: the page detects the presence of any newline character (0x0a) and blocks the input. 0x0a is how computers write the newline character in hexadecimal (base 16). The problem is that this check can be bypassed with characters encoded in UTF-8. UTF-8 is the standard way of storing text as bytes, and some characters take more than one byte. The page later tries to convert those bytes back to the original Unicode form and extract the last byte. Unicode is the universal catalogue that gives every character in every writing system a number, and each such number is called a code point, written like U+560A.
The report gives the mapping explicitly:
%E5%98%8A => U+560A => 0A
In plain words:
%E5%98%8Ais three bytes written in percent-encoded form:E5,98and8A.- Those three bytes together are the UTF-8 encoding of the Unicode character
U+560A. - When the page converts the value back to Unicode and takes the last byte, that last byte is
0A, which is a newline.
So the filter does not catch the encoded sequence. Later, when the page decodes the value, a newline appears. The filter and the place where the value is used disagree about what the value actually is, and the newline slips past.
Attachments
The report includes a screenshot as an attachment:

Because the newline ends the original header, everything after it is read as new headers. The researcher states that this allows attackers to inject arbitrary headers and contents in the response.
Why this matters
A cookie is a small label that a website asks your browser to keep and send back on later visits. It is often used to remember who you are, which is why a cookie can be sensitive. The report does not describe a specific attack chain, victim population or preconditions beyond the crafted URL, and no severity or CVSS score is given.
The underlying mistake
The root cause is a mismatch between checking and decoding. The newline check runs on the raw input and looks for 0x0a, but the value is later decoded from UTF-8 back to Unicode and its last byte is taken. A multi-byte sequence such as %E5%98%8A passes the raw check because it contains no 0x0a byte, yet its decoded form ends in 0x0a. The filter and the place where the value is used therefore disagree about what the value is, and the newline reaches the header.
A second contributing factor is that reported_tweet_id is not strictly validated as a number. If the parameter were parsed as an integer, the non-numeric payload would never reach the header. The report does not show the server-side code, so the exact decoding routine is likely as described rather than confirmed.
Fix
The obvious direction, based on the root cause, is to validate reported_tweet_id strictly as a number before it is used in any header, and to perform the newline check after decoding rather than before, so that multi-byte sequences cannot smuggle a 0x0a past the filter.
Variants to test
Each one is a variation on the same idea: get a line break into a header.
- Other parameters reflected into headers. Try every query parameter that ends up in a
Set-Cookie,Locationor other response header, and send a UTF-8 sequence whose last byte is0x0a(for example%E5%98%8A). A positive result is a response containing an extra header you supplied. - Other newline encodings. Try sequences whose last byte is
0x0das well, and combinations that produce\r\n. A positive result is a header injection or a split response. - Numeric parameters that are not validated. Look for ID-like parameters that are used in headers or redirects and are not parsed as integers. A positive result is any non-numeric value appearing verbatim in a header.
- Double decoding. Try values that only become a newline after a second decode, such as
%25E5%2598%258A. A positive result is the same injected header appearing after the second decode.
Hunting notes
This kind of bug tends to hide in endpoints that take user-controlled values and place them into response headers: cookie setters, redirect builders, and pages that echo request parameters into Location or Set-Cookie. During recon, look for parameters whose values appear in headers rather than only in the body, and for filters that check for 0x0a or 0x0d on the raw input. The signal is a parameter that is described as an ID but is not strictly parsed as a number.
Glossary
- API: a way for one piece of software to ask another for data or actions, using agreed addresses and formats.
- Cookie: a small piece of data a website asks your browser to store and send back on later requests, often used to remember who you are.
- CRLF injection: sneaking the two characters that make a line break (carriage return and line feed) into a value, so that the receiver treats the rest as a new line.
- CVSS: a standard scoring system that rates how severe a security vulnerability is.
- Endpoint: a specific address on a server that accepts requests and does something, such as a page or an API path.
- Header: a line of extra information sent with a web request or response, such as which cookies to set or where to redirect.
- HTTP response splitting: a vulnerability where an attacker inserts line breaks into a response so that extra headers or body content can be added.
- Integer: a whole number, such as 1, 42 or 9000.
- Location header: a response header that tells the browser to go to a different address.
- Newline character: the invisible character that marks the end of a line of text, written
0x0ain hexadecimal. - Parameter: a named value passed along with a request, usually after a
?in a web address. - Percent-encoding: writing special characters in a web address as a percent sign followed by two hexadecimal digits, such as
%20for a space. - PoC (proof of concept): a small, concrete demonstration that a bug is real.
- Query parameter: a parameter placed in the address after the
?, separated by&signs. - Recon: the information-gathering phase before testing, where you map out what a site does and which inputs it accepts.
- Response: what a web server sends back to a browser after a request.
- Set-Cookie header: the response header that tells the browser to store a cookie.
- Severity: a rating of how serious a vulnerability is.
- Unicode: the universal catalogue that assigns a number (code point) to every character in every writing system.
- UTF-8: the standard way of storing Unicode text as bytes, where some characters take more than one byte.
- Vulnerability: a weakness in software that someone can abuse to make it behave in a way its makers did not intend.