Skip to content

Disable CORS credentials by default [SPR-16130] #20678

@spring-projects-issues

Description

@spring-projects-issues

Nanne Baars opened SPR-16130 and commented

Using a simple Spring Boot application and defining a REST endpoint with the following annotation:

@GetMapping
@CrossOrigin(value = "*")
fun allBlogs(): Iterable<BlogEntry> = blogRepository.findAll()

Using the following curl request: (for testing purposes only, to easily show the response, you can do this with a XHR script running on foo.com as well)

curl -i -XGET -H "Origin: http://foo.com" http://localhost:8083/blogs/

which replies with:

HTTP/1.1 200 
Access-Control-Allow-Origin: http://foo.com
Access-Control-Allow-Credentials: true
Content-Type: application/json;charset=UTF-8

The origin is reflected and here is the strange part the "Access-Control-Allow-Credentials" header is set to true. Meaning any site can make a XHR request with credentials, see attached link to see why this can be an issue.

This probably is not the best default setting (using '*' with Access-Control-Allow-Credentials: true would have been better because the browser simply does not send credentials along in this case). In my opinion the default settings with * should set the Access-Control-Allow-Origin response header to "*" and leave out the Access-Control-Allow-Credentials header.

For more information, see: http://blog.portswigger.net/2016/10/exploiting-cors-misconfigurations-for.html


Issue Links:

Referenced from: commits 652e5c5

Metadata

Metadata

Assignees

Labels

in: webIssues in web modules (web, webmvc, webflux, websocket)type: bugA general bug

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions