Skip to content
Access control Write-up Intermediate

WebConsole IP Whitelist bypass

The Web Console in Rails 4.0 and 4.1 checks the client IP against a whitelist using request.remote_ip, but older Rails versions compute that value with regular expressions that can be tricked by crafted X-Forwarded-For or Client-IP headers. An attacker could therefore reach the console and evaluate arbitrary Ruby statements.

0day.click

Published on 0day.click

With the release of Ruby on Rails 4.2 the so called Web Console was introduced.

The author, on 0day.click

The full write-up lives on its author's site

It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

How it worked

Root cause

Likely the older Rails IP-parsing regular expressions did not strictly validate the forwarded-for headers, so a crafted header could make request.remote_ip appear to be a whitelisted loopback address.

Impact

An attacker could bypass the console's IP whitelist and evaluate arbitrary Ruby statements, which could lead to remote code execution on the server.

What the attacker needed

Rails 4.0 or 4.1 with Web Console; attacker can send HTTP headers

The fix

Upgrading to Rails 4.2, which computes request.remote_ip more strictly, removes the bypass.

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 write-up has not been written yet. The Original tab links to the source.

The Web Console is a debugging tool that lets developers run Ruby code on a Rails app, and it is supposed to only accept connections from the local machine. The app decides whether a request is local by reading an address that can be influenced by HTTP headers the client sends. In older Rails versions those headers were parsed loosely, so a remote attacker could pretend to be local and reach the console.

What is Access control?

A user can do something their role should not allow: reach an admin function, act on a feature they have not paid for, or skip a permission check. IDOR is the special case where the object belongs to someone else.

Similar reports

View all

Same bug class and techniques, clearest first.

Broken access control

The lesson behind this report.

A user can do something their role should not allow: reach an admin function, act on a feature they have not paid for, or skip a permission check. IDOR is the special case where the object belongs to someone else.