---
id: "CVE-2026-118389"
page: "https://infrastack.ai/live/CVE-2026-118389"
kind: "vulnerability"
aliases: ["CVE-2026-118389", "GHSA-49c9-hm8q-6rvq"]
title: "RubyGems Compact Index Injection via Newline in Package Metadata \u2014 Supply Chain Poisoning"
severity: "high"
cvss: 8.1
epss: null
exploited: false
status: "open"
category: "package"
products: [{"name": "gitea.dev", "fixed": ["28.3.0"], "affected": "<= 28.2.0", "ecosystem": "go"}]
ecosystems: ["go"]
tags: ["bundler", "cwe-74", "gitea", "package", "rubygems", "self-hosted"]
not_affected_if: ["managed-hosting", "no-rubygems-registry"]
published_at: "2026-11-15T21:03:11+00:00"
first_seen_at: "2026-11-15T21:12:47+00:00"
updated_at: "2026-11-15T21:14:12+00:00"
sources: [{"source": "ghsa-repo", "url": "https://github.com/go-gitea/gitea/security/advisories/GHSA-49c9-hm8q-6rvq", "first_seen_at": "2026-11-15T21:12:47+00:00"}, {"source": "nvd", "url": "https://nvd.nist.gov/vuln/detail/CVE-2026-118389", "first_seen_at": "2026-11-15T22:40:23+00:00"}]
exploit_sources: []
---

# RubyGems Compact Index Injection via Newline in Package Metadata — Supply Chain Poisoning

Link for people: https://infrastack.ai/live/CVE-2026-118389 (this .md is for agents)

Gitea's RubyGems registry accepts gem platform and dependency fields containing newline characters, which forge extra entries in the line-based compact index served to Bundler. An attacker can make Bundler resolve a poisoned version of a real gem that pulls in a malicious dependency, running attacker code on developer machines.

_Summary, check and fix written by a model from the sources; labelled as such._

## Affected

- go:gitea.dev affected <= 28.2.0 fixed 28.3.0

## How to check

- Check the Gitea version with `gitea --version` and confirm whether it is `28.2.0` or earlier.
- Confirm whether the Gitea package registry's RubyGems support is enabled and used as a Bundler source.

## Fix

- Gitea: upgrade to `28.3.0`, which adds newline validation to the RubyGems metadata fields.

## Timeline

- 2026-11-15T21:12:47+00:00 ghsa-repo https://github.com/go-gitea/gitea/security/advisories/GHSA-49c9-hm8q-6rvq
- 2026-11-15T22:40:23+00:00 nvd https://nvd.nist.gov/vuln/detail/CVE-2026-118389

## Documents

- [advisory] Maintainer's advisory: github.com https://github.com/go-gitea/gitea/security/advisories/GHSA-49c9-hm8q-6rvq
- [fix] Release notes: github.com https://github.com/go-gitea/gitea/releases/tag/v28.3.0

## From the sources

## Summary

The Gitea package registry accepts RubyGems packages whose dependency names, version requirements, and platform fields contain newline characters (`\n`). Because the RubyGems compact index format is **line-based**, an injected newline forges arbitrary entries in two critical index endpoints:

1. **`/versions`** — the global package listing. Platform injection forges entries for **packages that don't exist**, making bundler clients believe a fake package is hosted on this registry.
2. **`info/<name>`** — the per-package dependency index. Dependency name injection forges **fake version entries** with attacker-controlled dependencies under a real package.

This is a **supply chain attack**: any developer using this Gitea instance as a RubyGems source gets poisoned resolution data, and bundler will install attacker-controlled gems as transitive dependencies.

## Root Cause

`modules/packages/rubygems/metadata.go` — the `parseMetadataFile` function validates the gem name (`\A[\w.-]+\z`) and version, but **does not validate** the `Platform`, dependency `Name`, or `VersionRequirement` fields for newline characters.

Those fields flow directly into the compact index output via `makePackageVersionDependency` and `writePackageVersionForList` in `routers/api/packages/rubygems/rubygems.go`, which use `fmt.Fprintf` with no sanitization.

## Full Attack Chain

1. Attacker pushes gem with newline-injected platform → forges phantom package `trojaned-lib` in `/versions`
2. Attacker uploads a REAL gem named `trojaned-lib` with malicious post-install hook
3. Attacker pushes gem with newline-injected dependency name → forges version `99.99.99` under `innocent-gem` with dependency `trojaned-lib`
4. Victim adds `gem "innocent-gem"` to Gemfile
5. Bundler resolves `innocent-gem` 99.99.99 → installs `trojaned-lib` → attacker code executes

## Impact

**Supply chain integrity compromise:** Any Gitea instance serving as a RubyGems registry is vulnerable to index poisoning. The attack forges phantom packages, forges version entries with attacker-controlled dependencies, and executes attacker code on developer machines via gem install hooks. The attack is invisible to the victim — the Gemfile references a real package; the malicious dependency is injected at the index level.

**Trust model violation:** Organizations using Gitea's package registry trust that the index accurately reflects uploaded packages. Index-level injection bypasses all package-level integrity checks because forged entries are added before bundler ever downloads a gem file.

## Affected Versions

Gitea <= 28.2.0 (confirmed). The fix is in commit `c52e7c0c` which adds newline validation to metadata fields.

## Suggested Fix

Validate that `Platform`, dependency `Name`, and `VersionRequirement` fields do not contain `\r` or `\n` characters in `modules/packages/rubygems/metadata.go` before storing the metadata. Return an error if they do. (This is what commit `c52e7c0c` implements.)

---

_Free to read, with fair use of about 60 pages a minute. For higher limits or API access: sales@infrastack.ai_
