{"@ID": "918", "@Name": "Server-Side Request Forgery (SSRF)", "@Abstraction": "Base", "@Structure": "Simple", "@Status": "Incomplete", "@Diagram": "/data/images/CWE-918-Diagram.png", "Description": "The web server receives a URL or similar request from an upstream component and retrieves the contents of this URL, but it does not sufficiently ensure that the request is being sent to the expected destination.", "Related_Weaknesses": {"Related_Weakness": [{"@Nature": "ChildOf", "@CWE_ID": "441", "@View_ID": "1000", "@Ordinal": "Primary"}, {"@Nature": "ChildOf", "@CWE_ID": "610", "@View_ID": "1003", "@Ordinal": "Primary"}]}, "Weakness_Ordinalities": {"Weakness_Ordinality": {"Ordinality": "Resultant"}}, "Applicable_Platforms": {"Language": {"@Class": "Not Language-Specific", "@Prevalence": "Undetermined"}, "Technology": [{"@Class": "Web Based", "@Prevalence": "Undetermined"}, {"@Name": "AI/ML", "@Prevalence": "Often"}, {"@Name": "Web Server", "@Prevalence": "Undetermined"}]}, "Alternate_Terms": {"Alternate_Term": [{"Term": "XSPA", "Description": "Cross Site Port Attack"}, {"Term": "SSRF", "Description": "Server-Side Request Forgery"}]}, "Modes_Of_Introduction": {"Introduction": [{"Phase": "Architecture and Design"}, {"Phase": "Implementation"}]}, "Common_Consequences": {"Consequence": [{"Scope": "Confidentiality", "Impact": "Read Application Data"}, {"Scope": "Integrity", "Impact": "Execute Unauthorized Code or Commands"}, {"Scope": "Access Control", "Impact": "Bypass Protection Mechanism", "Note": "By providing URLs to unexpected hosts or ports, attackers can make it appear that the server is sending the request, possibly bypassing access controls such as firewalls that prevent the attackers from accessing the URLs directly. The server can be used as a proxy to conduct port scanning of hosts in internal networks, use other URLs such as that can access documents on the system (using file://), or use other protocols such as gopher:// or tftp://, which may provide greater control over the contents of requests."}]}, "Detection_Methods": {"Detection_Method": {"@Detection_Method_ID": "DM-14", "Method": "Automated Static Analysis", "Description": "Automated static analysis, commonly referred to as Static Application Security Testing (SAST), can find some instances of this weakness by analyzing source code (or binary/compiled code) without having to execute it. Typically, this is done by building a model of data flow and control flow, then searching for potentially-vulnerable patterns that connect \"sources\" (origins of input) with \"sinks\" (destinations where the data interacts with external components, a lower layer such as the OS, etc.)", "Effectiveness": "High"}}, "Demonstrative_Examples": {"Demonstrative_Example": {"Intro_Text": "This code intends to receive a URL from a user, access the URL, and return the results to the user.", "Example_Code": [{"@Nature": "Bad", "@Language": "PHP", "xhtml:div": {"xhtml:i": ["# User-controlled input", "# Fetch the content of the provided URL"], "xhtml:br": [null, null, null, null, null, null], "#text": "$url = $_GET['url'];\n                     \n                     \n                     $response = file_get_contents($url);\n\t\t\t\t\t echo $response;"}}, {"@Nature": "Good", "@Language": "PHP", "xhtml:div": {"xhtml:i": ["# Define allowed URLs (or domains)", "# Get the user-provided URL", "# Validate against allowed URLs", "# Fetch content safely", "# Escape output for safety"], "xhtml:br": [null, null, null, null, null, null, null, null, null, null, null, null], "xhtml:div": [{"@style": "margin-left:1em;", "xhtml:br": [null, null], "#text": "'https://example.com/data.json','https://api.example.com/info',"}, {"@style": "margin-left:1em;", "xhtml:br": [null, null, null], "#text": "http_response_code(400);echo \"Invalid or unauthorized URL.\";exit;"}, {"@style": "margin-left:1em;", "xhtml:br": [null, null, null], "#text": "http_response_code(500);echo \"Failed to fetch content.\";exit;"}], "#text": "$allowed_urls = [];$url = $_GET['url'] ?? '';if (!in_array($url, $allowed_urls)) {}$response = @file_get_contents($url);if ($response === false) {}echo htmlspecialchars($response);"}}], "Body_Text": "The given PHP code is vulnerable to Server-Side Request Forgery (SSRF) because it directly accepts a user-supplied URL from the $_GET['url'] parameter and fetches its content using file_get_contents(), without any validation or restrictions. This allows an attacker to request internal or restricted resources within the server's network, such as internal admin panels, cloud metadata endpoints, or local services running on localhost."}}, "Observed_Examples": {"Observed_Example": [{"Reference": "CVE-2026-33626", "Description": "SSRF in LLM toolkit accesses arbitrary URLs for images, as exploited in the wild in April 2026 to conduct port scanning [REF-1519]", "Link": "https://www.cve.org/CVERecord?id=CVE-2026-33626"}, {"Reference": "CVE-2024-3095", "Description": "SSRF in LLM application development framework because the URL retriever allows connections to local addresses using a crafted Location header", "Link": "https://www.cve.org/CVERecord?id=CVE-2024-3095"}, {"Reference": "CVE-2023-32786", "Description": "Chain: LLM integration framework has prompt injection\n\t     (CWE-1427) that allows an attacker to force the service to retrieve\n\t     data from an arbitrary URL, essentially providing SSRF (CWE-918) and\n\t     potentially injecting content into downstream tasks.", "Link": "https://www.cve.org/CVERecord?id=CVE-2023-32786"}, {"Reference": "CVE-2021-26855", "Description": "Server Side Request Forgery (SSRF) in mail server, as exploited in the wild per CISA KEV.", "Link": "https://www.cve.org/CVERecord?id=CVE-2021-26855"}, {"Reference": "CVE-2021-21973", "Description": "Server Side Request Forgery in cloud platform, as exploited in the wild per CISA KEV.", "Link": "https://www.cve.org/CVERecord?id=CVE-2021-21973"}, {"Reference": "CVE-2016-4029", "Description": "Chain: incorrect validation of intended decimal-based IP address format (CWE-1286) enables parsing of octal or hexadecimal formats (CWE-1389), allowing bypass of an SSRF protection mechanism (CWE-918).", "Link": "https://www.cve.org/CVERecord?id=CVE-2016-4029"}, {"Reference": "CVE-2002-1484", "Description": "Web server allows attackers to request a URL from another server, including other ports, which allows proxied scanning.", "Link": "https://www.cve.org/CVERecord?id=CVE-2002-1484"}, {"Reference": "CVE-2004-2061", "Description": "CGI script accepts and retrieves incoming URLs.", "Link": "https://www.cve.org/CVERecord?id=CVE-2004-2061"}, {"Reference": "CVE-2010-1637", "Description": "Web-based mail program allows internal network scanning using a modified POP3 port number.", "Link": "https://www.cve.org/CVERecord?id=CVE-2010-1637"}, {"Reference": "CVE-2009-0037", "Description": "URL-downloading library automatically follows redirects to file:// and scp:// URLs", "Link": "https://www.cve.org/CVERecord?id=CVE-2009-0037"}]}, "Related_Attack_Patterns": {"Related_Attack_Pattern": {"@CAPEC_ID": "664"}}, "References": {"Reference": [{"@External_Reference_ID": "REF-913"}, {"@External_Reference_ID": "REF-914"}, {"@External_Reference_ID": "REF-915"}, {"@External_Reference_ID": "REF-916"}, {"@External_Reference_ID": "REF-917"}, {"@External_Reference_ID": "REF-918"}, {"@External_Reference_ID": "REF-919"}, {"@External_Reference_ID": "REF-920"}, {"@External_Reference_ID": "REF-1511"}, {"@External_Reference_ID": "REF-1519"}]}, "Mapping_Notes": {"Usage": "Allowed", "Rationale": "This CWE entry is at the Base level of abstraction, which is a preferred level of abstraction for mapping to the root causes of vulnerabilities.", "Comments": "Carefully read both the name and description to ensure that this mapping is an appropriate fit. Do not try to 'force' a mapping to a lower-level Base/Variant simply to comply with this preferred level of abstraction.", "Reasons": {"Reason": {"@Type": "Acceptable-Use"}}}, "Notes": {"Note": {"@Type": "Relationship", "#text": "CWE-918 (SSRF) and CWE-611 (XXE) are closely related, because they both involve web-related technologies and can launch outbound requests to unexpected destinations. However, XXE can be performed client-side, or in other contexts in which the software is not acting directly as a server, so the \"Server\" portion of the SSRF acronym does not necessarily apply."}}, "Content_History": {"Submission": {"Submission_Name": "CWE Content Team", "Submission_Organization": "MITRE", "Submission_Date": "2013-02-17", "Submission_Version": "2.4", "Submission_ReleaseDate": "2013-02-21"}, "Modification": [{"Modification_Name": "CWE Content Team", "Modification_Organization": "MITRE", "Modification_Date": "2015-12-07", "Modification_Version": "2.9", "Modification_ReleaseDate": "2015-12-07", "Modification_Comment": "updated Relationships"}, {"Modification_Name": "CWE Content Team", "Modification_Organization": "MITRE", "Modification_Date": "2017-01-19", "Modification_Version": "2.10", "Modification_ReleaseDate": "2017-01-19", "Modification_Comment": "updated Relationships"}, {"Modification_Name": "CWE Content Team", "Modification_Organization": "MITRE", "Modification_Date": "2017-11-08", "Modification_Version": "3.0", "Modification_ReleaseDate": "2017-11-08", "Modification_Comment": "updated Applicable_Platforms, References"}, {"Modification_Name": "CWE Content Team", "Modification_Organization": "MITRE", "Modification_Date": "2018-03-27", "Modification_Version": "3.1", "Modification_ReleaseDate": "2018-03-27", "Modification_Comment": "updated References"}, {"Modification_Name": "CWE Content Team", "Modification_Organization": "MITRE", "Modification_Date": "2019-06-20", "Modification_Version": "3.3", "Modification_ReleaseDate": "2019-06-20", "Modification_Comment": "updated Relationships"}, {"Modification_Name": "CWE Content Team", "Modification_Organization": "MITRE", "Modification_Date": "2020-02-24", "Modification_Version": "4.0", "Modification_ReleaseDate": "2020-02-24", "Modification_Comment": "updated Applicable_Platforms, Relationships"}, {"Modification_Name": "CWE Content Team", "Modification_Organization": "MITRE", "Modification_Date": "2021-07-20", "Modification_Version": "4.5", "Modification_ReleaseDate": "2021-07-20", "Modification_Comment": "updated References, Related_Attack_Patterns, Relationships"}, {"Modification_Name": "CWE Content Team", "Modification_Organization": "MITRE", "Modification_Date": "2021-10-28", "Modification_Version": "4.6", "Modification_ReleaseDate": "2021-10-28", "Modification_Comment": "updated Relationships"}, {"Modification_Name": "CWE Content Team", "Modification_Organization": "MITRE", "Modification_Date": "2022-06-28", "Modification_Version": "4.8", "Modification_ReleaseDate": "2022-06-28", "Modification_Comment": "updated Observed_Examples, Relationships"}, {"Modification_Name": "CWE Content Team", "Modification_Organization": "MITRE", "Modification_Date": "2022-10-13", "Modification_Version": "4.9", "Modification_ReleaseDate": "2022-10-13", "Modification_Comment": "updated Observed_Examples"}, {"Modification_Name": "CWE Content Team", "Modification_Organization": "MITRE", "Modification_Date": "2023-04-27", "Modification_Version": "4.11", "Modification_ReleaseDate": "2023-04-27", "Modification_Comment": "updated Detection_Factors, References, Relationships"}, {"Modification_Name": "CWE Content Team", "Modification_Organization": "MITRE", "Modification_Date": "2023-06-29", "Modification_Version": "4.12", "Modification_ReleaseDate": "2023-06-29", "Modification_Comment": "updated Mapping_Notes, Relationships"}, {"Modification_Name": "CWE Content Team", "Modification_Organization": "MITRE", "Modification_Date": "2024-11-19", "Modification_Version": "4.16", "Modification_ReleaseDate": "2024-11-19", "Modification_Comment": "updated Alternate_Terms, Common_Consequences, Description, Diagram, Observed_Examples, Relationships"}, {"Modification_Name": "CWE Content Team", "Modification_Organization": "MITRE", "Modification_Date": "2025-09-09", "Modification_Version": "4.18", "Modification_ReleaseDate": "2025-09-09", "Modification_Comment": "updated Applicable_Platforms, Observed_Examples, References"}, {"Modification_Name": "CWE Content Team", "Modification_Organization": "MITRE", "Modification_Date": "2025-12-11", "Modification_Version": "4.19", "Modification_ReleaseDate": "2025-12-11", "Modification_Comment": "updated Applicable_Platforms, Demonstrative_Examples, References, Relationships, Weakness_Ordinalities"}, {"Modification_Name": "CWE Content Team", "Modification_Organization": "MITRE", "Modification_Date": "2026-04-30", "Modification_Version": "4.20", "Modification_ReleaseDate": "2026-04-30", "Modification_Comment": "updated Applicable_Platforms, Observed_Examples, References, Relationships"}], "Contribution": [{"@Type": "Content", "Contribution_Name": "Abhi Balakrishnan", "Contribution_Date": "2024-02-29", "Contribution_Version": "4.16", "Contribution_ReleaseDate": "2024-11-19", "Contribution_Comment": "Provided diagram to improve CWE usability"}, {"@Type": "Content", "Contribution_Name": "Affan Ahmed", "Contribution_Date": "2025-02-08", "Contribution_Version": "4.19", "Contribution_ReleaseDate": "2025-12-11", "Contribution_Comment": "Provided a PHP-based demonstrative example"}]}}
