API7—Server Side Request Forgery
>Control Description
>Prevention & Mitigation Strategies
- 1.Isolate the resource fetching mechanism in your network: usually these features are aimed at retrieving remote resources and not internal ones.
- 2.Whenever possible, use allow lists for remote origins that users are expected to download resources from (e.g. Google Drive, Gravatar).
- 3.Use allow lists for URL schemes and ports.
- 4.Use allow lists for accepted media types for a given functionality.
- 5.Disable HTTP redirections.
- 6.Use a well-tested and maintained URL parser to avoid issues caused by URL parsing inconsistencies.
- 7.Validate and sanitize all client-supplied input data.
- 8.Do not send raw responses to clients.
>Attack Scenarios
An attacker exploits a social network that allows users to upload profile pictures by providing a URL. The attacker provides a URL targeting an internal service (e.g. http://localhost:8080). By observing the response time differences, the attacker can determine which internal ports are open, effectively performing an internal port scan from the server.
A security product generates events by receiving inputs from networks. For each event, several enrichments are performed by fetching information from internal services. An attacker sends a crafted event to the product with a payload URL pointing to the cloud instance metadata service (http://169.254.169.254/latest/meta-data/iam/security-credentials/). The API blindly fetches the URL and returns the sensitive cloud credentials to the attacker.
>Related CWEs
>References
Ask AI
Configure your API key to use AI features.