Avoid server-side request forgery | CAST Appmarq

Avoid server-side request forgery

CRITICAL

Rule Definition
The software does not properly neutralize URLs that are used in an request execution, allowing attackers to access internal services or to launch attacks from your web server.

Remediation
Do not accept URLs from users. Use authorized sanitization methods.

Violation Code Sample
// JEE
String taintedURL = request.getParameter("url");
var url = new URL(taintedURL);
HttpURLConnection conn = (HttpURLConnection)url.openConnection(); // Violation

// .NET
String taintedURL = request.Item("url");
var client = new HttpClient();
HttpResponseMessage response = await client.GetAsync(taintedUrl); // Violation
Fixed Code Sample
// JEE
String constURL = "https://www.validUrl.com/";
var url = new URL(constURL);
HttpURLConnection conn = (HttpURLConnection)url.openConnection(); // OK

// .NET
String constURL = "https://www.validUrl.com/";
var client = new HttpClient();
HttpResponseMessage response = await client.GetAsync(constUrl); // OK

Reference
https://cwe.mitre.org/data/definitions/918.html https://owasp.org/Top10/A10_2021-Server-Side_Request_Forgery_%28SSRF%29/ https://cheatsheetseries.owasp.org/cheatsheets/Server_Side_Request_Forgery_Prevention_Cheat_Sheet.html

Related Technologies

Health Factor

  Total Quality Index


Technical Criterion
Secure Coding - Input Validation

About CAST Appmarq

CAST Appmarq is by far the biggest repository of data about real IT systems. It's built on thousands of analyzed applications, made of 35 different technologies, by over 300 business organizations across major verticals. It provides IT Leaders with factual key analytics to let them know if their applications are on track.

Benchmark Statistics

Global Compliance

nan%

Total Violations
0
Total Opportunities
0
Average Violations / App.
nan
The compliance score represents 1 minus the ratio between the number of times a rule has been violated compared to the number of opportunities in a set of applications that the rule could have been violated.

Industry Insights

Select from drop-down

99.96%

Government

99.82%

Software ISV

99.98%