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

bug: make CORS default less restrictive. #348

Merged
merged 3 commits into from
Apr 27, 2023
Merged

bug: make CORS default less restrictive. #348

merged 3 commits into from
Apr 27, 2023

Conversation

jrconlin
Copy link
Member

The default actix-cors is even more restrictive than it was before. We need to loosen it up again, so this time, be more explicit about what we're allowing.

(I wonder if we should just use .permissive() since we handle most of the actual security internally?)

Fixes: Sync-3608

@jrconlin jrconlin requested review from pjenvey and a team and removed request for a team February 17, 2023 00:29
actix_web::http::Method::GET,
actix_web::http::Method::POST,
actix_web::http::Method::PUT,
])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you want to expose the Location response header with .expose_headers(), also?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not seeing a Location header, but yeah, there are a few X-Forward headers we should probably not disclose.

sigh

Really didn't want to list out all the headers either.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm... Looking at allow_any_headers, the call will echo the list of headers requested in Access-Control-Request-Headers into Access-Control-Allow-Headers, so it's not returning all the headers that are sent, only the ones that are requested to be sent, and even then, it's only returning the names, not the values.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ohh, gotcha—I thought you might be returning a Location header in 201s for POST requests, sorry! Thanks for double-checking, @jrconlin! 😊

Copy link
Member

@pjenvey pjenvey Apr 18, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We do send a Location header (routers send them via RouterResponse::success) as well as TTL. The python also sent www-authenticate alongside errors but the rust doesn't.

It's not clear to me that these need exposing, but I guess the Test Page might want access to them in theory which would require exposing them (or expose_any_header), I think?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The problem is that the browser is very strict about what sort of information gets disclosed to the DOM level Javascript. An unexpected or disallowed value will prevent the DOM javascript from getting the response. This results in the Test Page breaking.

So, in this case, the test page doesn't really care or want the response (aside from getting the status) but is blocked from even sending the inbound request due to the strict header limitations.

@jrconlin jrconlin merged commit d421e8d into master Apr 27, 2023
@jrconlin jrconlin deleted the bug/3608_cors branch April 27, 2023 00:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants