Skip to main content
replaced http://stackoverflow.com/ with https://stackoverflow.com/
Source Link

I understand the purpose of the Access-Control-Allow-Credentials headerpurpose of the Access-Control-Allow-Credentials header, but can't see what problem the Access-Control-Allow-Origin header solves.

More precisely, it's easy to see how, if cross-domain AJAX requests with credentials were permitted by default, or if some server were spitting out Access-Control-Allow-Credentials headers on every request, CSRF attacks would be made possible that could not otherwise be performed. The attack method in this scenario would be simple:

  1. Lure an unsuspecting user to my malicious page.
  2. JavaScript on my malicious page sends an AJAX request - with cookies - to some page of a target site.
  3. JavaScript on my malicious page parses the response to the AJAX request, and extracts the CSRF token from it.
  4. JavaScript on my malicious page uses any means - either AJAX or a traditional vessel for a CSRF request, like a form POST - to perform actions using the combination of the user's cookies and their stolen CSRF token.

However, what I can't see is what purpose is served by not allowing uncredentialed cross-domain AJAX requests without an Access-Control-Allow-Origin header. Suppose I were to create a browser that behaved as though every HTTP response it ever received contained

Access-Control-Allow-Origin: *

but still required an appropriate Access-Control-Allow-Credentials header before sending cookies with cross-domain AJAX requests.

Since CSRF tokens have to be tied to individual users (i.e. to individual session cookies), the response to an uncredentialed AJAX request would not expose any CSRF tokens. So what method of attack - if any - would the hypothetical browser described above be exposing its users to?

I understand the purpose of the Access-Control-Allow-Credentials header, but can't see what problem the Access-Control-Allow-Origin header solves.

More precisely, it's easy to see how, if cross-domain AJAX requests with credentials were permitted by default, or if some server were spitting out Access-Control-Allow-Credentials headers on every request, CSRF attacks would be made possible that could not otherwise be performed. The attack method in this scenario would be simple:

  1. Lure an unsuspecting user to my malicious page.
  2. JavaScript on my malicious page sends an AJAX request - with cookies - to some page of a target site.
  3. JavaScript on my malicious page parses the response to the AJAX request, and extracts the CSRF token from it.
  4. JavaScript on my malicious page uses any means - either AJAX or a traditional vessel for a CSRF request, like a form POST - to perform actions using the combination of the user's cookies and their stolen CSRF token.

However, what I can't see is what purpose is served by not allowing uncredentialed cross-domain AJAX requests without an Access-Control-Allow-Origin header. Suppose I were to create a browser that behaved as though every HTTP response it ever received contained

Access-Control-Allow-Origin: *

but still required an appropriate Access-Control-Allow-Credentials header before sending cookies with cross-domain AJAX requests.

Since CSRF tokens have to be tied to individual users (i.e. to individual session cookies), the response to an uncredentialed AJAX request would not expose any CSRF tokens. So what method of attack - if any - would the hypothetical browser described above be exposing its users to?

I understand the purpose of the Access-Control-Allow-Credentials header, but can't see what problem the Access-Control-Allow-Origin header solves.

More precisely, it's easy to see how, if cross-domain AJAX requests with credentials were permitted by default, or if some server were spitting out Access-Control-Allow-Credentials headers on every request, CSRF attacks would be made possible that could not otherwise be performed. The attack method in this scenario would be simple:

  1. Lure an unsuspecting user to my malicious page.
  2. JavaScript on my malicious page sends an AJAX request - with cookies - to some page of a target site.
  3. JavaScript on my malicious page parses the response to the AJAX request, and extracts the CSRF token from it.
  4. JavaScript on my malicious page uses any means - either AJAX or a traditional vessel for a CSRF request, like a form POST - to perform actions using the combination of the user's cookies and their stolen CSRF token.

However, what I can't see is what purpose is served by not allowing uncredentialed cross-domain AJAX requests without an Access-Control-Allow-Origin header. Suppose I were to create a browser that behaved as though every HTTP response it ever received contained

Access-Control-Allow-Origin: *

but still required an appropriate Access-Control-Allow-Credentials header before sending cookies with cross-domain AJAX requests.

Since CSRF tokens have to be tied to individual users (i.e. to individual session cookies), the response to an uncredentialed AJAX request would not expose any CSRF tokens. So what method of attack - if any - would the hypothetical browser described above be exposing its users to?

Link to the purpose of the header. Fix "JavaScript" capitalization.
Source Link

I understand the purpose of the Access-Control-Allow-Credentials headerpurpose of the Access-Control-Allow-Credentials header, but can't see what problem the Access-Control-Allow-Origin header solves.

More precisely, it's easy to see how, if cross-domain AJAX requests with credentials were permitted by default, or if some server were spitting out Access-Control-Allow-Credentials headers on every request, CSRF attacks would be made possible that could not otherwise be performed. The attack method in this scenario would be simple:

  1. Lure an unsuspecting user to my malicious page.
  2. JavascriptJavaScript on my malicious page sends an AJAX request - with cookies - to some page of a target site.
  3. JavascriptJavaScript on my malicious page parses the response to the AJAX request, and extracts the CSRF token from it.
  4. JavascriptJavaScript on my malicious page uses any means - either AJAX or a traditional vessel for a CSRF request, like a form POST - to perform actions using the combination of the user's cookies and their stolen CSRF token.

However, what I can't see is what purpose is served by not allowing uncredentialed cross-domain AJAX requests without an Access-Control-Allow-Origin header. Suppose I were to create a browser that behaved as though every HTTP response it ever received contained

Access-Control-Allow-Origin: *

but still required an appropriate Access-Control-Allow-Credentials header before sending cookies with cross-domain AJAX requests.

Since CSRF tokens have to be tied to individual users (i.e. to individual session cookies), the response to an uncredentialed AJAX request would not expose any CSRF tokens. So what method of attack - if any - would the hypothetical browser described above be exposing its users to?

I understand the purpose of the Access-Control-Allow-Credentials header, but can't see what problem the Access-Control-Allow-Origin header solves.

More precisely, it's easy to see how, if cross-domain AJAX requests with credentials were permitted by default, or if some server were spitting out Access-Control-Allow-Credentials headers on every request, CSRF attacks would be made possible that could not otherwise be performed. The attack method in this scenario would be simple:

  1. Lure an unsuspecting user to my malicious page.
  2. Javascript on my malicious page sends an AJAX request - with cookies - to some page of a target site.
  3. Javascript on my malicious page parses the response to the AJAX request, and extracts the CSRF token from it.
  4. Javascript on my malicious page uses any means - either AJAX or a traditional vessel for a CSRF request, like a form POST - to perform actions using the combination of the user's cookies and their stolen CSRF token.

However, what I can't see is what purpose is served by not allowing uncredentialed cross-domain AJAX requests without an Access-Control-Allow-Origin header. Suppose I were to create a browser that behaved as though every HTTP response it ever received contained

Access-Control-Allow-Origin: *

but still required an appropriate Access-Control-Allow-Credentials header before sending cookies with cross-domain AJAX requests.

Since CSRF tokens have to be tied to individual users (i.e. to individual session cookies), the response to an uncredentialed AJAX request would not expose any CSRF tokens. So what method of attack - if any - would the hypothetical browser described above be exposing its users to?

I understand the purpose of the Access-Control-Allow-Credentials header, but can't see what problem the Access-Control-Allow-Origin header solves.

More precisely, it's easy to see how, if cross-domain AJAX requests with credentials were permitted by default, or if some server were spitting out Access-Control-Allow-Credentials headers on every request, CSRF attacks would be made possible that could not otherwise be performed. The attack method in this scenario would be simple:

  1. Lure an unsuspecting user to my malicious page.
  2. JavaScript on my malicious page sends an AJAX request - with cookies - to some page of a target site.
  3. JavaScript on my malicious page parses the response to the AJAX request, and extracts the CSRF token from it.
  4. JavaScript on my malicious page uses any means - either AJAX or a traditional vessel for a CSRF request, like a form POST - to perform actions using the combination of the user's cookies and their stolen CSRF token.

However, what I can't see is what purpose is served by not allowing uncredentialed cross-domain AJAX requests without an Access-Control-Allow-Origin header. Suppose I were to create a browser that behaved as though every HTTP response it ever received contained

Access-Control-Allow-Origin: *

but still required an appropriate Access-Control-Allow-Credentials header before sending cookies with cross-domain AJAX requests.

Since CSRF tokens have to be tied to individual users (i.e. to individual session cookies), the response to an uncredentialed AJAX request would not expose any CSRF tokens. So what method of attack - if any - would the hypothetical browser described above be exposing its users to?

edited tags
Link
Anders
  • 65.7k
  • 24
  • 185
  • 222
Tweeted twitter.com/#!/StackSecurity/status/388367710260051968
deleted 131 characters in body
Source Link
Mark Amery
  • 1.8k
  • 2
  • 14
  • 22
Loading
Source Link
Mark Amery
  • 1.8k
  • 2
  • 14
  • 22
Loading