V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
gouchaoer
V2EX  ›  PHP

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

  •  
  •   gouchaoer · 2017-10-30 13:06:18 +08:00 · 1835 次点击
    这是一个创建于 2362 天前的主题,其中的信息可能已经有所发展或是发生改变。

    昨天看到 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
       2017-10-30 14:05:07 +08:00
    https://stackoverflow.com/questions/11597025/is-this-use-of-str-replace-sufficient-to-prevent-sql-injection-attacks

    这个问题的最后一个 comment 也有人提出来这种方法是否能防止 injection,不过没人知道。。。
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   3247 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 26ms · UTC 14:08 · PVG 22:08 · LAX 07:08 · JFK 10:08
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.