Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CorsUtils#isCorsRequest should detect same origin requests with an Origin header #22496

Closed
ArayChou opened this issue Mar 1, 2019 · 1 comment
Assignees
Labels
type: enhancement A general enhancement
Milestone

Comments

@ArayChou
Copy link

ArayChou commented Mar 1, 2019

Affecting version: spring-web:5.1.3.RELEASE

Hello, org.springframework.web.cors.CorsUtils#isCorsRequest only check whether the request header "Origin" is null.

public static boolean isCorsRequest(HttpServletRequest request) {
	return (request.getHeader(HttpHeaders.ORIGIN) != null);
}

But Chrome/Edge always send the "Origin" header in AJAX request even when it is not CORS request ( the target URL is the same domain ).

It is better to check that whether the "Origin" header is the same as the request URL in addition.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Mar 1, 2019
@sdeleuze sdeleuze changed the title Flaw in org.springframework.web.cors.CorsUtils#isCorsRequest CorsUtils#isCorsRequest should detect same origin requests with an Origin header Mar 4, 2019
@sdeleuze
Copy link
Contributor

sdeleuze commented Mar 4, 2019

This check is currently done as a second step at WebUtils#isSameOrigin level invoked by DefaultCorsProcessor#processRequest. That said, per RFC 6454 section 7.3, I tend to agree that this check should be invoked by CorsUtils#isCorsRequest for more correct semantics but I would like to avoid any performance regression, and I would like to see if we have possibilities to avoid duplicated CorsUtils#isCorsRequest, so I plan this one for 5.2 along to #22273 unless other team members think otherwise.

@sdeleuze sdeleuze added type: enhancement A general enhancement and removed status: waiting-for-triage An issue we've not yet triaged or decided on labels Mar 4, 2019
@sdeleuze sdeleuze added this to the 5.2 M1 milestone Mar 4, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

3 participants