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 "Origin" isolation check #135

Open
lidel opened this issue Feb 12, 2021 · 2 comments
Open

Fix "Origin" isolation check #135

lidel opened this issue Feb 12, 2021 · 2 comments
Assignees
Labels
effort/hours Estimated to take one or several hours exp/intermediate Prior experience is likely helpful good first issue Good issue for new contributors help wanted Seeking public contribution on this issue kind/bug A bug in existing code (including security flaws) P1 High: Likely tackled by core team if no one steps up status/ready Ready to be worked

Comments

@lidel
Copy link
Member

lidel commented Feb 12, 2021

It seems that gateways get βœ… for Origin isolation and πŸ’š EVEN when path gateway does not redirect to a subdomain.

This broken setup is not possible with go-ipfs, but someone could do this type of menace with a custom Nginx config, defeating the origin isolation provided by subdomains.

Figuring out if /ipfs/{cid} returns HTTP 200 or 301 will be tricky because JS fetch follows redirects.

Workarounds to investigate (did not check, just an idea):

  • load HTML+JS into a hidden iframe, and read window.location.origin from iframe via postMessage and fail if origin is not https://{cid}.ipfs.{gateway}
    • does not work due to CORS
  • ? ? ? (comment with your ideas)
@lidel lidel added kind/bug A bug in existing code (including security flaws) help wanted Seeking public contribution on this issue good first issue Good issue for new contributors exp/intermediate Prior experience is likely helpful P1 High: Likely tackled by core team if no one steps up effort/hours Estimated to take one or several hours status/ready Ready to be worked labels Feb 12, 2021
@SoftCreatR
Copy link
Contributor

Just check the response URL:

let hash = `bafybeifx7yeb55armcsxwwitkymga5xf53dxiarykms3ygqic223w5sk3m`
let now = Date.now()
let testUrl = `https://ipfs.1-2.dev/ipfs/${hash}?now=${now}#x-ipfs-companion-no-redirect`

fetch(testUrl).then(res => {
   if (response.url.startsWith(`https://${hash}`)) console.log(`Supports origin isolation`)
   else console.log(`Does not support origin isolation`)
});

@SgtPooki SgtPooki self-assigned this Feb 25, 2022
@SgtPooki SgtPooki assigned whizzzkid and unassigned SgtPooki Nov 22, 2022
@SgtPooki
Copy link
Member

@whizzzkid to investigate if this is solved with his recent changes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
effort/hours Estimated to take one or several hours exp/intermediate Prior experience is likely helpful good first issue Good issue for new contributors help wanted Seeking public contribution on this issue kind/bug A bug in existing code (including security flaws) P1 High: Likely tackled by core team if no one steps up status/ready Ready to be worked
Projects
No open projects
Status: Prioritized / Ready for Dev
Development

No branches or pull requests

4 participants