CORS

Cross Origin Resource Sharing misconfiguration exploits

ko-fi

A CORS policy allows developers to selectively relax SOP restrictions and allow controlled cross-origin requests. It's a browser security policy that's declared through the Access-Control-Allow-Origin and Access-Control-Allow-Credentials response headers.

CORS Misconfiguration

Detection

Send a request with a likely trusted origin in the Origin: request header and examine the response for any CORS policy reflections.

Scanner

Nuclei template

https://github.com/coffinxp/priv8-Nuclei/blob/main/cors.yaml

Burp Extension

To use this extension, simply click on the “Activate CORS* checkbox” and browse your target to let the extension do its magic. It will attempt different CORS bypass techniques for all requests passing through your Burp proxy. All you need to do is to check the results.

URL Validation Bypass

Bypassing weak regex pattern validations

Null Access-Control-Allow-Origin

Payload: Use a sandboxed iframe with allow-scripts and srcdoc to execute a script that:

  • Sends a request to https://api.example.com/api/account/billing including the user's cookies (credentials: 'include').

  • Reads the response, encodes it in base64, and sends it to a malicious server at http://attacker-server/collector.

Resources

Interesting Books

Interesting Books

Disclaimer: As an Amazon Associate, I earn from qualifying purchases. This helps support this GitBook project at no extra cost to you.

Support this Gitbook

I hope it helps you as much as it has helped me. If you can support me in any way, I would deeply appreciate it.

ko-fi

buymeacoffee

Last updated