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

static file register arbitrary file read #633

yeahx opened this Issue Apr 13, 2017 · 2 comments


None yet
3 participants

yeahx commented Apr 13, 2017

File sanic/sanic/ line 46
we can see here is security check

43    async def _handler(request, file_uri=None):
44        # Using this to determine if the URL is trying to break out of the path
45        # served.  os.path.realpath seems to be very slow
46        if file_uri and '../' in file_uri:
47            raise InvalidUsage("Invalid URL")

but at the line 56 in this file,the unquote function decoded file_path
file_path = unquote(file_path)
we only need to "/" url coding can bypass the previous security check
like this:

example of vulnerabilities:

#!/usr/bin/env python
#-*- coding:utf-8 -*-
from sanic import Sanic
from sanic.response import text

app = Sanic()

app.static('/static', '/var/tmp')

async def test(request):
    return text('Hello!')

if __name__ == '__main__':'', port=8787, debug=True)

This comment has been minimized.

Show comment
Hide comment

go2sh commented Apr 14, 2017



This comment has been minimized.

Show comment
Hide comment

seemethere Apr 14, 2017


Closed with #635


seemethere commented Apr 14, 2017

Closed with #635

@seemethere seemethere closed this Apr 14, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment