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