Gentoo Archives: gentoo-commits

From: "Mike Frysinger (vapier)" <vapier@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] gentoo-x86 commit in dev-libs/elfutils/files: elfutils-0.161-libelf-dir-traversal.patch
Date: Wed, 31 Dec 2014 08:26:00
Message-Id: 20141231082556.06ADEE8DE@oystercatcher.gentoo.org
1 vapier 14/12/31 08:25:56
2
3 Added: elfutils-0.161-libelf-dir-traversal.patch
4 Log:
5 Version bump and libelf directory traversal fix from upstream #534000 by Agostino Sarubbo.
6
7 (Portage version: 2.2.15/cvs/Linux x86_64, signed Manifest commit with key D2E96200)
8
9 Revision Changes Path
10 1.1 dev-libs/elfutils/files/elfutils-0.161-libelf-dir-traversal.patch
11
12 file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/dev-libs/elfutils/files/elfutils-0.161-libelf-dir-traversal.patch?rev=1.1&view=markup
13 plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/dev-libs/elfutils/files/elfutils-0.161-libelf-dir-traversal.patch?rev=1.1&content-type=text/plain
14
15 Index: elfutils-0.161-libelf-dir-traversal.patch
16 ===================================================================
17 https://bugs.gentoo.org/534000
18
19 From 147018e729e7c22eeabf15b82d26e4bf68a0d18e Mon Sep 17 00:00:00 2001
20 From: Alexander Cherepanov <cherepan@×××××.ru>
21 Date: Sun, 28 Dec 2014 19:57:19 +0300
22 Subject: [PATCH] libelf: Fix dir traversal vuln in ar extraction.
23
24 read_long_names terminates names at the first '/' found but then skips
25 one character without checking (it's supposed to be '\n'). Hence the
26 next name could start with any character including '/'. This leads to
27 a directory traversal vulnerability at the time the contents of the
28 archive is extracted.
29
30 The danger is mitigated by the fact that only one '/' is possible in a
31 resulting filename and only in the leading position. Hence only files
32 in the root directory can be written via this vuln and only when ar is
33 executed as root.
34
35 The fix for the vuln is to not skip any characters while looking
36 for '/'.
37
38 Signed-off-by: Alexander Cherepanov <cherepan@×××××.ru>
39 ---
40 libelf/ChangeLog | 5 +++++
41 libelf/elf_begin.c | 5 +----
42 2 files changed, 6 insertions(+), 4 deletions(-)
43
44 2014-12-28 Alexander Cherepanov <cherepan@×××××.ru>
45
46 * elf_begin.c (read_long_names): Don't miss '/' right after
47 another '/'. Fixes a dir traversal vuln in ar extraction.
48
49 diff --git a/libelf/elf_begin.c b/libelf/elf_begin.c
50 index 30abe0b..cd3756c 100644
51 --- a/libelf/elf_begin.c
52 +++ b/libelf/elf_begin.c
53 @@ -749,10 +749,7 @@ read_long_names (Elf *elf)
54 }
55
56 /* NUL-terminate the string. */
57 - *runp = '\0';
58 -
59 - /* Skip the NUL byte and the \012. */
60 - runp += 2;
61 + *runp++ = '\0';
62
63 /* A sanity check. Somebody might have generated invalid
64 archive. */
65 --
66 2.2.1