{"id":"CVE-2026-118389","kind":"vulnerability","aliases":["CVE-2026-118389","GHSA-49c9-hm8q-6rvq"],"related":[],"title":"RubyGems Compact Index Injection via Newline in Package Metadata — Supply Chain Poisoning","description":"## Summary\n\nThe 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:\n\n1. **`/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.\n2. **`info/<name>`** — the per-package dependency index. Dependency name injection forges **fake version entries** with attacker-controlled dependencies under a real package.\n\nThis 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.\n\n## Root Cause\n\n`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.\n\nThose 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.\n\n## Full Attack Chain\n\n1. Attacker pushes gem with newline-injected platform → forges phantom package `trojaned-lib` in `/versions`\n2. Attacker uploads a REAL gem named `trojaned-lib` with malicious post-install hook\n3. Attacker pushes gem with newline-injected dependency name → forges version `99.99.99` under `innocent-gem` with dependency `trojaned-lib`\n4. Victim adds `gem \"innocent-gem\"` to Gemfile\n5. Bundler resolves `innocent-gem` 99.99.99 → installs `trojaned-lib` → attacker code executes\n\n## Impact\n\n**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.\n\n**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.\n\n## Affected Versions\n\nGitea <= 28.2.0 (confirmed). The fix is in commit `c52e7c0c` which adds newline validation to metadata fields.\n\n## Suggested Fix\n\nValidate 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.)","summary":"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.","severity":"high","cvss":8.1,"epss":null,"exploited":false,"exploited_at":null,"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"],"how_to_check":"- Check the Gitea version with `gitea --version` and confirm whether it is `28.2.0` or earlier.\n- 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.","status":"open","published_at":"2026-11-15T21:03:11+00:00","first_seen_at":"2026-11-15T21:12:47+00:00","triaged_at":"2026-11-15T21:14:12+00:00","updated_at":"2026-11-15T21:14:12+00:00","category":"package","confidence":0.85,"triage":{"at":"2026-11-15T21:14:12Z","model":"claude-haiku-5-5","output":{"fix":"- Gitea: upgrade to `28.3.0`, which adds newline validation to the RubyGems metadata fields.","reach":"network","title":"Gitea: newline in RubyGems metadata poisons compact index, enabling supply chain attacks","impact":"high","summary":"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.","audience":"developers","category":"package","nicknames":[],"who_cares":["gitea","rubygems","bundler","self-hosted"],"confidence":0.85,"fix_status":"available","needs_auth":"yes","worst_case":"Developer machines install attacker-controlled gems and run code","analyst_note":"","how_to_check":"- Check the Gitea version with `gitea --version` and confirm whether it is `28.2.0` or earlier.\n- Confirm whether the Gitea package registry's RubyGems support is enabled and used as a Bundler source.","plain_action":"","product_name":"","needs_analyst":false,"not_affected_if":["no-rubygems-registry","managed-hosting"],"who_is_affected":"Any Gitea instance that serves as a RubyGems registry is exposed, because attacker-supplied gem metadata reaches the index that Bundler reads. Teams that do not run Gitea's package registry for RubyGems, or that use only rubygems.org, are not affected.","user_interaction":"yes","product_ecosystem":"","needs_special_setup":"yes","severity_if_unknown":"high"},"cost_usd":0.000852,"input_tokens":5594,"output_tokens":586,"severity_before":"high"},"analyst_status":null,"analyst_note":null,"search":"'-118389':15A,23A '-2026':14A,22A '-74':27B '/versions':128C,279C '1':127C,263C '2':155C,280C '28.2.0':448C '3':296C '4':318C '49c9':18A '5':327C '6rvq':20A '99.99.99':308C,333C 'accept':38B,91C 'accur':418C 'add':320C,437C,457C 'affect':445C 'arbitrari':120C 'attack':62B,81B,172C,184C,204C,261C,264C,281C,297C,338C,360C,369C,374C,384C 'attacker-control':171C,203C,368C 'base':55B,115C 'believ':146C 'bundler':25B,60B,65B,144C,200C,328C,439C 'bypass':426C 'c52e7c0c':455C,496C 'caus':211C 'chain':11A,183C,262C,343C 'charact':46B,104C,238C,479C 'check':432C 'client':145C 'code':82B,339C,375C 'commit':454C,495C 'compact':2A,56B,109C,245C 'compromis':345C 'confirm':449C 'contain':44B,102C,475C 'control':173C,205C,370C 'critic':124C 'cve':13A,21A 'cwe':26B 'data':198C 'depend':42B,79B,95C,161C,163C,174C,209C,231C,304C,314C,371C,398C,468C 'develop':84B,186C,377C 'direct':242C 'download':441C 'endpoint':126C 'entri':50B,121C,136C,169C,366C,435C 'error':488C 'ever':440C 'execut':340C,373C 'exist':142C 'extra':49B 'fake':148C,167C 'field':43B,101C,235C,240C,462C,472C 'file':444C 'fix':451C,464C 'flow':241C 'fmt.fprintf':256C 'forg':48B,119C,135C,166C,272C,306C,361C,364C,434C 'format':111C 'full':260C 'function':215C 'gem':39B,73B,206C,218C,266C,285C,299C,312C,321C,324C,332C,380C,443C 'gemfil':326C,391C 'get':195C 'ghsa':17A 'ghsa-49c9-hm8q-6rvq':16A 'gitea':28B,34B,88C,189C,347C,410C,447C 'gitea.dev':24A 'global':130C 'hm8q':19A 'hook':295C,382C 'host':33B,151C 'impact':341C 'implement':497C 'index':3A,57B,110C,125C,162C,246C,357C,403C,417C,423C 'index-level':422C 'info':156C 'inject':4A,117C,134C,165C,270C,303C,400C,425C 'innoc':311C,323C,331C 'innocent-gem':310C,322C,330C 'instal':202C,294C,334C,381C 'instanc':190C,348C 'integr':344C,431C 'invis':386C 'level':404C,424C,430C 'lib':277C,289C,317C,337C 'line':54B,114C 'line-bas':53B,113C 'list':132C 'machin':85B,378C 'make':64B,143C 'makepackageversiondepend':249C 'malici':78B,291C,397C 'metadata':9A,461C,485C 'model':406C 'modules/packages/rubygems/metadata.go':212C,481C 'n':105C,478C 'name':96C,164C,219C,232C,286C,305C,469C 'newlin':6A,45B,103C,118C,237C,269C,302C,458C 'newline-inject':268C,301C 'organ':408C 'output':247C 'packag':8A,29B,89C,93C,131C,138C,149C,160C,178C,274C,363C,395C,412C,421C,429C 'package-level':428C 'parsemetadatafil':214C 'per':159C 'per-packag':158C 'phantom':273C,362C 'platform':40B,100C,133C,230C,271C,467C 'poison':12A,68B,196C,358C 'post':293C 'post-instal':292C 'pull':75B 'push':265C,298C 'r':476C 'real':72B,177C,284C,394C 'refer':392C 'reflect':419C 'registri':37B,90C,154C,353C,413C 'requir':98C 'resolut':197C 'resolv':66B,329C 'return':486C 'root':210C 'routers/api/packages/rubygems/rubygems.go':253C 'rubygem':1A,30B,36B,92C,108C,193C,352C 'run':80B 'sanit':259C 'self':32B 'self-host':31B 'serv':58B,349C 'sourc':194C 'store':483C 'suggest':463C 'summari':86C 'suppli':10A,182C,342C 'transit':208C 'trojan':276C,288C,316C,336C 'trojaned-lib':275C,287C,315C,335C 'trust':405C,414C 'two':123C 'upload':282C,420C 'use':187C,255C,409C 'valid':216C,228C,459C,465C 'version':69B,97C,168C,224C,307C,365C,446C 'versionrequir':234C,471C 'via':5A,248C,379C 'victim':319C,389C 'violat':407C 'vulner':355C 'w':221C 'whose':94C 'writepackageversionforlist':251C 'z':222C","nicknames":[],"mitigations":[],"who_affected":"Any Gitea instance that serves as a RubyGems registry is exposed, because attacker-supplied gem metadata reaches the index that Bundler reads. Teams that do not run Gitea's package registry for RubyGems, or that use only rubygems.org, are not affected.","tier":"B","verified":{},"analyst_revisit_at":null,"fix_status":"available","audience":"developers","plain_action":null,"pkeys":["giteadev"],"ptokens":["dev","gitea"],"labels":["bundler","cwe74","gitea","go","high","package","rubygems","selfhosted"],"campaign_type":null,"search_a":"'-118389':15A,23A '-2026':14A,22A '49c9':18A '6rvq':20A 'chain':11A 'compact':2A 'cve':13A,21A 'ghsa':17A 'ghsa-49c9-hm8q-6rvq':16A 'gitea.dev':24A 'hm8q':19A 'index':3A 'inject':4A 'metadata':9A 'newlin':6A 'packag':8A 'poison':12A 'rubygem':1A 'suppli':10A 'via':5A","search_b":"'-74':27B 'accept':38B 'attack':62B,81B 'base':55B 'bundler':25B,60B,65B 'charact':46B 'code':82B 'compact':56B 'contain':44B 'cwe':26B 'depend':42B,79B 'develop':84B 'entri':50B 'extra':49B 'field':43B 'forg':48B 'gem':39B,73B 'gitea':28B,34B 'host':33B 'index':57B 'line':54B 'line-bas':53B 'machin':85B 'make':64B 'malici':78B 'newlin':45B 'packag':29B 'platform':40B 'poison':68B 'pull':75B 'real':72B 'registri':37B 'resolv':66B 'rubygem':30B,36B 'run':80B 'self':32B 'self-host':31B 'serv':58B 'version':69B","search_c":"'/versions':128C,279C '1':127C,263C '2':155C,280C '28.2.0':448C '3':296C '4':318C '5':327C '99.99.99':308C,333C 'accept':91C 'accur':418C 'add':320C,437C,457C 'affect':445C 'arbitrari':120C 'attack':172C,184C,204C,261C,264C,281C,297C,338C,360C,369C,374C,384C 'attacker-control':171C,203C,368C 'base':115C 'believ':146C 'bundler':144C,200C,328C,439C 'bypass':426C 'c52e7c0c':455C,496C 'caus':211C 'chain':183C,262C,343C 'charact':104C,238C,479C 'check':432C 'client':145C 'code':339C,375C 'commit':454C,495C 'compact':109C,245C 'compromis':345C 'confirm':449C 'contain':102C,475C 'control':173C,205C,370C 'critic':124C 'data':198C 'depend':95C,161C,163C,174C,209C,231C,304C,314C,371C,398C,468C 'develop':186C,377C 'direct':242C 'download':441C 'endpoint':126C 'entri':121C,136C,169C,366C,435C 'error':488C 'ever':440C 'execut':340C,373C 'exist':142C 'fake':148C,167C 'field':101C,235C,240C,462C,472C 'file':444C 'fix':451C,464C 'flow':241C 'fmt.fprintf':256C 'forg':119C,135C,166C,272C,306C,361C,364C,434C 'format':111C 'full':260C 'function':215C 'gem':206C,218C,266C,285C,299C,312C,321C,324C,332C,380C,443C 'gemfil':326C,391C 'get':195C 'gitea':88C,189C,347C,410C,447C 'global':130C 'hook':295C,382C 'host':151C 'impact':341C 'implement':497C 'index':110C,125C,162C,246C,357C,403C,417C,423C 'index-level':422C 'info':156C 'inject':117C,134C,165C,270C,303C,400C,425C 'innoc':311C,323C,331C 'innocent-gem':310C,322C,330C 'instal':202C,294C,334C,381C 'instanc':190C,348C 'integr':344C,431C 'invis':386C 'level':404C,424C,430C 'lib':277C,289C,317C,337C 'line':114C 'line-bas':113C 'list':132C 'machin':378C 'make':143C 'makepackageversiondepend':249C 'malici':291C,397C 'metadata':461C,485C 'model':406C 'modules/packages/rubygems/metadata.go':212C,481C 'n':105C,478C 'name':96C,164C,219C,232C,286C,305C,469C 'newlin':103C,118C,237C,269C,302C,458C 'newline-inject':268C,301C 'organ':408C 'output':247C 'packag':89C,93C,131C,138C,149C,160C,178C,274C,363C,395C,412C,421C,429C 'package-level':428C 'parsemetadatafil':214C 'per':159C 'per-packag':158C 'phantom':273C,362C 'platform':100C,133C,230C,271C,467C 'poison':196C,358C 'post':293C 'post-instal':292C 'push':265C,298C 'r':476C 'real':177C,284C,394C 'refer':392C 'reflect':419C 'registri':90C,154C,353C,413C 'requir':98C 'resolut':197C 'resolv':329C 'return':486C 'root':210C 'routers/api/packages/rubygems/rubygems.go':253C 'rubygem':92C,108C,193C,352C 'sanit':259C 'serv':349C 'sourc':194C 'store':483C 'suggest':463C 'summari':86C 'suppli':182C,342C 'transit':208C 'trojan':276C,288C,316C,336C 'trojaned-lib':275C,287C,315C,335C 'trust':405C,414C 'two':123C 'upload':282C,420C 'use':187C,255C,409C 'valid':216C,228C,459C,465C 'version':97C,168C,224C,307C,365C,446C 'versionrequir':234C,471C 'via':248C,379C 'victim':319C,389C 'violat':407C 'vulner':355C 'w':221C 'whose':94C 'writepackageversionforlist':251C 'z':222C","cause_entry":null,"cause_path":null,"disclosures_checked_at":null,"first_public_at":"2026-11-15T21:03:11+00:00","kev":null,"cvss_vector":null,"cvss_by":null,"poc_count":0,"sources":[{"source":"ghsa-repo","external_id":"GHSA-49c9-hm8q-6rvq","url":"https://github.com/go-gitea/gitea/security/advisories/GHSA-49c9-hm8q-6rvq","severity":"high","published_at":"2026-11-15T21:03:11+00:00","modified_at":"2026-11-15T21:03:11+00:00","first_seen_at":"2026-11-15T21:12:47+00:00","fetched_at":"2026-11-15T21:12:47+00:00","note":null},{"source":"nvd","external_id":"CVE-2026-118389","url":"https://nvd.nist.gov/vuln/detail/CVE-2026-118389","severity":null,"published_at":"2026-11-15T22:17:17+00:00","modified_at":"2026-11-15T22:17:17+00:00","first_seen_at":"2026-11-15T22:40:23+00:00","fetched_at":"2026-11-15T22:40:24+00:00","note":null}],"documents":[{"id":165570,"url":"https://github.com/go-gitea/gitea/security/advisories/GHSA-49c9-hm8q-6rvq","title":"Maintainer's advisory: github.com","kind":"vendor","source":"ghsa-repo","publisher":"vendor","text":null,"published_at":"2026-11-15T21:03:11+00:00","relation":"advisory","confidence":null,"note":"Maintainer's advisory: github.com"},{"id":50311,"url":"https://github.com/go-gitea/gitea/releases/tag/v28.3.0","title":"Release notes: github.com","kind":"release","source":"nvd","publisher":"vendor","text":null,"published_at":null,"relation":"fix","confidence":null,"note":"Release notes: github.com"}],"disclosures":[],"exploit_sources":[],"notice":"Free to read, with fair use of about 60 pages a minute. For higher limits or API access: sales@infrastack.ai"}