public inbox for git-commits@fedoraproject.org
help / color / mirror / Atom feed
* [rpms/python3-rpm] epel10: CVE-2026-78367: Prevent command injection via rpmbuild -t
@ 2026-10-21 12:54 Michal Domonkos
0 siblings, 0 replies; only message in thread
From: Michal Domonkos @ 2026-10-21 12:54 UTC (permalink / raw)
To: git-commits
A new commit has been pushed.
Repo : rpms/python3-rpm
Branch : epel10
Commit : b1287c3498561d43c6aec70e28b63bb580845c24
Author : Michal Domonkos <mdomonko@redhat.com>
Date : 2026-10-12T14:35:06+02:00
Stats : +85/-1 in 2 file(s)
URL : https://src.fedoraproject.org/rpms/python3-rpm/c/b1287c3498561d43c6aec70e28b63bb580845c24?branch=epel10
Log:
CVE-2026-78367: Prevent command injection via rpmbuild -t
Resolves: RHEL-247298
---
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..a93338a
--- /dev/null
+++ b/0001-Prevent-command-injection-via-rpmbuild-t.patch
@@ -0,0 +1,79 @@
+From f4ae6ca2338606d2d2ba64882dc94dec80b20dab 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 +-
+ tools/rpmbuild.c | 9 +++++++--
+ 2 files changed, 8 insertions(+), 3 deletions(-)
+
+diff --git a/build/parseSpec.c b/build/parseSpec.c
+index 0ecfcb6cd..309d0ad06 100644
+--- a/build/parseSpec.c
++++ b/build/parseSpec.c
+@@ -1111,7 +1111,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/tools/rpmbuild.c b/tools/rpmbuild.c
+index 16fba7767..c86a3ab23 100644
+--- a/tools/rpmbuild.c
++++ b/tools/rpmbuild.c
+@@ -366,6 +366,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];
+@@ -415,9 +417,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);
+@@ -428,6 +432,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 e8d4084..7572e44 100644
--- a/rpm.spec
+++ b/rpm.spec
@@ -27,7 +27,7 @@
%global rpmver 4.19.1.1
#global snapver rc1
-%global baserelease 25
+%global baserelease 26
%global sover 10
%global srcver %{rpmver}%{?snapver:-%{snapver}}
@@ -180,6 +180,8 @@ rpm-4.19.x-add-parkdb.patch
rpm-4.19.x-improve-syslog.patch
0001-Prevent-buffer-overruns-in-findPreambleTag-for-langu.patch
+0001-Prevent-command-injection-via-rpmbuild-t.patch
+
# These are not yet upstream
rpm-4.7.1-geode-i686.patch
@@ -670,6 +672,9 @@ fi
%doc %{_defaultdocdir}/rpm/API/
%changelog
+* Mon Oct 12 2026 Michal Domonkos <mdomonko@redhat.com> - 4.19.1.1-26
+- CVE-2026-78367: Prevent command injection via rpmbuild -t (RHEL-247298)
+
* Fri Jun 19 2026 Michal Domonkos <mdomonko@redhat.com> - 4.19.1.1-25
- Apply forgotten patch for RHEL-169755
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2026-10-21 12:54 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-21 12:54 [rpms/python3-rpm] epel10: 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