AI Security AI安全 5h ago Updated 2h ago 更新于 2小时前 49

Researcher Publishes GitLab RCE PoC Letting Authenticated Users Run Commands as Git 研究人员发布GitLab远程代码执行PoC,允许认证用户以Git身份运行命令

Security researchers at depthfirst published a working Proof of Concept (PoC) for a Remote Code Execution (RCE) vulnerability in GitLab, affecting self-managed instances that have not applied recent patches. The exploit allows any authenticated user with push access to execute commands as the `git` user by chaining two memory corruption bugs in the Oj Ruby JSON parser gem. GitLab patched the underlying Oj dependency in June but failed to classify it as a security fix, leading to many administrat 安全研究员 depthfirst 发布了 GitLab 远程代码执行(RCE)的完整利用代码,该漏洞影响所有未更新版本的自托管实例。 攻击链利用 Oj JSON 解析器中的两个内存损坏漏洞,通过伪造 Jupyter Notebook 触发堆指针泄露和栈溢出,最终在无需管理员权限的情况下以 `git` 用户身份执行命令。 GitLab 将修复程序列为普通 Bug 而非安全补丁,导致缺乏 CVE 编号和 CVSS 评分,使得许多运维人员未能及时识别其紧急性。 受影响版本包括 GitLab CE/EE 15.2.0 至 18.10.7、18.11.0 至 18.11.4 以及 19.0.0 至 19

75
Hot 热度
65
Quality 质量
70
Impact 影响力

Analysis 深度分析

TL;DR

  • Security researchers at depthfirst published a working Proof of Concept (PoC) for a Remote Code Execution (RCE) vulnerability in GitLab, affecting self-managed instances that have not applied recent patches.
  • The exploit allows any authenticated user with push access to execute commands as the git user by chaining two memory corruption bugs in the Oj Ruby JSON parser gem.
  • GitLab patched the underlying Oj dependency in June but failed to classify it as a security fix, leading to many administrators missing the urgency of the update.
  • The attack vector involves leaking heap pointers via crafted Jupyter notebook diffs to locate libraries in memory, followed by triggering the payload without requiring administrator rights or CI/runner access.

Why It Matters

This incident highlights critical risks in supply chain dependencies and patch management processes within DevOps platforms. It demonstrates how seemingly minor library updates can mask severe security vulnerabilities if not properly classified and communicated, potentially leaving organizations exposed to unauthorized code execution.

Technical Details

  • Vulnerability Chain: The RCE exploits two memory corruption bugs in Oj (versions 3.13.0 to 3.17.1), a native C implementation of a Ruby JSON parser. One bug allows writing past a fixed nesting stack to control the parser's start callback, while the other truncates an object key to leak a live heap pointer.
  • Exploitation Mechanism: Attackers commit a crafted Jupyter notebook (ipynb) which triggers the renderer (ipynbdiff). Opening the commit diff leaks the heap pointer, allowing the attacker to locate libc and other libraries in memory. Subsequent notebooks fire the payload, pointing the callback to system().
  • Affected Components: All GitLab CE/EE tiers (Free through Ultimate) are affected. Specifically, versions 15.2.0–18.10.7, 18.11.0–18.11.4, and 19.0.0–19.0.1 are vulnerable. The Oj gem versions 3.13.0–3.17.1 contain the flaws.
  • Patch Status: GitLab released fixes on June 10 (18.10.8, 18.11.5, 19.0.2) and Oj released 3.17.3 on June 4. However, GitLab listed the Oj bump under "bug fixes" rather than security advisories, causing confusion. No CVE was initially assigned.
  • Privileges and Impact: The exploit runs commands as the git user (the account behind the Puma worker). This grants access to source code, Rails secrets, service credentials, CI/CD data, and internal services reachable by the application.

Industry Insight

  • Patch Classification Rigor: Organizations must scrutinize all dependency updates, even those labeled as "bug fixes," for potential security implications. Automated monitoring should flag updates to critical components like JSON parsers regardless of their classification in release notes.
  • Dependency Hygiene: Regular audits of third-party gems and native libraries are essential. The Oj vulnerability underscores the need to ensure that downstream applications using vulnerable libraries are updated promptly, independent of the primary platform's security advisory timeline.
  • Isolation Strategies: Since the exploit runs as the git user, robust containerization and strict filesystem permissions are vital. Minimizing the blast radius of the application process can limit the impact of such RCEs, protecting sensitive secrets and internal services.

TL;DR

  • 安全研究员 depthfirst 发布了 GitLab 远程代码执行(RCE)的完整利用代码,该漏洞影响所有未更新版本的自托管实例。
  • 攻击链利用 Oj JSON 解析器中的两个内存损坏漏洞,通过伪造 Jupyter Notebook 触发堆指针泄露和栈溢出,最终在无需管理员权限的情况下以 git 用户身份执行命令。
  • GitLab 将修复程序列为普通 Bug 而非安全补丁,导致缺乏 CVE 编号和 CVSS 评分,使得许多运维人员未能及时识别其紧急性。
  • 受影响版本包括 GitLab CE/EE 15.2.0 至 18.10.7、18.11.0 至 18.11.4 以及 19.0.0 至 19.0.1,建议立即升级至 18.10.8、18.11.5 或 19.0.2。

为什么值得看

这篇文章揭示了第三方依赖库(Oj)的安全缺陷如何被组合成针对大型平台(GitLab)的高危 RCE 漏洞,强调了供应链安全和依赖管理的复杂性。同时,GitLab 将该严重漏洞归类为普通 Bug 的处理方式,引发了关于漏洞披露透明度、分类标准及应急响应机制的重要讨论。

技术解析

  • 漏洞原理:利用 Ruby JSON 解析库 Oj 中的两个内存错误。第一个漏洞允许写入超过固定的 1,024 字节嵌套栈,从而控制解析器的 start 回调;第二个漏洞通过截断对象键返回活跃的堆指针,用于定位 libc 基址。
  • 攻击向量:攻击者提交精心构造的 .ipynb (Jupyter Notebook) 文件并查看其 commit diff。GitLab 的 ipynbdiff gem 会将受控 JSON 传递给长驻的 Puma worker 中的 Oj::Parser.usual.parse,使恶意字节进入手动管理的 C 内存。
  • 利用细节:通过自动化探测定位内存库,再使用两个额外的 notebook 触发 payload。由于 Puma master 重启会丢失库基址信息,该公开 PoC 主要针对 x86-64 架构下的 GitLab 18.11.3 版本定制,移植到其他环境需要大量逆向工作。
  • 影响范围与修复:所有 GitLab 版本均受影响(CE/EE, Free-Ultimate)。Oj 3.17.3 修复了底层问题,但 GitLab 需在应用层升级。对于 15.2 至 18.9 的版本,由于不在安全维护补丁轨道内,必须迁移到受支持的发布版本。

行业启示

  • 依赖风险管理:核心基础设施对第三方原生库(如 C 实现的 JSON 解析器)高度依赖,单一底层漏洞可能引发连锁反应。企业需建立更严格的第三方组件审计和监控机制,而不仅关注直接依赖。
  • 漏洞披露规范:厂商应将潜在的高危漏洞明确标记为安全修复,并提供 CVE/CVSS 评分,以确保运维团队能准确评估风险优先级。模糊的分类可能导致大规模安全事件。
  • 零信任与隔离:尽管此漏洞无需管理员权限,但命令以 git 用户运行。这突显了容器化部署中镜像版本检查的重要性(检查 Webservice 镜像内的 GitLab 版本而非 Helm Chart 版本),以及进程间隔离对限制横向移动的关键作用。

Disclaimer: The above content is generated by AI and is for reference only. 免责声明:以上内容由 AI 生成,仅供参考。

Security 安全 Open Source 开源