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

2017-10-30 13:06:18 +08:00
 gouchaoer

昨天看到 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,问一下这样安全么?

1848 次点击
所在节点    PHP
1 条回复
gouchaoer
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,不过没人知道。。。

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/401901

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX