Skip to content
Misconfiguration Disclosed report Intermediate CVE-2022-30123

Escape Sequence Injection vulnerability in Rack

Rack's common logger writes the request method into the log line without sanitising it, so control characters such as backspaces pass through unchanged. An attacker could inject escape sequences into the logs, which may then be executed by a victim's terminal emulator when the log is viewed.

vairelt Follow

Originally disclosed on HackerOne

Medium 6.5 View original
  • Disclosed after 19 months

Dangerous bug in commonlogger of rack that allows to inject escape sequences in logs, the same bug alredy closed in webrick https://www.ruby-lang.org/en/news/2010/01/10/webrick-escape-sequence-injection/ Logger processes the query string correctly, but request metod printing as is. https://github.com/rack/rack/blob/master/lib/rack/common_logger.rb#L50 Triggering request:

GET\b\b\bPOST /sign_in?test1=1\b2 HTTP/1.0
Host: 127.0.0.1:4567

Result:

Rack::Lint::LintError: REQUEST_METHOD unknown: POST
        /usr/local/bundle/gems/rack-2.2.3/lib/rack/lint.rb:21:in `assert'
        /usr/local/bundle/gems/rack-2.2.3/lib/rack/lint.rb:340:in `check_env'
        /usr/local/bundle/gems/rack-2.2.3/lib/rack/lint.rb:44:in `_call'
        /usr/local/bundle/gems/rack-2.2.3/lib/rack/lint.rb:38:in `call'
        /usr/local/bundle/gems/rack-2.2.3/lib/rack/show_exceptions.rb:23:in `call'
        /usr/local/bundle/gems/rack-2.2.3/lib/rack/common_logger.rb:38:in `call'
        /usr/local/bundle/gems/sinatra-2.1.0/lib/sinatra/base.rb:253:in `call'
        /usr/local/bundle/gems/rack-2.2.3/lib/rack/content_length.rb:17:in `call'
        /usr/local/bundle/gems/rack-2.2.3/lib/rack/handler/webrick.rb:95:in `service'
        /usr/local/bundle/gems/webrick-1.7.0/lib/webrick/httpserver.rb:140:in `service'
        /usr/local/bundle/gems/webrick-1.7.0/lib/webrick/httpserver.rb:96:in `run'
        /usr/local/bundle/gems/webrick-1.7.0/lib/webrick/server.rb:310:in `block in start_thread'
172.19.0.1 - - [29/Nov/2021:12:19:06 +0000] "POST /sign_in?test1=1%082 HTTP/1.1" 500 950 0.0006

Impact

inject malicious escape sequences to its logs, making it possible for dangerous control characters to be executed on a victim's terminal emulator

The original report as published on HackerOne, by vairelt. 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

Impact

An attacker could inject malicious escape sequences into the logs, making it possible for dangerous control characters to be executed on a victim's terminal emulator.

What the attacker needed

Ability to send a crafted request; victim views the log in a terminal

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.

A web server keeps a log of every request it receives. Some characters in a request are invisible control codes that a terminal program can interpret as commands rather than text. Here the logging code copied the request method into the log without cleaning it, so an attacker could slip those control codes in and have them run on someone's screen when they read the log.

What is Misconfiguration?

Settings left unsafe: exposed panels, open storage buckets, debug modes, default credentials.

More from Ruby on Rails

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Security misconfiguration

The lesson behind this report.

Settings left unsafe: exposed panels, open storage buckets, debug modes, default credentials.