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

fix(subdomain-gw): curl on localhost (Option B: User-Agent sniff) #6984

Closed

Conversation

lidel
Copy link
Member

@lidel lidel commented Mar 11, 2020

This is a PR against feat/gateway-subdomains branch to resolve concerns from #6975
See Option A for alternative fix.

TL;DR

When request to localhost/ipfs/* is processed:

  • add Clear-Site-Data header
  • see if User-Agent is matching known cli tool ^(curl|wget)/i
    • on positive match, return regular HTTP 200 response instead of subdomain redirect

Context: #6975

When request is sent to http://localhost:8080/ipfs/$cid we check
User-Agent and disable subdomain redirect if it is a known cli tool that
does not follow redirects by default.

We also set Clear-Site-Data header on 'localhost' responses to ensure Origin
sandbox can't be abused.

License: MIT
Signed-off-by: Marcin Rataj <lidel@lidel.org>
@lidel lidel requested a review from Stebalien March 11, 2020 18:27
@lidel lidel mentioned this pull request Mar 11, 2020
Closed
@lidel lidel changed the title fix(gateway): curl without redirect on localhost (User-Agent sniff) fix(subdomain-gw): curl on localhost (Option B: User-Agent sniff) Mar 11, 2020
@lidel lidel linked an issue Mar 12, 2020 that may be closed by this pull request
@Stebalien
Copy link
Member

Closing because we've selected option A (#6984).

Please do not delete this branch.

@Stebalien Stebalien closed this Mar 14, 2020
@hacdias hacdias deleted the fix/curl-on-localhost-option-b branch May 9, 2023 10:57
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.

Update subdomain redirection logic to only engage on browsers
2 participants