推荐学习书目
› Learn Python the Hard Way
Python Sites
› PyPI - Python Package Index
› http://diveintopython.org/toc/index.html
› Pocoo
值得关注的项目
› PyPy
› Celery
› Jinja2
› Read the Docs
› gevent
› pyenv
› virtualenv
› Stackless Python
› Beautiful Soup
› 结巴中文分词
› Green Unicorn
› Sentry
› Shovel
› Pyflakes
› pytest
Python 编程
› pep8 Checker
Styles
› PEP 8
› Google Python Style Guide
› Code Style from The Hitchhiker's Guide
RIcter
V2EX  ›  Python

Tornado 框架某缺陷可能造成文件读取漏洞

  •  
  •   RIcter ·
    RicterZ · Mar 2, 2015 via iPad · 6620 views
    This topic created in 4266 days ago, the information mentioned may be changed or developed.
    19 replies  •  2015-03-02 12:26:39 +08:00
    kslr
    kslr
    Mar 2, 2015 via Android
    1
    可能,期待公布过程
    mywaiting
    mywaiting
    Mar 2, 2015
    2
    StaticFileHandler的问题?
    RIcter
    RIcter
    OP
    Mar 2, 2015 via iPad❤️1
    3
    @mywaiting 我估计也是,但是不敢确定,稍微看一下代码好了
    Livid
    Livid
    MOD
    PRO
    Mar 2, 2015
    4
    把可能需要用到 StaticFileHandler 的地方都换到 Nginx 里配置吧。
    evlos
    evlos
    Mar 2, 2015
    5
    Wut?! 赶紧出补丁啊啊啊!
    RIcter
    RIcter
    OP
    Mar 2, 2015❤️2
    6
    @Livid
    @evlos
    @mywaiting
    @kslr
    不仅仅是 StaticFileHandler 的样子, settings 里的 static_file 也一样。
    **大体**测试出来在 **Windows** 下可以读取文件,而且不是任意文件。
    比如:

    settings = {
    "static_path": os.path.join(os.path.dirname(__file__), "xxx")
    }

    curl http://10.211.55.5:8888/static/static\\\\..\\..\\xxx.txt

    文件名要和指定的目录一样,略鸡肋。不过我不确定 wooyun 上的漏洞和我是否一样 :(
    latyas
    latyas
    Mar 2, 2015
    7
    ?还有人用web framework的static配置来路由静态文件?
    mywaiting
    mywaiting
    Mar 2, 2015❤️1
    8
    @RIcter 这速度,我略表汗颜......

    settings里面的static_file默认也是调用StaticFileHandler来实现的。

    @Livid 翻了一下V2EX的HTML源代码,有必要提醒一下,这样的URL:

    https://www.v2ex.com/static/js/v2ex.js?v=8a80fb0cbc5ebd7a71574b13793cef3b

    就已经是调用了StaticFileHandler来实现在链接后面加上v=version这样的版本号的。
    Livid
    Livid
    MOD
    PRO
    Mar 2, 2015
    9
    @mywaiting StaticFileHandler 确实生成了后面的版本号,但是网站在提供服务时,在 Nginx 配置里加入这样一段:

    location ^~ /static/ {

    root /example/site;
    expires max;

    }
    typcn
    typcn
    Mar 2, 2015❤️2
    10
    @Livid 另外提醒一下,你相信了来自客户端的数据,
    X-Forwarded-For:127.0.0.1 就可以无视你的访问频率限制了
    bfti
    bfti
    Mar 2, 2015
    11
    如果不看乌云,服务器就很可能被入侵么?
    ehs2013
    ehs2013
    Mar 2, 2015
    12
    没在生产中用过 StaticFileHandler。
    futursolo
    futursolo
    Mar 2, 2015
    13
    用GridFS的就偶一个?
    letitbesqzr
    letitbesqzr
    Mar 2, 2015
    14
    @typcn 但如果不去读X-Forwarded-For头,有些大学或者大型网络里只有一个出口ip,那不会影响正常用户访问?
    geew
    geew
    Mar 2, 2015
    15
    tornado 的 StaticFileHandler一般不用在生产环境中的吧 官方也不推荐...
    raincious
    raincious
    Mar 2, 2015 via Android❤️1
    16
    @letitbesqzr

    X-Forwarded-For其实并非不安全,没做校验检查才会造成不安全。 X-Forwarded-For这东西需要搭配TrustedProxies表来用才是安全的,但是部署人员就多了个职责。多框架只是将它解析出来了而已,数据是否伪造其实是未知的。
    est
    est
    Mar 2, 2015
    17
    @raincious 赞头像。。。

    其实办法很多啦。改个X-MY-REAL-Forwarded_For 欢迎来猜我用的什么头
    est
    est
    Mar 2, 2015
    18
    如果真是StaticFileHandler,而且是windows only,那么估计没人理会这漏洞。。。。。。。。生产环境中这个招的也只能说活该呃。。。。。。
    feelapi
    feelapi
    Mar 2, 2015
    19
    @typcn 可以完全使用nginx处理静态文件么?那不是要求网站的url设计要小心,静态的页面也要放在特别的位置,比如API Docs这种只读的页面。
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   4245 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 49ms · UTC 09:45 · PVG 17:45 · LAX 01:45 · JFK 04:45
    ♥ Do have faith in what you're doing.