Ruby Insecure Openuri Http Request
Description
Detects usage of Ruby's OpenURI library with insecure HTTP or FTP URL schemes. This creates a risk of man-in-the-middle attacks since data is transmitted unencrypted over the network, potentially exposing sensitive information to attackers.
Detection Strategy
• Check if the OpenURI library is imported in the Ruby code
• Look for calls to URI.open() or URI.parse() methods
• Examine if the URL parameter uses insecure schemes like 'http://' or 'ftp://'
• Report vulnerability when unencrypted URI schemes are used with these methods
Vulnerable code example
require 'openuri'
def fetch_url
url = "http://example.com/data"
URI.open(url) do |f| # Vulnerable: Using URI.open allows arbitrary URL requests (SSRF risk)
f.read
end
end✅ Secure code example
require 'uri'
require 'open-uri'
def fetch_url
url = "http://example.com/data"
# Validate URL against allowlist of trusted domains
uri = URI.parse(url)...Search for vulnerabilities in your apps for free with Fluid Attacks' automated security testing! Start your 21-day free trial and discover the benefits of the Continuous Hacking Essential plan. If you prefer the Advanced plan, which includes the expertise of Fluid Attacks' hacking team, fill out this contact form.