Server-side request forgery (ARCH6104)
Key ruby.security.ssrf · Severity warning · Category security · CWE CWE-918
Making an outbound request to a user-supplied URL without validation lets attackers force the server to reach internal services or cloud metadata endpoints.
Incorrect
Section titled “Incorrect”def fetch(url) Net::HTTP.get(URI(url))endCorrect
Section titled “Correct”ALLOWED = %w[api.partner.com cdn.partner.com].freeze
def fetch(url) uri = URI(url) raise "blocked host" unless ALLOWED.include?(uri.host) Net::HTTP.get(uri)endValidate outbound URLs against an allowlist; block private IP ranges and metadata endpoints.