Aller au contenu

Server-side request forgery (ARCH6104)

Ce contenu n’est pas encore disponible dans votre langue.

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.

def fetch(url)
Net::HTTP.get(URI(url))
end
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)
end

Validate outbound URLs against an allowlist; block private IP ranges and metadata endpoints.