public inbox for git-commits@fedoraproject.org
help / color / mirror / Atom feed
* [rpms/python3-rpm] epel10: Fix some more CVEs
@ 2026-12-01 13:48 Michal Domonkos
  0 siblings, 0 replies; only message in thread
From: Michal Domonkos @ 2026-12-01 13:48 UTC (permalink / raw)
  To: git-commits

            A new commit has been pushed.

            Repo   : rpms/python3-rpm
            Branch : epel10
            Commit : 984fb5eafab8da6f1470db729c2a20df5f0bceb7
            Author : Michal Domonkos <mdomonko@redhat.com>
            Date   : 2026-11-20T14:55:46+01:00
            Stats  : +417/-1 in 7 file(s)
            URL    : https://src.fedoraproject.org/rpms/python3-rpm/c/984fb5eafab8da6f1470db729c2a20df5f0bceb7?branch=epel10

            Log:
            Fix some more CVEs

Resolves: RHEL-288159
Resolves: RHEL-287862
Resolves: RHEL-287861
Resolves: RHEL-273514

---
diff --git a/0001-Make-the-hex-validator-helper-function-internally-av.patch b/0001-Make-the-hex-validator-helper-function-internally-av.patch
new file mode 100644
index 0000000..93ed784
--- /dev/null
+++ b/0001-Make-the-hex-validator-helper-function-internally-av.patch
@@ -0,0 +1,62 @@
+From 65e8da955bdb30bd8baba947a305f3c81d112a30 Mon Sep 17 00:00:00 2001
+From: Panu Matilainen <pmatilai@redhat.com>
+Date: Thu, 10 Oct 2024 11:15:56 +0300
+Subject: [PATCH 1/3] Make the hex validator helper function internally
+ available
+
+We may and will have other places that need to validate input as hex.
+
+Backported from commit 0de0ce4bca0dec588df250f6d443b7accec88e6b
+- Needed for the CVE-2026-103242 fix
+---
+ lib/misc.h  | 3 +++
+ lib/rpmvs.c | 5 +++--
+ 2 files changed, 6 insertions(+), 2 deletions(-)
+
+diff --git a/lib/misc.h b/lib/misc.h
+index e2f234bcf..8963811ed 100644
+--- a/lib/misc.h
++++ b/lib/misc.h
+@@ -62,6 +62,9 @@ RPM_GNUC_INTERNAL
+ void rpmRelocationBuild(Header h, rpmRelocation *rawrelocs,
+ 		int *rnrelocs, rpmRelocation **rrelocs, uint8_t **rbadrelocs);
+ 
++RPM_GNUC_INTERNAL
++int rpmIsValidHex(const char *str, size_t slen);
++
+ #ifdef __cplusplus
+ }
+ #endif
+diff --git a/lib/rpmvs.c b/lib/rpmvs.c
+index 763481386..32bf9e603 100644
+--- a/lib/rpmvs.c
++++ b/lib/rpmvs.c
+@@ -5,6 +5,7 @@
+ #include <rpm/rpmkeyring.h>
+ #include <rpm/rpmmacro.h>
+ #include <rpm/rpmlog.h>
++#include "misc.h"
+ #include "rpmvs.h"
+ #include "rpmpgpval.h"
+ 
+@@ -118,7 +119,7 @@ static int sinfoLookup(rpmTagVal tag)
+     return ix;
+ }
+ 
+-static int validHex(const char *str, size_t slen)
++int rpmIsValidHex(const char *str, size_t slen)
+ {
+     int valid = 0; /* Assume invalid */
+     const char *b;
+@@ -234,7 +235,7 @@ static rpmRC rpmsinfoInit(const struct vfyinfo_s *vinfo,
+ 	if (td->type == RPM_BIN_TYPE) {
+ 	    sinfo->dig = rpmhex(data, dlen);
+ 	} else {
+-	    if (!validHex(data, dlen)) {
++	    if (!rpmIsValidHex(data, dlen)) {
+ 		rasprintf(&sinfo->msg,
+ 			_("%s: tag %u: invalid hex"), origin, td->tag);
+ 		goto exit;
+-- 
+2.56.1
+

diff --git a/0001-Prevent-command-injection-via-spec-source-basename.patch b/0001-Prevent-command-injection-via-spec-source-basename.patch
new file mode 100644
index 0000000..4a43c39
--- /dev/null
+++ b/0001-Prevent-command-injection-via-spec-source-basename.patch
@@ -0,0 +1,45 @@
+From 46831d2f007dfcda524ceee1ed6b1c2b0347206a Mon Sep 17 00:00:00 2001
+From: Michal Domonkos <mdomonko@redhat.com>
+Date: Thu, 19 Nov 2026 11:27:19 +0100
+Subject: [PATCH] Prevent command injection via spec/source basename
+
+Don't macro-expand spec or source filenames coming from the SRPM we are
+installing. Instead, expand the configuration macros first and only then
+append the basename without expanding it. This fixes another one in the
+recent series of command injection flaws.
+
+We could use rpm::join_path() here instead of rasprintf() but the latter
+will make it easier to backport this patch to older RPM versions, and is
+also more consistent with the surrounding code, so let's just do that.
+
+Enable the respective test added in the previous commit.
+
+Fixes: CVE-2026-95521
+(cherry picked from commit 4c609d887e076bf6b34d0a361e9996a7ee1c5f64)
+---
+ lib/relocation.c | 8 ++++++--
+ 1 file changed, 6 insertions(+), 2 deletions(-)
+
+diff --git a/lib/relocation.c b/lib/relocation.c
+index a7110d426..455c2a509 100644
+--- a/lib/relocation.c
++++ b/lib/relocation.c
+@@ -448,9 +448,13 @@ int rpmRelocateSrpmFileList(Header h, const char *rootDir)
+ 	headerGet(h, RPMTAG_ORIGBASENAMES, &filenames, HEADERGET_ALLOC);
+ 	for (int i = 0; (bn = rpmtdNextString(&filenames)); i++) {
+ 	    int spec = (i == specix);
+-	    char *fn = rpmGenPath(rootDir,
+-				  spec ? "%{_specdir}" : "%{_sourcedir}", bn);
++	    char *fn = NULL;
++	    char *dn = rpmGenPath(rootDir,
++				  spec ? "%{_specdir}" : "%{_sourcedir}",
++				  NULL);
++	    rasprintf(&fn, "%s/%s", dn, bn);
+ 	    headerPutString(h, RPMTAG_OLDFILENAMES, fn);
++	    free(dn);
+ 	    free(fn);
+ 	}
+ 	rpmtdFreeData(&filenames);
+-- 
+2.56.1
+

diff --git a/0001-Remove-macro-expansion-from-manifest-parsing.patch b/0001-Remove-macro-expansion-from-manifest-parsing.patch
new file mode 100644
index 0000000..ad6850a
--- /dev/null
+++ b/0001-Remove-macro-expansion-from-manifest-parsing.patch
@@ -0,0 +1,54 @@
+From 273798735fbe01d3723b03b266ef55b0466ee45a Mon Sep 17 00:00:00 2001
+From: SleedSurfer <timo.tabacek@gmail.com>
+Date: Tue, 13 Oct 2026 13:34:11 +0200
+Subject: [PATCH] Remove macro expansion from manifest parsing
+
+Processing a non-package file as manifest triggered a macro expansion
+before opening and reading the file. This allowed execution of arbitrary
+commands through the use of shell escape macros.
+
+Macro expansion was removed entirely from manifest/path parsing to
+prevent further exploits.
+
+Note: Possibly a breaking change for dynamic paths/manifests.
+
+Fixes: CVE-2026-95519, #4349
+(cherry picked from commit 4f7be32ef288a231893dd4c45d4ef36584e3d4b6)
+---
+ lib/rpmgi.c | 8 +++-----
+ 1 file changed, 3 insertions(+), 5 deletions(-)
+
+diff --git a/lib/rpmgi.c b/lib/rpmgi.c
+index 2ed7a41dd..08a8639d3 100644
+--- a/lib/rpmgi.c
++++ b/lib/rpmgi.c
+@@ -41,7 +41,7 @@ struct rpmgi_s {
+ };
+ 
+ /**
+- * Open a file after macro expanding path.
++ * Open a file.
+  * @todo There are two error messages printed on header, then manifest failures.
+  * @param path		file path
+  * @param fmode		open mode
+@@ -49,15 +49,13 @@ struct rpmgi_s {
+  */
+ static FD_t rpmgiOpen(const char * path, const char * fmode)
+ {
+-    char * fn = rpmExpand(path, NULL);
+-    FD_t fd = Fopen(fn, fmode);
++    FD_t fd = Fopen(path, fmode);
+ 
+     if (fd == NULL || Ferror(fd)) {
+-	rpmlog(RPMLOG_ERR, _("open of %s failed: %s\n"), fn, Fstrerror(fd));
++	rpmlog(RPMLOG_ERR, _("open of %s failed: %s\n"), path, Fstrerror(fd));
+ 	if (fd != NULL) (void) Fclose(fd);
+ 	fd = NULL;
+     }
+-    free(fn);
+ 
+     return fd;
+ }
+-- 
+2.56.1
+

diff --git a/0001-Sanity-check-symlink-info-while-iterating-an-archive.patch b/0001-Sanity-check-symlink-info-while-iterating-an-archive.patch
new file mode 100644
index 0000000..6500760
--- /dev/null
+++ b/0001-Sanity-check-symlink-info-while-iterating-an-archive.patch
@@ -0,0 +1,54 @@
+From 8615d74d4c08d2d9e4f5fb07aded362a9ddef7b7 Mon Sep 17 00:00:00 2001
+From: Panu Matilainen <pmatilai@redhat.com>
+Date: Thu, 22 Oct 2026 14:41:35 +0300
+Subject: [PATCH] Sanity check symlink info while iterating an archive
+ (CVE-2026-95520)
+
+A crafted package (either v4 with > 4GB files or v6 format) can have
+UINT64_MAX as the symlink size and the previous code would've allocated
+a buffer of 1 byte for it due to wraparound and then the consequent read
+operation reads attacker controlled data into memory. I dunno how
+exploitable it is in reality, and the the next rpmfiNext() call will
+fail so there seems to be limited damage it can do, but it's ugly anyhow.
+
+The symlink data from the payload is irrelevant, we only ever use what's
+in the header. But since it's there, we need to get the size right.
+Cross-check the provided header data matches size-wise. This gives
+us a guarantee against the overflow, as string lengths are capped by
+the 256MB total size limit of the header.
+
+Fixes: CVE-2026-95520
+Fixes: #4347
+
+Backported from commit 5bc8705e0f9a9ffc123fb1c693bdad13de9f7c03:
+- The main difference here is the test behavior due to broken
+  rpm2archive error handling in this version of rpm, but we can't
+  start backporting all those along. So the outputed tarball is
+  invalid but at least the iteration stops at the oversized link.
+---
+ lib/rpmfi.c | 8 ++++++--
+ 1 file changed, 6 insertions(+), 2 deletions(-)
+
+diff --git a/lib/rpmfi.c b/lib/rpmfi.c
+index b35195e76..f6fa53a5d 100644
+--- a/lib/rpmfi.c
++++ b/lib/rpmfi.c
+@@ -2278,9 +2278,13 @@ static int iterReadArchiveNext(rpmfi fi)
+ 	    if (!(numlinks > 1 && links[numlinks-1] != fx))
+ 		fsize = rpmfilesFSize(fi->files, fx);
+ 	} else if (S_ISLNK(mode)) {
+-	    /* Skip over symlink target data in payload */
++	    /* Cross-check symlink data, strings are capped by header size. */
+ 	    rpm_loff_t lsize = rpmfilesFSize(fi->files, fx);
+-	    char *buf = xmalloc(lsize + 1);
++	    const char *link = rpmfilesFLink(fi->files, fx);
++	    if (link == NULL || lsize != strlen(link))
++		return RPMERR_BAD_HEADER;
++	    /* Skip over symlink target data in payload */
++	    char *buf = (char *)xmalloc(lsize + 1);
+ 	    if (rpmcpioRead(fi->archive, buf, lsize) != lsize)
+ 		rc = RPMERR_READ_FAILED;
+ 	    /* XXX should we validate the payload matches? */
+-- 
+2.56.1
+

diff --git a/0002-Harden-file-signature-data-population-in-the-rpmfile.patch b/0002-Harden-file-signature-data-population-in-the-rpmfile.patch
new file mode 100644
index 0000000..7448ef6
--- /dev/null
+++ b/0002-Harden-file-signature-data-population-in-the-rpmfile.patch
@@ -0,0 +1,106 @@
+From 7ffc3e2625e3a770acb5217daeda94a7d411117f Mon Sep 17 00:00:00 2001
+From: Panu Matilainen <pmatilai@redhat.com>
+Date: Tue, 13 Oct 2026 13:03:07 +0300
+Subject: [PATCH 2/3] Harden file signature data population in the rpmfiles API
+ (CVE-2026-103242)
+
+Check for non-zero rpmtdSize() before basing calculations on it.
+Validate each string to be actual hex.
+
+Differentiate between missing file signatures (which is not an error)
+and invalid data in hex2binv(), return an error code and fail the
+entire rpmfi/rpmfiles on bad data.
+
+Fixes: CVE-2026-103242
+Fixes: #4346
+
+Backported from commit 4a142372bb27375ccee6b0975cff8008dc249b77
+- test dropped, it depends on too many other things that are not there
+---
+ lib/rpmfi.c | 32 ++++++++++++++++++++++----------
+ 1 file changed, 22 insertions(+), 10 deletions(-)
+
+diff --git a/lib/rpmfi.c b/lib/rpmfi.c
+index f6fa53a5d..7c2e2ded7 100644
+--- a/lib/rpmfi.c
++++ b/lib/rpmfi.c
+@@ -20,6 +20,7 @@
+ #include "rpmte_internal.h"	/* relocations */
+ #include "cpio.h"	/* XXX CPIO_FOO */
+ #include "fsm.h"	/* rpmpsm stuff for now */
++#include "misc.h"
+ #include "rpmug.h"
+ #include "rpmio_internal.h"       /* fdInit/FiniDigest */
+ 
+@@ -1484,16 +1485,23 @@ err:
+  * accessed via offsets to a contiguous binary blob. Empty values
+  * are represented by identical consequtive offsets. The offsets array
+  * always has one extra element to allow calculating the size of the
+- * last element.
++ * last element. Return zero on success.
+  */
+-static uint8_t *hex2binv(Header h, rpmTagVal tag, rpm_count_t num,
+-			uint32_t **offsetp)
++static int hex2binv(Header h, rpmTagVal tag, rpm_count_t num,
++		    uint32_t **offsetp, unsigned char **binp)
+ {
+     struct rpmtd_s td;
+     uint8_t *bin = NULL;
+     uint32_t *offs = NULL;
++    int rc = 1; /* assume failure */
+ 
+-    if (headerGet(h, tag, &td, HEADERGET_MINMEM) && rpmtdCount(&td) == num) {
++    /* File signature presence is not required */
++    if (!headerGet(h, tag, &td, HEADERGET_MINMEM)) {
++	rc = 0;
++	goto exit;
++    }
++
++    if (rpmtdSize(&td) && rpmtdCount(&td) == num) {
+ 	const char *s;
+ 	int i = 0;
+ 	uint8_t *t = bin = xmalloc(((rpmtdSize(&td) / 2) + 1));
+@@ -1502,9 +1510,9 @@ static uint8_t *hex2binv(Header h, rpmTagVal tag, rpm_count_t num,
+ 	while ((s = rpmtdNextString(&td))) {
+ 	    uint32_t slen = strlen(s);
+ 	    uint32_t len = slen / 2;
+-	    if (slen % 2) {
+-		bin = rfree(bin);
+-		offs = rfree(offs);
++	    if (!rpmIsValidHex(s, slen)) {
++		bin = _free(bin);
++		offs = _free(offs);
+ 		goto exit;
+ 	    }
+ 	    offs[i] = t - bin;
+@@ -1514,11 +1522,13 @@ static uint8_t *hex2binv(Header h, rpmTagVal tag, rpm_count_t num,
+ 	}
+ 	offs[i] = t - bin;
+ 	*offsetp = offs;
++	rc = 0;
+     }
+ 
+ exit:
++    *binp = bin;
+     rpmtdFreeData(&td);
+-    return bin;
++    return rc;
+ }
+ 
+ /* Convert a tag of hex strings to binary presentation */
+@@ -1675,8 +1685,10 @@ static int rpmfilesPopulate(rpmfiles fi, Header h, rpmfiFlags flags)
+     fi->signatures = NULL;
+     /* grab hex signatures from header and store in binary format */
+     if (!(flags & RPMFI_NOFILESIGNATURES)) {
+-	fi->signatures = hex2binv(h, RPMTAG_FILESIGNATURES,
+-				 totalfc, &fi->signatureoffs);
++	if (hex2binv(h, RPMTAG_FILESIGNATURES,
++		     totalfc, &fi->signatureoffs, &fi->signatures)) {
++	    goto err;
++	}
+     }
+ 
+     fi->veritysigs = NULL;
+-- 
+2.56.1
+

diff --git a/0003-Tighten-up-tag-type-validation-on-header-load.patch b/0003-Tighten-up-tag-type-validation-on-header-load.patch
new file mode 100644
index 0000000..50fa082
--- /dev/null
+++ b/0003-Tighten-up-tag-type-validation-on-header-load.patch
@@ -0,0 +1,75 @@
+From 7aa1241404d5a430efdee7c8476a5c7055d8f7de Mon Sep 17 00:00:00 2001
+From: Panu Matilainen <pmatilai@redhat.com>
+Date: Tue, 13 Oct 2026 15:12:19 +0300
+Subject: [PATCH 3/3] Tighten up tag type validation on header load
+
+Commit 4254f68b39b7b44bb712442f742a7ff34cb88744 introduced this
+"tag types harmlessly disagree" comment in the code, and then commit
+db88f4806167caf69eda67f4f675551764304d78 further relaxed it to cover
+i18nstring as well. And now we have a CVE from that very thing, not
+so harmless afterall.
+
+Only allow known exceptions to pass through from now on:
+1) i18nstring tags can be plain strings
+2) scriptlet prog tags commonly differ due to leftover rpm < 4.0.3
+   compatibility code
+
+To avoid duplicating the tags and possibly missing something, add a
+special purpose function for looking them up from the scriptlet table.
+The low-level header code shouldn't really know about such things,
+but then the layering isn't even remotely clean to begin with, so this
+isn't any worse than what we already do.
+
+The code path used here just fails silently, but on package read (which
+is how normal person would encounter this), you'd get an error like:
+
+   error: evil.rpm: tag[52]: BAD, tag 5090 type 9 offset 1126 count 1 len 6
+
+This alone would have also prevented/fixed CVE-2026-103242.
+
+Related: CVE-2026-103242
+Related: #4346
+
+Backported from commit 184507c8f690085c5917347a2cfd9722bcd8ee94:
+- This is a minimal variant that only tightens the i18n string check
+  whereas the upstream version requires exact tags for the string/array
+  exception. Turns out that's too tight for some out-in-the-wild
+  packages.
+- Unlike upstream, we're testing against a crafted package so we get
+  an error like the one described in the commit message.
+---
+ lib/header.c | 11 ++++++++---
+ 1 file changed, 8 insertions(+), 3 deletions(-)
+
+diff --git a/lib/header.c b/lib/header.c
+index 99b4fd9f8..962b83634 100644
+--- a/lib/header.c
++++ b/lib/header.c
+@@ -200,6 +200,7 @@ void hdrblobDigestUpdate(rpmDigestBundle bundle, struct hdrblob_s *blob)
+ /* Check tag type matches our definition */
+ static int hdrchkTagType(uint32_t tag, uint32_t type)
+ {
++    /* Expected type */
+     rpmTagType t = rpmTagGetTagType(tag);
+     if (t == type)
+ 	return 0;
+@@ -208,9 +209,13 @@ static int hdrchkTagType(uint32_t tag, uint32_t type)
+     if (t == RPM_NULL_TYPE)
+ 	return 0;
+ 
+-    /* Some string tags harmlessly disagree on the exact type */
+-    if (rpmTagGetClass(tag) == RPM_STRING_CLASS &&
+-	    (rpmTagTypeGetClass(type) == RPM_STRING_CLASS))
++    /* Some string tags harmlessly disagree on array vs non-array */
++    if ((t == RPM_STRING_ARRAY_TYPE && type == RPM_STRING_TYPE) ||
++	    (type == RPM_STRING_ARRAY_TYPE && t == RPM_STRING_TYPE))
++	return 0;
++
++    /* Some old packages have string type on i18nstring tags */
++    if (t == RPM_I18NSTRING_TYPE && type == RPM_STRING_TYPE)
+ 	return 0;
+ 
+     /* Known tag with mismatching type, bad bad bad. */
+-- 
+2.56.1
+

diff --git a/rpm.spec b/rpm.spec
index a33ccf2..78d277d 100644
--- a/rpm.spec
+++ b/rpm.spec
@@ -27,7 +27,7 @@
 
 %global rpmver 4.19.1.1
 #global snapver rc1
-%global baserelease 29
+%global baserelease 30
 %global sover 10
 
 %global srcver %{rpmver}%{?snapver:-%{snapver}}
@@ -194,6 +194,20 @@ rpm-4.19.x-improve-syslog.patch
 0005-Prevent-shell-injection-via-RubyGem-filenames.patch
 0001-Fix-rpopen-rpclose-and-make-them-more-POSIXy.patch
 
+# CVE-2026-95520
+0001-Sanity-check-symlink-info-while-iterating-an-archive.patch
+
+# CVE-2026-103242
+0001-Make-the-hex-validator-helper-function-internally-av.patch
+0002-Harden-file-signature-data-population-in-the-rpmfile.patch
+0003-Tighten-up-tag-type-validation-on-header-load.patch
+
+# CVE-2026-95521
+0001-Prevent-command-injection-via-spec-source-basename.patch
+
+# CVE-2026-95519
+0001-Remove-macro-expansion-from-manifest-parsing.patch
+
 # These are not yet upstream
 rpm-4.7.1-geode-i686.patch
 
@@ -684,6 +698,12 @@ fi
 %doc %{_defaultdocdir}/rpm/API/
 
 %changelog
+* Fri Nov 20 2026 Michal Domonkos <mdomonko@redhat.com> - 4.19.1.1-30
+- CVE-2026-95519: Remove macro expansion from manifest parsing (RHEL-288159)
+- CVE-2026-95520: Sanity check symlink info while iterating an archive (RHEL-287862)
+- CVE-2026-95521: Prevent command injection via spec/source basename (RHEL-287861)
+- CVE-2026-103242: Harden file signature data population in the rpmfiles API (RHEL-273514)
+
 * Mon Nov 09 2026 Michal Domonkos <mdomonko@redhat.com> - 4.19.1.1-29
 - Fix rpopen()/rpclose() and make them more POSIXy (RHEL-288156)
 

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2026-12-01 13:48 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-12-01 13:48 [rpms/python3-rpm] epel10: Fix some more CVEs Michal Domonkos

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox