Ruby's open-uri is one step away from RCE
Ruby's open-uri library patches Kernel.open, so passing user-controlled input to open() can lead to remote code execution (via a pipe-prefixed string) or arbitrary local file reads (via a path that does not start with http). The library also fails to limit redirects and permits http-to-ftp redirects, enabling SSRF.
sakurity.com
Published on sakurity.com
Ruby’s OpenURI is an easy-to-use wrapper for net/http, net/https and net/ftp. As far as I know it’s the most popular way to read URL content, make a GET request or download a file.
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
Impact
An attacker could achieve remote code execution, read arbitrary local files, or perform SSRF via redirects, depending on how the application calls open().
What the attacker needed
Application passes user input to open(); user input is not strictly validated
The fix
The author recommends that Ruby core developers deprecate open-uri and create a separate openURI method instead.
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.
In Ruby, the open() method is normally used to run a command or open a file. The open-uri library changes open() so it can also fetch web addresses, but it keeps the dangerous command-running behaviour. If a website passes a user's input straight into open(), an attacker can make the server run commands or read files.
What is RCE?
Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.