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

gateway: feature request: ability to disable directory listings #9645

Open
3 tasks done
delgyd opened this issue Feb 10, 2023 · 6 comments
Open
3 tasks done

gateway: feature request: ability to disable directory listings #9645

delgyd opened this issue Feb 10, 2023 · 6 comments
Assignees
Labels
effort/hours Estimated to take one or several hours exp/novice Someone with a little familiarity can pick up help wanted Seeking public contribution on this issue kind/feature A new feature P3 Low: Not priority right now topic/gateway Topic gateway

Comments

@delgyd
Copy link

delgyd commented Feb 10, 2023

tldr; I would like one more option to support blocking listing directory contents

Checklist

  • My issue is specific & actionable.
  • I am not suggesting a protocol enhancement.
  • I have searched on the issue tracker for my issue.

Description

https://ipfs.io/ipfs/Qmd148AbtEZKR4KCUZiNGDURTxCwSa13adLKkjdmyWPMt9 【let him redirect】
https://ipfs.io/ipfs/Qmd148AbtEZKR4KCUZiNGDURTxCwSa13adLKkjdmyWPMt9/VCG211be3c9c31.jpg 【OK】
https://ipfs.io/ipfs/QmcBpxUZMbD5iwNA8w2dj8QBWvTdAXwNDHbZ74ffqGtNHh  【OK】

Because certain scenarios have relatively strict security requirements, directory traversal caused by direct get access is considered a security issue. Therefore, it is recommended to directly redirect to the specified page when accessing indirect data resources, instead of directly using the form of directory traversal, or Add a parameter directly in the configuration file to achieve.

@delgyd delgyd added the kind/feature A new feature label Feb 10, 2023
@lidel lidel self-assigned this Feb 10, 2023
@lidel
Copy link
Member

lidel commented Feb 10, 2023

Mind elaborating what is the exact problem you see, how threat model looks like, and what is your proposed solution?

My understanding is that you don't like the fact someone can list directory contents, which is not a bug.
All data stored on IPFS is in the clear, directory structures can be trivially inspected, all you need it CID:
https://explore.ipld.io/#/explore/Qmd148AbtEZKR4KCUZiNGDURTxCwSa13adLKkjdmyWPMt9

If you remove CIDs, then you lose the ability to do content-addressing, and end up with regular HTTP without being able to do integrity checks (which is fine, but that also suggests you don't need what IPFS provides).

@lidel lidel added the need/author-input Needs input from the original author label Feb 10, 2023
@delgyd
Copy link
Author

delgyd commented Feb 11, 2023

Yes. This is not a bug, but I would like one more option to support blocking listing directory contents

kubo/core/corehttp/gateway_handler.go

if strings.HasSuffix(resolvedPath.String(),"/") == true {
http.Redirect(w,r,"https://ipfs.io",302)
return
} else {
trace.SpanFromContext(r.Context()).SetAttributes(attribute.String("ResolvedPath", resolvedPath.String()))
}

@Jorropo
Copy link
Contributor

Jorropo commented Feb 11, 2023

@delgyd the directory content is stored publicly inside the block, if you block it on your gateway that does not prevent someone from just using an other gateway or running their own IPFS node.

If https://example.org/ipfs/Qmd148AbtEZKR4KCUZiNGDURTxCwSa13adLKkjdmyWPMt9 blocks directory listing, what does this achieve if I can just use https://jorropo.net/ipfs/Qmd148AbtEZKR4KCUZiNGDURTxCwSa13adLKkjdmyWPMt9 ?

@delgyd
Copy link
Author

delgyd commented Feb 13, 2023

@lidel lidel removed the need/author-input Needs input from the original author label Feb 20, 2023
@lidel lidel changed the title Non-critical security issues caused by directory traversal caused by non-resource path access gateway: feature request: ability to disable directory listings Feb 20, 2023
@ipfs ipfs deleted a comment from github-actions bot Feb 20, 2023
@lidel
Copy link
Member

lidel commented Feb 20, 2023

I would like one more option to support blocking listing directory contents

Ack. It is not related to security in any way, so low priority for the team.

But it makes UX sense in context of DNSLink websites, where one may want to keep all HTML returned under own brand, and generated dir listings break that consistency.

If someone wants to work on this, next steps:

@lidel lidel added help wanted Seeking public contribution on this issue exp/novice Someone with a little familiarity can pick up P3 Low: Not priority right now good first issue Good issue for new contributors effort/hours Estimated to take one or several hours topic/gateway Topic gateway and removed kind/stale good first issue Good issue for new contributors labels Feb 20, 2023
@arthurgavazza
Copy link
Contributor

Anyone working on this? I'm looking for a good first issue and would appreciate taking this one. I just need some help to understand the tasks.

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/novice Someone with a little familiarity can pick up help wanted Seeking public contribution on this issue kind/feature A new feature P3 Low: Not priority right now topic/gateway Topic gateway
Projects
None yet
Development

No branches or pull requests

4 participants