public inbox for git-commits@fedoraproject.org
help / color / mirror / Atom feed
* [rpms/python3-rpm] epel9-next: CVE-2026-78367: Prevent command injection via rpmbuild -t
@ 2026-11-04 17:00 Michal Domonkos
0 siblings, 0 replies; only message in thread
From: Michal Domonkos @ 2026-11-04 17:00 UTC (permalink / raw)
To: git-commits
A new commit has been pushed.
Repo : rpms/python3-rpm
Branch : epel9-next
Commit : c4e5a302550b6c688d02ff9de691ccd16262880b
Author : Michal Domonkos <mdomonko@redhat.com>
Date : 2026-10-16T12:39:26+02:00
Stats : +84/-1 in 2 file(s)
URL : https://src.fedoraproject.org/rpms/python3-rpm/c/c4e5a302550b6c688d02ff9de691ccd16262880b?branch=epel9-next
Log:
CVE-2026-78367: Prevent command injection via rpmbuild -t
Resolves: RHEL-282745
---
diff --git a/0001-Prevent-command-injection-via-rpmbuild-t.patch b/0001-Prevent-command-injection-via-rpmbuild-t.patch
new file mode 100644
index 0000000..e4455d2
--- /dev/null
+++ b/0001-Prevent-command-injection-via-rpmbuild-t.patch
@@ -0,0 +1,79 @@
+From 9aa517baeceec55c02678c7bf89713448dd70bb6 Mon Sep 17 00:00:00 2001
+From: Michal Domonkos <mdomonko@redhat.com>
+Date: Wed, 26 Aug 2026 10:53:12 +0200
+Subject: [PATCH] Prevent command injection via rpmbuild -t
+
+When running in -t mode, the spec member name in the passed tarball will
+get macro-expanded twice: first when constructing the target filename in
+getTarSpec() and then in parseSpec(). This allows a crafted tarball to
+execute arbitrary code when the user just runs rpmbuild -ts or similar.
+
+Luckily, neither of these expansions is necessary, they are only done as
+a convenience and/or historical artifact. The former in getTarSpec() was
+only added recently via commit dfffedb5ebe46e039c0313b3d2fb939dfc63efd6
+and can easily be split into a basename(3) call so that the member name
+is not included in the expansion, effectively reverting that part of the
+original commit. The latter seems to be only used as a way to normalize
+the spec filename stored in the rpmSpec struct and can be replaced by a
+mere rpmCleanPath().
+
+Make both changes, and add a corresponding test, too.
+
+Fixes: CVE-2026-78367, #4314
+(backported from commit 2a11eb3e4e51094082e0123aebd797ec051dc094)
+---
+ build/parseSpec.c | 2 +-
+ rpmbuild.c | 9 +++++++--
+ 2 files changed, 8 insertions(+), 3 deletions(-)
+
+diff --git a/build/parseSpec.c b/build/parseSpec.c
+index 2fd29e178..4d62c337c 100644
+--- a/build/parseSpec.c
++++ b/build/parseSpec.c
+@@ -895,7 +895,7 @@ static rpmSpec parseSpec(const char *specFile, rpmSpecFlags flags,
+ /* Set up a new Spec structure with no packages. */
+ spec = newSpec();
+
+- spec->specFile = rpmGetPath(specFile, NULL);
++ spec->specFile = rpmCleanPath(xstrdup(specFile));
+ pushOFI(spec, spec->specFile);
+ /* If buildRoot not specified, use default %{buildroot} */
+ if (buildRoot) {
+diff --git a/rpmbuild.c b/rpmbuild.c
+index d02caa511..8dbd06d5f 100644
+--- a/rpmbuild.c
++++ b/rpmbuild.c
+@@ -337,6 +337,8 @@ static int isSpecFile(const char * specfile)
+ static char * getTarSpec(const char *arg)
+ {
+ char *specFile = NULL;
++ char *specDir = NULL;
++ char *specBase = NULL;
+ char *specFinal = NULL;
+ const char **spec;
+ char tarbuf[BUFSIZ];
+@@ -386,9 +388,11 @@ static char * getTarSpec(const char *arg)
+ if (!gotspec) {
+ rpmlog(RPMLOG_ERR, _("Failed to read spec file from %s\n"), arg);
+ } else {
++ specDir = rpmExpand("%{_specdir}", NULL);
++ specBase = basename(tarbuf);
+ /* remove trailing \n */
+- tarbuf[strlen(tarbuf)-1] = '\0';
+- specFinal = rpmExpand("%{_specdir}/%{basename:", tarbuf, "}", NULL);
++ specBase[strlen(specBase)-1] = '\0';
++ rasprintf(&specFinal, "%s/%s", specDir, specBase);
+ if (rename(specFile, specFinal)) {
+ rpmlog(RPMLOG_ERR, _("Failed to rename %s to %s: %m\n"),
+ specFile, specFinal);
+@@ -399,6 +403,7 @@ static char * getTarSpec(const char *arg)
+
+ exit:
+ free(specFile);
++ free(specDir);
+ Fclose(fd);
+ return specFinal;
+ }
+--
+2.56.0
+
diff --git a/rpm.spec b/rpm.spec
index b665b69..759c8f1 100644
--- a/rpm.spec
+++ b/rpm.spec
@@ -32,7 +32,7 @@
%global rpmver 4.16.1.3
#global snapver rc1
-%global rel 40
+%global rel 41
%global sover 9
%global srcver %{rpmver}%{?snapver:-%{snapver}}
@@ -123,6 +123,7 @@ Patch154: 0003-Add-support-for-spec-local-file-attributes-and-gener.patch
Patch155: 0001-Allow-an-optional-override-clock-for-deterministic-t.patch
Patch156: 0001-Improve-error-handling-on-keystore-load.patch
Patch157: 0001-Sort-files-before-passing-to-file-attribute-dependen.patch
+Patch158: 0001-Prevent-command-injection-via-rpmbuild-t.patch
# These are not yet upstream
Patch906: rpm-4.7.1-geode-i686.patch
@@ -675,6 +676,9 @@ fi
%doc doc/librpm/html/*
%changelog
+* Tue Oct 13 2026 Michal Domonkos <mdomonko@redhat.com> - 4.16.1.3-41
+- CVE-2026-78367: Prevent command injection via rpmbuild -t (RHEL-282745)
+
* Fri Nov 21 2025 Michal Domonkos <mdomonko@redhat.com> - 4.16.1.3-40
- Improve error handling on keystore load (RHEL-114837)
- Sort files before passing to file attr dependency generators (RHEL-95376)
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2026-11-04 17:00 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-04 17:00 [rpms/python3-rpm] epel9-next: CVE-2026-78367: Prevent command injection via rpmbuild -t Michal Domonkos
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox