V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
gouchaoer
V2EX  ›  PHP

typecho 关于把'替换成''来对 sql 参数消毒以及 real_escape_string 的安全性问题

  •  
  •   gouchaoer · Oct 30, 2017 · 2357 views
    This topic created in 3107 days ago, the information mentioned may be changed or developed.

    昨天看到 typecho 爆漏洞,于是今天上班就看了一下 typecho 的源码: 1、发现 mysqli 的适配器 quote 只是简单的替换了单引号 https://github.com/typecho/typecho/blob/93bcd46d5594b2e0066896105834fb4d6a45cd4c/var/Typecho/Db/Adapter/Mysqli.php#L117

    2、https://github.com/typecho/typecho/blob/93bcd46d5594b2e0066896105834fb4d6a45cd4c/var/Typecho/Db/Adapter/Mysqli.php#L131 这里用了 real_escape_string,而官方的文档 http://php.net/manual/en/mysqli.real-escape-string.php 说需要先调用一下 mysqli_set_charset() 才安全

    我也不是搞渗透的,一时半会儿拿不出 poc,问一下这样安全么?

    gouchaoer
        1
    gouchaoer  
    OP
       Oct 30, 2017
    https://stackoverflow.com/questions/11597025/is-this-use-of-str-replace-sufficient-to-prevent-sql-injection-attacks

    这个问题的最后一个 comment 也有人提出来这种方法是否能防止 injection,不过没人知道。。。
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   2507 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 28ms · UTC 08:40 · PVG 16:40 · LAX 01:40 · JFK 04:40
    ♥ Do have faith in what you're doing.