Closed Medicean closed 5 years ago
有问题的代码:
https://github.com/opensec-cn/kunpeng/blob/master/plugin/go/mongoWeakPass.go#L45-L52
使用 session.Ping() == nil 来判断未授权访问是不正确的,即使 mongodb 加了认证,ping 也会返回正常。
session.Ping() == nil
下面是 log:
root@83dd9fca0b15:/# mongo 192.168.2.106:37017/test MongoDB shell version v4.0.10 connecting to: mongodb://192.168.2.106:37017/test?gssapiServiceName=mongodb Implicit session: session { "id" : UUID("b67c65b0-fd06-4eb8-bc34-3917a0e99bb4") } MongoDB server version: 4.0.10 > db.runCommand({"ping":1}) { "ok" : 1 } > db.runCommand({"serverStatus":1}) { "ok" : 0, "errmsg" : "command serverStatus requires authentication", "code" : 13, "codeName" : "Unauthorized" } >
正确的做法是替换为:
if err == nil && session.Run("serverStatus", nil) == nil { // ... }
直接PR一波 @Medicean
有问题的代码:
https://github.com/opensec-cn/kunpeng/blob/master/plugin/go/mongoWeakPass.go#L45-L52
使用
session.Ping() == nil
来判断未授权访问是不正确的,即使 mongodb 加了认证,ping 也会返回正常。下面是 log:
正确的做法是替换为: