diff options
-rw-r--r-- | meta/recipes-devtools/dpkg/dpkg/CVE-2025-6297.patch | 125 | ||||
-rw-r--r-- | meta/recipes-devtools/dpkg/dpkg_1.21.4.bb | 1 |
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 @@ | |||
1 | From 98c623c8d6814ae46a3b30ca22e584c77d47d86b 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 | CVE: CVE-2025-6297 | ||
40 | Upstream-Status: Backport [https://git.dpkg.org/cgit/dpkg/dpkg.git/commit/?id=98c623c8d6814ae46a3b30ca22e584c77d47d86b] | ||
41 | Signed-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 | |||
47 | diff --git a/src/at/deb-content.at b/src/at/deb-content.at | ||
48 | index 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 | ||
87 | diff --git a/src/deb/info.c b/src/deb/info.c | ||
88 | index 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.21.4.bb b/meta/recipes-devtools/dpkg/dpkg_1.21.4.bb index 7ef6233ee4..27e835a288 100644 --- a/meta/recipes-devtools/dpkg/dpkg_1.21.4.bb +++ b/meta/recipes-devtools/dpkg/dpkg_1.21.4.bb | |||
@@ -15,6 +15,7 @@ SRC_URI = "git://salsa.debian.org/dpkg-team/dpkg.git;protocol=https;branch=main | |||
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://0001-Dpkg-Source-Archive-Prevent-directory-traversal-for-.patch \ | 17 | file://0001-Dpkg-Source-Archive-Prevent-directory-traversal-for-.patch \ |
18 | file://CVE-2025-6297.patch \ | ||
18 | " | 19 | " |
19 | 20 | ||
20 | SRC_URI:append:class-native = " file://0001-build.c-ignore-return-of-1-from-tar-cf.patch" | 21 | SRC_URI:append:class-native = " file://0001-build.c-ignore-return-of-1-from-tar-cf.patch" |