News for hackers. Stuff that matters.
Re:Finding an arbitrary file upload vulnerability in a files... by jwilk on Sunday May 14, 2017 @07:11AM (#14335122)
So I was curious what translate_path does:

    def translate_path(self, path):
        """Translate a /-separated PATH to the local filename syntax.

        Components that mean special things to the local file system
        (e.g. drive or directory names) are ignored.  (XXX They should
        probably be diagnosed.)

        """
        # abandon query parameters
        path = path.split('?',1)[0]
        path = path.split('#',1)[0]
        path = posixpath.normpath(urllib.unquote(path))
        words = path.split('/')
        words = filter(None, words)
        path = os.getcwd()
        for word in words:
            drive, word = os.path.splitdrive(word)
            head, word = os.path.split(word)
            if word in (os.curdir, os.pardir): continue
            path = os.path.join(path, word)
        return path
That... that doesn't make any sense.
Re:Finding an arbitrary file upload vulnerability in a files... by jwilk on Sunday May 14, 2017 @07:19AM (#14335141)
Oh, and thanks to urllib.unquote, I can disguise slashes as "%2f", so the tightened regexp doesn't help.
Re:Finding an arbitrary file upload vulnerability in a files... by jwilk on Sunday May 14, 2017 @10:24AM (#14335751)
Never mind me, I misread how this function is used.

Apparently this code was copied from stdlib, including a different directory traversal bug on Windows:

https://bugs.python.org/issue26657