Skip to content
Smuggling / CRLF Disclosed report Intermediate CVE-2021-33621

Security Unfavorable Specifications and Implementations in the CGI::Cookie Class

The cgi gem did not properly validate user input when generating HTTP responses, allowing an attacker to inject malicious headers or body content. Also, CGI::Cookie objects created from user input could inject invalid attributes into the Set-Cookie header.

ht0k Follow

Originally disclosed on HackerOne

  • Triaged in 9 days
  • Fixed in 9 days
  • Disclosed after 39 days

Summary by the program

CVE-2021-33621: HTTP response splitting in CGI Posted by mame on 22 Nov 2022

We have released the cgi gem version 0.3.5, 0.2.2, and 0.1.0.2 that has a security fix for a HTTP response splitting vulnerability. This vulnerability has been assigned the CVE identifier CVE-2021-33621.

Details If an application that generates HTTP responses using the cgi gem with untrusted user input, an attacker can exploit it to inject a malicious HTTP response header and/or body.

Also, the contents for a CGI::Cookie object were not checked properly. If an application creates a CGI::Cookie object based on user input, an attacker may exploit it to inject invalid attributes in Set-Cookie header. We think such applications are unlikely, but we have included a change to check arguments for CGI::Cookie#initialize preventatively.

Please update the cgi gem to version 0.3.5, 0.2.2, and 0.1.0.2, or later. You can use gem update cgi to update it. If you are using bundler, please add gem "cgi", ">= 0.3.5" to your Gemfile.

Credits Thanks to Hiroshi Tokumaru for discovering this issue.

Full Security Advisory: https://www.ruby-lang.org/en/news/2022/11/22/http-response-splitting-in-cgi-cve-2021-33621/

The original report as published on HackerOne, by ht0k. 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 did not sanitise or validate user-supplied input before including it in HTTP headers or cookie attributes.

Impact

An attacker could inject a malicious HTTP response header and/or body, and may inject invalid attributes in the Set-Cookie header if an application creates a CGI::Cookie object from user input.

What the attacker needed

Application uses cgi gem with untrusted input; application creates CGI::Cookie from user input

The fix

The cgi gem was updated to versions 0.3.5, 0.2.2, and [redacted], which include a security fix and a change to check arguments for CGI::Cookie#initialize.

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 web application builds a response using data from users, it must be careful not to let that data break the structure of the response. Here, the library failed to check the data, so an attacker could sneak in extra headers or content, potentially changing how the browser behaves.

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 ht0k

View all

1 more disclosed report, best first.

More from Internet Bug Bounty

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.