kubo/core
Lars Gierth 09937f84b6 gateway: enforce allowlist for path prefixes
The gateway accepts an X-Ipfs-Path-Prefix header,
and assumes that it is mounted in a reverse proxy
like nginx, at this path. Links in directory listings,
as well as trailing-slash redirects need to be rewritten
with that prefix in mind.

We don't want a potential attacker to be able to
pass in arbitrary path prefixes, which would end up
in redirects and directory listings, which is why
every prefix has to be explicitly allowed in the config.

Previously, we'd accept *any* X-Ipfs-Path-Prefix header.

Example:

We mount blog.ipfs.io (a dnslink page) at ipfs.io/blog.

nginx_ipfs.conf:

    location /blog/ {
        rewrite "^/blog(/.*)$" $1 break;
        proxy_set_header Host blog.ipfs.io;
        proxy_set_header X-Ipfs-Gateway-Prefix /blog;
        proxy_pass http://127.0.0.1:8080;
    }

.ipfs/config:

    "Gateway": {
        "PathPrefixes": ["/blog"],
        // ...
    },

dnslink:

    > dig TXT _dnslink.blog.ipfs.io
    dnslink=/ipfs/QmWcBjXPAEdhXDATV4ghUpkAonNBbiyFx1VmmHcQe9HEGd

License: MIT
Signed-off-by: Lars Gierth <larsg@systemli.org>
2016-04-04 16:31:57 -04:00
..
commands use the builtin option parser to set the default for ipfs pin ls --type 2016-03-30 20:00:40 -04:00
corehttp gateway: enforce allowlist for path prefixes 2016-04-04 16:31:57 -04:00
corenet update utp and cleanup more godeps along the way 2016-03-29 19:18:14 -07:00
corerepo repo-stat 2016-03-04 23:45:03 +00:00
corerouting update utp and cleanup more godeps along the way 2016-03-29 19:18:14 -07:00
coreunix clean deprecated Key.Pretty() 2016-03-25 12:05:45 +01:00
mock update utp and cleanup more godeps along the way 2016-03-29 19:18:14 -07:00
.gitignore ignore testdb 2014-07-05 15:04:04 -07:00
bootstrap_test.go update utp and cleanup more godeps along the way 2016-03-29 19:18:14 -07:00
bootstrap.go update utp and cleanup more godeps along the way 2016-03-29 19:18:14 -07:00
builder.go update utp and cleanup more godeps along the way 2016-03-29 19:18:14 -07:00
core_test.go Use gx vendored go-ipfs-utils where possible 2016-02-12 17:21:40 -08:00
core.go update utp and cleanup more godeps along the way 2016-03-29 19:18:14 -07:00
pathresolver_test.go Add test to detect invalid path 2015-07-04 02:50:15 +07:00
pathresolver.go dns: update dns command docs 2016-03-03 17:06:10 +01:00