platform/upstream/xz.git
2 years ago[CVE-2022-1271] xzgrep: Fix escaping of malicious filenames (ZDI-CAN-16587). 54/275254/1 accepted/tizen_6.0_base accepted/tizen_6.0_base_tool tizen_6.0_base accepted/tizen/6.0/base/20230713.143122 accepted/tizen/6.0/base/tool/20220530.211613 submit/tizen_6.0_base/20220527.053338
Lasse Collin [Tue, 29 Mar 2022 16:19:12 +0000 (19:19 +0300)]
[CVE-2022-1271] xzgrep: Fix escaping of malicious filenames (ZDI-CAN-16587).

Malicious filenames can make xzgrep to write to arbitrary files
or (with a GNU sed extension) lead to arbitrary code execution.

xzgrep from XZ Utils versions up to and including 5.2.5 are
affected. 5.3.1alpha and 5.3.2alpha are affected as well.
This patch works for all of them.

This bug was inherited from gzip's zgrep. gzip 1.12 includes
a fix for zgrep.

The issue with the old sed script is that with multiple newlines,
the N-command will read the second line of input, then the
s-commands will be skipped because it's not the end of the
file yet, then a new sed cycle starts and the pattern space
is printed and emptied. So only the last line or two get escaped.

One way to fix this would be to read all lines into the pattern
space first. However, the included fix is even simpler: All lines
except the last line get a backslash appended at the end. To ensure
that shell command substitution doesn't eat a possible trailing
newline, a colon is appended to the filename before escaping.
The colon is later used to separate the filename from the grep
output so it is fine to add it here instead of a few lines later.

The old code also wasn't POSIX compliant as it used \n in the
replacement section of the s-command. Using \<newline> is the
POSIX compatible method.

LC_ALL=C was added to the two critical sed commands. POSIX sed
manual recommends it when using sed to manipulate pathnames
because in other locales invalid multibyte sequences might
cause issues with some sed implementations. In case of GNU sed,
these particular sed scripts wouldn't have such problems but some
other scripts could have, see:

    info '(sed)Locale Considerations'

This vulnerability was discovered by:
cleemy desu wayo working with Trend Micro Zero Day Initiative

Thanks to Jim Meyering and Paul Eggert discussing the different
ways to fix this and for coordinating the patch release schedule
with gzip.

Change-Id: If46f37ac612bb2f870575cd1f3a9a85a5aa19955

5 years agoBumpt to xz 5.2.4 accepted/tizen_5.5_base accepted/tizen_5.5_base_mobile_hotfix accepted/tizen_5.5_base_wearable_hotfix accepted/tizen_6.0_base_tool_hotfix sandbox/dh0128.kwak/xz_5.2.4 tizen_5.5_base tizen_5.5_base_mobile_hotfix tizen_5.5_base_wearable_hotfix tizen_5.5_tv tizen_6.0_base_hotfix accepted/tizen/5.5/base/20191030.084517 accepted/tizen/5.5/base/mobile/hotfix/20201023.084017 accepted/tizen/5.5/base/wearable/hotfix/20201023.080407 accepted/tizen/6.0/base/20201029.105953 accepted/tizen/6.0/base/tool/20201029.111651 accepted/tizen/6.0/base/tool/hotfix/20201030.124456 accepted/tizen/6.0/base/tool/hotfix/20201102.085613 accepted/tizen/base/20181214.154430 submit/tizen_5.5_base/20191030.000001 submit/tizen_5.5_base_mobile_hotfix/20201023.171502 submit/tizen_5.5_base_wearable_hotfix/20201023.155602 submit/tizen_6.0_base/20201029.184802 submit/tizen_6.0_base_hotfix/20201030.192502 submit/tizen_6.0_base_hotfix/20201102.162702 submit/tizen_base/20181211.024740 tizen_5.5.m2_release tizen_6.0.m2_release
DongHun Kwak [Tue, 11 Dec 2018 02:43:02 +0000 (11:43 +0900)]
Bumpt to xz 5.2.4

[Model] All
[BinType] AP
[Customer] OPEN

