Summary
A high-severity code injection vulnerability in RPM's rpmbuild tarball processing allows a crafted source archive member name to inject RPM macros, including Lua expressions.
When a victim or automated build system processes the archive in tarball mode, arbitrary code may execute with the privileges of the user running rpmbuild.
Affected context
The vulnerability occurs in RPM builds that process attacker-controlled source archives through rpmbuild tarball modes such as -ts, -ta, or -tb. It requires the archive to contain a specially crafted member name and for the build workflow to pass that name into macro expansion before the source package is fully trusted or constrained.
Exploit preconditions
- Attack surface: RPM source tarball processing through rpmbuild
- Required access: Ability to provide or influence a source archive processed by a victim or build system
- Trigger point: Tarball member-name handling during getTarSpec() processing
- Why exploitation is possible: An archive member name is incorporated into an RPM macro expression and evaluated by rpmExpand(), allowing attacker-controlled macro or Lua content to be interpreted
Why this happens
The underlying flaw is improper separation between archive metadata and executable macro language. The getTarSpec() function passes an attacker-controlled tar archive member name into rpmExpand() as part of a %{basename:...} expression, causing data that should remain a filename to be interpreted as RPM macro content.
This maps to CWE-94: Improper Control of Generation of Code ('Code Injection'), because untrusted input reaches an interpreter without adequate neutralization, validation, or isolation.
Potential impact
- Arbitrary code may execute with the privileges of the rpmbuild process
- Build hosts or automated CI workers could be compromised
- Source packages, generated artifacts, or build outputs could be altered
- Credentials and other data accessible to the build account could be exposed
- Downstream software supply chains could be affected by tampered artifacts
General mitigation guidance
Mitigation generally focuses on preventing untrusted archive metadata from reaching executable macro evaluation.
Common defensive patterns include:
- Treating archive member names as inert data rather than macro or script input
- Applying strict validation and canonicalization to archive paths and metadata
- Using narrowly scoped parsing APIs that do not evaluate embedded expressions
- Separating source acquisition from privileged or sensitive build operations
- Running builds with dedicated, least-privileged accounts and isolated workers
- Reducing network, filesystem, and credential access available to build processes
- Requiring provenance and policy checks before accepting externally supplied source archives
How teams detect issues like this
Detection approaches can include:
- Static analysis searches for attacker-controlled archive metadata passed to macro, template, Lua, or shell evaluators
- Code review checks for string interpolation into RPM expressions without strict validation
- Regression tests using archive metadata containing unexpected delimiters or interpreter syntax
- Build-policy enforcement that restricts externally supplied tarballs in privileged or connected workers
- Runtime monitoring for unexpected child processes, file changes, or network activity from rpmbuild
- Automated security review tools configured to flag interpreter-bound data flows

