summaryrefslogtreecommitdiffstats
path: root/meta
diff options
context:
space:
mode:
authorPeter Marko <peter.marko@siemens.com>2025-08-24 22:19:31 +0200
committerSteve Sakoman <steve@sakoman.com>2025-09-01 08:30:56 -0700
commitbf7f8a0202e318e6208d90b9c15c408141bbb011 (patch)
tree85b274c3ba84c9f54a95c609c9cc0784fbbe2f77 /meta
parent3270b1284ece4dbc99a72627c0c45cdc9ac79313 (diff)
downloadpoky-bf7f8a0202e318e6208d90b9c15c408141bbb011.tar.gz
dpkg: patch CVE-2025-6297
Pick commit per [1] from 1.22.x branch. [1] https://nvd.nist.gov/vuln/detail/CVE-2025-6297 (From OE-Core rev: 859e5a47744a91b40d5d12c46ff4d8657ef5cf6e) Signed-off-by: Peter Marko <peter.marko@siemens.com> Signed-off-by: Steve Sakoman <steve@sakoman.com>
Diffstat (limited to 'meta')
-rw-r--r--meta/recipes-devtools/dpkg/dpkg/CVE-2025-6297.patch125
-rw-r--r--meta/recipes-devtools/dpkg/dpkg_1.22.0.bb1
2 files changed, 126 insertions, 0 deletions
diff --git a/meta/recipes-devtools/dpkg/dpkg/CVE-2025-6297.patch b/meta/recipes-devtools/dpkg/dpkg/CVE-2025-6297.patch
new file mode 100644
index 0000000000..537f77643b
--- /dev/null
+++ b/meta/recipes-devtools/dpkg/dpkg/CVE-2025-6297.patch
@@ -0,0 +1,125 @@
1From 98c623c8d6814ae46a3b30ca22e584c77d47d86b Mon Sep 17 00:00:00 2001
2From: Guillem Jover <guillem@debian.org>
3Date: Sat, 7 Jun 2025 14:17:07 +0200
4Subject: [PATCH] dpkg-deb: Fix cleanup for control member with restricted
5 directories
6MIME-Version: 1.0
7Content-Type: text/plain; charset=UTF-8
8Content-Transfer-Encoding: 8bit
9
10When extracting a control member into a temporary directory, which is
11documented as being a safe operation even on untrusted data, the code
12in charge of the temporary directory cleanup does not sanitize the
13directory permissions, which is then unable to perform the «rm -rf»
14when running as a non-root user, leaving temporary files behind.
15
16Given automated and repeated execution of dpkg-deb commands on
17adversarial .deb packages or with well compressible files, placed
18inside a directory with permissions not allowing removal by a non-root
19user, this can end up with a DoS scenario due to causing disk quota
20exhaustion or disk full conditions.
21
22This is considered a minor issue, given the required conditions to
23trigger a problem with it, but an issue non the less given the
24documented security guarantees of the command. This has been an
25issue since the initial commit introducing dpkg-deb in C.
26
27We use an existing string for the error message to avoid new strings
28needing translation for stable branches, which make the error message
29less descriptive than what would be ideal. This will be improved in
30git HEAD.
31
32Reported-by: zhutyra on HackerOne
33Fixes: CVE-2025-6297
34Stable-Candidate: 1.20.x 1.21.x 1.22.x
35(cherry picked from commit ed6bbd445dd8800308c67236ba35d08004c98e82)
36(cherry picked from commit 02ad0532bd490cbc95b344f670e622a38eecfbf6)
37(cherry picked from commit d8a76551e22abe76eefd7fef5c7f51f4118eb40e)
38
39CVE: CVE-2025-6297
40Upstream-Status: Backport [https://git.dpkg.org/cgit/dpkg/dpkg.git/commit/?id=98c623c8d6814ae46a3b30ca22e584c77d47d86b]
41Signed-off-by: Peter Marko <peter.marko@siemens.com>
42---
43 src/at/deb-content.at | 32 ++++++++++++++++++++++++++++++++
44 src/deb/info.c | 20 ++++++++++++++++++++
45 2 files changed, 52 insertions(+)
46
47diff --git a/src/at/deb-content.at b/src/at/deb-content.at
48index a192c9493..d48eed72b 100644
49--- a/src/at/deb-content.at
50+++ b/src/at/deb-content.at
51@@ -127,3 +127,35 @@ newline'
52 ])
53
54 AT_CLEANUP
55+
56+AT_SETUP([dpkg-deb .deb extraction cleanup])
57+AT_KEYWORDS([dpkg-deb deb extraction])
58+
59+DPKG_GEN_CONTROL([pkg-ctrl-dir-perms])
60+AT_CHECK([
61+dpkg-deb --root-owner-group -Znone -b pkg-ctrl-dir-perms
62+DPKG_AR_EXTRACT([pkg-ctrl-dir-perms.deb])
63+dpkg-deb -R pkg-ctrl-dir-perms.deb pkg-ctrl-dir-perms-bad
64+mkdir -p pkg-ctrl-dir-perms-bad/DEBIAN/rx-subdir/inner
65+touch pkg-ctrl-dir-perms-bad/DEBIAN/rx-subdir/inner/file
66+chmod 0555 pkg-ctrl-dir-perms-bad/DEBIAN
67+chmod 0555 pkg-ctrl-dir-perms-bad/DEBIAN/rx-subdir
68+chmod 0555 pkg-ctrl-dir-perms-bad/DEBIAN/rx-subdir/inner
69+$TAR cf control.tar --format=gnu --sort=name --mtime @0 --clamp-mtime --owner root:0 --group root:0 -C pkg-ctrl-dir-perms-bad/DEBIAN .
70+DPKG_AR_GEN([pkg-ctrl-dir-perms.deb], [debian-binary control.tar data.tar])
71+], [0], [dpkg-deb: building package 'pkg-ctrl-dir-perms' in 'pkg-ctrl-dir-perms.deb'.
72+])
73+AT_CHECK([
74+dpkg-deb --ctrl-tarfile pkg-ctrl-dir-perms.deb | $TAR tvf -
75+], [0], [dr-xr-xr-x root/root 0 1970-01-01 00:00 ./
76+-rw-r--r-- root/root 176 1970-01-01 00:00 ./control
77+dr-xr-xr-x root/root 0 1970-01-01 00:00 ./rx-subdir/
78+dr-xr-xr-x root/root 0 1970-01-01 00:00 ./rx-subdir/inner/
79+-rw-r--r-- root/root 0 1970-01-01 00:00 ./rx-subdir/inner/file
80+])
81+# Check that we can cleanup the temporarily extracted control.tar member.
82+AT_CHECK([
83+dpkg-deb -I pkg-ctrl-dir-perms.deb
84+], [0], [ignore])
85+
86+AT_CLEANUP
87diff --git a/src/deb/info.c b/src/deb/info.c
88index f3d57e2ce..396ea4d14 100644
89--- a/src/deb/info.c
90+++ b/src/deb/info.c
91@@ -45,14 +45,34 @@
92 #include <dpkg/pkg-format.h>
93 #include <dpkg/buffer.h>
94 #include <dpkg/path.h>
95+#include <dpkg/treewalk.h>
96 #include <dpkg/options.h>
97
98 #include "dpkg-deb.h"
99
100+static int
101+cu_info_treewalk_fixup_dir(struct treenode *node)
102+{
103+ const char *nodename;
104+
105+ if (!S_ISDIR(treenode_get_mode(node)))
106+ return 0;
107+
108+ nodename = treenode_get_pathname(node);
109+ if (chmod(nodename, 0755) < 0)
110+ ohshite(_("error setting permissions of '%.255s'"), nodename);
111+
112+ return 0;
113+}
114+
115 static void cu_info_prepare(int argc, void **argv) {
116 char *dir;
117+ struct treewalk_funcs cu_info_treewalk_funcs = {
118+ .visit = cu_info_treewalk_fixup_dir,
119+ };
120
121 dir = argv[0];
122+ treewalk(dir, TREEWALK_NONE, &cu_info_treewalk_funcs);
123 path_remove_tree(dir);
124 free(dir);
125 }
diff --git a/meta/recipes-devtools/dpkg/dpkg_1.22.0.bb b/meta/recipes-devtools/dpkg/dpkg_1.22.0.bb
index 7eaae9f22e..41f5123508 100644
--- a/meta/recipes-devtools/dpkg/dpkg_1.22.0.bb
+++ b/meta/recipes-devtools/dpkg/dpkg_1.22.0.bb
@@ -14,6 +14,7 @@ SRC_URI = "git://salsa.debian.org/dpkg-team/dpkg.git;protocol=https;branch=main
14 file://0001-dpkg-Support-muslx32-build.patch \ 14 file://0001-dpkg-Support-muslx32-build.patch \
15 file://pager.patch \ 15 file://pager.patch \
16 file://0001-Add-support-for-riscv32-CPU.patch \ 16 file://0001-Add-support-for-riscv32-CPU.patch \
17 file://CVE-2025-6297.patch \
17 " 18 "
18 19
19SRC_URI:append:class-native = " file://0001-build.c-ignore-return-of-1-from-tar-cf.patch" 20SRC_URI:append:class-native = " file://0001-build.c-ignore-return-of-1-from-tar-cf.patch"