AI Security AI安全 2h ago Updated 1h ago 更新于 1小时前 43

Critical Gitea Flaw Let Unauthenticated Attackers Read Server Files via Org-Mode Markup Gitea关键漏洞:未认证攻击者可通过Org-Mode标记读取服务器文件

Critical unauthenticated file-read vulnerability (CVE-2026-59774, CVSS 9.8) in Gitea versions 1.22.1 through 1.27.0 allows attackers to read any file accessible to the service account via crafted Org-mode markup The flaw exists in Gitea's Org-mode renderer, which failed to override the default `ReadFile` callback in the `go-org` library, allowing `#+INCLUDE` directives with absolute paths to leak server files The file-read primitive can potentially escalate to remote code execution by reading `a Gitea 1.22.1至1.27.0存在严重文件读取漏洞(CVE-2026-59774),CVSS评分9.8,未认证攻击者仅需公开仓库和构造的Org-Mode标记即可读取服务器任意文件 漏洞根因在于go-org库的ReadFile回调未被覆盖,默认使用ioutil.ReadFile,攻击者通过#+INCLUDE指令配合绝对路径可读取服务账户可访问的所有文件 该文件读取漏洞可进一步利用:读取app.ini提取INTERNAL_TOKEN,通过内部日志注入Git hook,在匿名克隆时触发实现远程代码执行 Gitea 1.27.1已修复此漏洞(CVE-2026-59774)及另一个RCE漏洞(C

65
Hot 热度
65
Quality 质量
55
Impact 影响力

Analysis 深度分析

TL;DR

  • Critical unauthenticated file-read vulnerability (CVE-2026-59774, CVSS 9.8) in Gitea versions 1.22.1 through 1.27.0 allows attackers to read any file accessible to the service account via crafted Org-mode markup
  • The flaw exists in Gitea's Org-mode renderer, which failed to override the default ReadFile callback in the go-org library, allowing #+INCLUDE directives with absolute paths to leak server files
  • The file-read primitive can potentially escalate to remote code execution by reading app.ini, extracting the INTERNAL_TOKEN, injecting a Git hook through the internal logger, and triggering it during an anonymous clone
  • The vulnerability was discovered by XBOW Security (an autonomous offensive security system) and independently reported by Shai Rod (NightRang3r), with the fix landing in PR #38642 and backported in PR #38645
  • No exploitation in the wild was reported as of August 5, 2026, and the vulnerability had not yet appeared on CISA's Known Exploited Vulnerabilities catalog

Why It Matters

This vulnerability is significant for AI practitioners and DevOps teams because Gitea is a widely adopted self-hosted Git platform, and the unauthenticated nature of the exploit means any instance with public repositories is immediately vulnerable without requiring credentials. The potential escalation chain from file read to remote code execution demonstrates how seemingly isolated rendering flaws can become full system compromises, which is particularly relevant for organizations running AI/ML pipelines on self-hosted infrastructure where sensitive credentials and model artifacts are stored.

Technical Details

  • Vulnerability Vector: The markup rendering endpoint POST /{owner}/{repo}/markup allows anonymous access to public repositories with the code unit enabled. An attacker submits Org-mode markup with Mode: file and absolute filesystem paths via the #+INCLUDE directive.
  • Root Cause: Gitea 1.27.0 initialized go-org with org.New() without overriding the library's default ReadFile callback, which in go-org 1.9.1 is ioutil.ReadFile. This allowed arbitrary file reads from the server filesystem.
  • Escalation Chain: File read → extract INTERNAL_TOKEN from app.ini → inject Git hook via internal logger → trigger hook during anonymous clone → remote code execution. This chain remains single-sourced to Gitea's advisory with no independently published exploit.
  • Fix: PR #38642 (main) and PR #38645 (backport) override ReadFile so Org-mode include paths are returned as plain rendered content instead of being resolved from the server filesystem. A regression test was added for include-path rendering.
  • Scope: Versions 1.22.1 through 1.27.0 are affected. Instances with no public repositories are not exposed to the anonymous attack path. Gitea Cloud instances were upgraded automatically; self-hosted administrators must manually upgrade to 1.27.1.

Industry Insight

  • Patch Urgency: Self-hosted Gitea administrators should upgrade to 1.27.1 immediately and treat any instance with exposed public repositories as potentially compromised, rotating all credentials (internal tokens, OAuth material, JWT signing keys, database credentials) even if no exploitation is confirmed.
  • Supply Chain Security: The discovery by an autonomous offensive security system (XBOW Security) highlights the growing role of AI-driven vulnerability research in identifying flaws in widely-deployed open-source infrastructure, suggesting organizations should monitor such tools for proactive security assessments.
  • Pattern Recognition: This vulnerability follows a dense stretch of Gitea security issues (CVE-2026-20896 in June, CVE-2026-27771 in May), indicating a pattern of critical flaws in self-hosted Git platforms that organizations should address through automated patch management, regular security audits, and minimizing public repository exposure where possible.

TL;DR

  • Gitea 1.22.1至1.27.0存在严重文件读取漏洞(CVE-2026-59774),CVSS评分9.8,未认证攻击者仅需公开仓库和构造的Org-Mode标记即可读取服务器任意文件
  • 漏洞根因在于go-org库的ReadFile回调未被覆盖,默认使用ioutil.ReadFile,攻击者通过#+INCLUDE指令配合绝对路径可读取服务账户可访问的所有文件
  • 该文件读取漏洞可进一步利用:读取app.ini提取INTERNAL_TOKEN,通过内部日志注入Git hook,在匿名克隆时触发实现远程代码执行
  • Gitea 1.27.1已修复此漏洞(CVE-2026-59774)及另一个RCE漏洞(CVE-2026-60004),Cloud实例将自动升级,自托管管理员需立即手动升级
  • 漏洞由XBOW Security自主攻击性安全系统发现,截至2026年8月5日尚未发现野外利用,也未出现在CISA已知被利用漏洞目录中

为什么值得看

本文揭示了一个影响广泛自托管Git平台的高危漏洞,对使用Gitea的DevOps团队和开源项目维护者具有直接安全影响。漏洞利用链展示了从文件读取到远程代码执行的完整攻击路径,为安全研究者提供了典型的第三方库配置不当导致的安全风险案例。

技术解析

  • 漏洞路径:漏洞通过Gitea的标记渲染端点POST /{owner}/{repo}/markup触发,该路由允许可选登录并检查读取器访问权限。匿名请求对任何启用了代码单元的公开仓库均可通过检查,但无公开仓库的实例不受影响。
  • 根本原因:Gitea 1.27.0使用org.New()初始化go-org库时未覆盖默认的ReadFile回调。在go-org 1.9.1中,该回调为ioutil.ReadFile,Org-Mode的#+INCLUDE指令接受绝对路径并传递给回调,攻击者选择Mode: file即可读取服务账户可访问的文件。
  • 利用链:攻击者读取app.ini提取INTERNAL_TOKEN,通过内部日志注入Git hook,然后在匿名克隆时触发该hook实现命令执行。该利用链仅在Gitea公告中描述,未发现独立发布的利用代码。
  • 修复方案:修复代码位于PR #38642并回溯到PR #38645。Gitea现在覆盖ReadFile,使Org-Mode包含路径返回纯渲染内容而非从服务器文件系统解析,并添加了回归测试。
  • 检测建议:审查对/{owner}/{repo}/markup的匿名POST请求,特别是选择Org-Mode渲染或提交绝对文件系统路径的请求。如怀疑已利用,检查仓库hook目录中的意外可执行文件。

行业启示

  • 开源基础设施安全维护需持续关注:Gitea近期密集修复多个严重漏洞(6月反向代理认证绕过CVE-2026-20896、5月容器注册表访问控制缺陷CVE-2026-27771),表明自托管DevOps工具的安全维护是持续过程,管理员需保持版本及时更新。
  • 第三方库安全配置是关键风险点:本次漏洞源于未正确覆盖第三方库的安全回调,提醒开发者在集成外部组件时需审查其安全默认值,避免依赖库的不安全配置。
  • 应急响应需超越版本升级:升级至1.27.1是必要但不充分的措施。如日志显示受影响版本曾访问markup端点,应视为凭证已暴露,需轮换内部令牌、OAuth材料、JWT签名材料和数据库凭证。

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

Security 安全 Open Source 开源