Skip to content
RCE Write-up Advanced

Airbnb – Ruby on Rails String Interpolation led to Remote Code Execution

An API endpoint that accepted listing directions as a string or array would evaluate Ruby string interpolation inside the input, allowing an attacker to execute shell commands. The attacker could run arbitrary commands on the server.

Brett Buerhaus Follow

Published on buer.haus

@nahamsec and I discovered a Cross-Site Scripting vulnerability a few months ago related to Rails typecasting request variables into JSON. This caused the output to be JSON formatted and the JSON indexes would avoid XSS encoding.

Brett Buerhaus (@bbuerhaus), Ben Sadeghipour (@nahamsec), on buer.haus

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 application passed user-controlled input into a Ruby string interpolation context without sanitising it, so the #{} syntax was evaluated as code.

Impact

An attacker could execute arbitrary shell commands on the server, leading to full remote code execution.

What the attacker needed

Access to the listing update API; ability to send POST requests

The fix

The vulnerability was fixed.

How it was found

  1. Send a POST request to the listing update API with directions as a string.
  2. Change directions to an array containing an object.
  3. Observe the output shows YAML with a Ruby hash tag.
  4. Insert a string interpolation expression like #{1+1} inside the array and see it evaluated.
  5. Use the %x syntax to run a shell command such as ls.

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 website let users send a list of directions for a rental listing. The server took that text and ran it through a feature that replaces special code like #{1+1} with the result. Because the server did not block this, an attacker could put a command like listing files inside the text and the server would run it.

What is RCE?

Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.

More by Brett Buerhaus

View all

3 more disclosed reports, best first.

More from Airbnb

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Remote code execution

The lesson behind this report.

Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.