[Issue#] N/A
[Request] N/A
[Occurrence Version] N/A

[Problem] version upgrade
[Cause & Measure]
[Checking Method] unit test

[Team] Open Source Management and Setting Part
[Developer] dh0128.kwak
[Solution company] Samsung
[Change Type] N/A

Change-Id: Ic2fa2e2a01f56f061c879dc5f212a4e0bc30aa2c
Signed-off-by: DongHun Kwak <dh0128.kwak@samsung.com>
5 years agoImported Upstream version 5.2.4 93/194993/1 upstream/5.2.4
DongHun Kwak [Mon, 10 Dec 2018 05:49:46 +0000 (14:49 +0900)]
Imported Upstream version 5.2.4

Change-Id: If54561c5e3e6e0c690ff582ecc80c83e47a51620
Signed-off-by: DongHun Kwak <dh0128.kwak@samsung.com>
6 years agoImported Upstream version 5.2.3 34/156134/1 upstream/5.2.3
DongHun Kwak [Tue, 17 Oct 2017 08:02:33 +0000 (17:02 +0900)]
Imported Upstream version 5.2.3

Change-Id: I0d4f7e6bed916f0a66517783e9b86576fe9bad2c
Signed-off-by: DongHun Kwak <dh0128.kwak@samsung.com>
7 years agoImported Upstream version 5.2.2 64/90064/1 upstream/5.2.2
DongHun Kwak [Wed, 28 Sep 2016 07:11:03 +0000 (16:11 +0900)]
Imported Upstream version 5.2.2

Change-Id: I88a4923ca5d7e7376cdf28e5b50ec629bebc7e6e
Signed-off-by: DongHun Kwak <dh0128.kwak@samsung.com>
7 years agoImported Upstream version 5.2.1 63/90063/1 upstream/5.2.1
DongHun Kwak [Wed, 28 Sep 2016 07:10:54 +0000 (16:10 +0900)]
Imported Upstream version 5.2.1

Change-Id: Ib9a5b6f2b2169823ee4154e5bac32dca1711c7f5
Signed-off-by: DongHun Kwak <dh0128.kwak@samsung.com>
7 years agoImported Upstream version 5.2.0 62/90062/1 upstream/5.2.0
DongHun Kwak [Wed, 28 Sep 2016 07:10:38 +0000 (16:10 +0900)]
Imported Upstream version 5.2.0

Change-Id: I8ba25644e4924c6481ef136bb40b087aef258c90
Signed-off-by: DongHun Kwak <dh0128.kwak@samsung.com>
7 years agoImported Upstream version 5.0.8 61/90061/1 upstream/5.0.8
DongHun Kwak [Wed, 28 Sep 2016 07:10:15 +0000 (16:10 +0900)]
Imported Upstream version 5.0.8

Change-Id: I35401a73fbf62236e0dbaeed21ee8596e186eca5
Signed-off-by: DongHun Kwak <dh0128.kwak@samsung.com>
7 years agoImported Upstream version 5.0.7 60/90060/1 upstream/5.0.7
DongHun Kwak [Wed, 28 Sep 2016 07:09:58 +0000 (16:09 +0900)]
Imported Upstream version 5.0.7

Change-Id: I69ed1329569e6445c0f418dad1a6f5b30a271204
Signed-off-by: DongHun Kwak <dh0128.kwak@samsung.com>
7 years agoImported Upstream version 5.0.6 59/90059/1 upstream/5.0.6
DongHun Kwak [Wed, 28 Sep 2016 07:09:41 +0000 (16:09 +0900)]
Imported Upstream version 5.0.6

Change-Id: I3397dc23ca85461efb248651e2e61103b5c74bab
Signed-off-by: DongHun Kwak <dh0128.kwak@samsung.com>
7 years agoImported Upstream version 5.0.5 58/90058/1 upstream/5.0.5
DongHun Kwak [Wed, 28 Sep 2016 07:09:25 +0000 (16:09 +0900)]
Imported Upstream version 5.0.5

Change-Id: I59da8ecd5b96e30004e93969fd82bd0bfe69162b
Signed-off-by: DongHun Kwak <dh0128.kwak@samsung.com>
7 years agoImported Upstream version 5.0.4 57/90057/1 upstream/5.0.4
DongHun Kwak [Wed, 28 Sep 2016 07:09:07 +0000 (16:09 +0900)]
Imported Upstream version 5.0.4

Change-Id: I282c2dd20ebb91b2ae626ca1071c18561f2238f8
Signed-off-by: DongHun Kwak <dh0128.kwak@samsung.com>
11 years agoImported Upstream version 5.0.3 upstream/5.0.3
Anas Nashif [Wed, 7 Nov 2012 05:10:45 +0000 (21:10 -0800)]
Imported Upstream version 5.0.3