diff options
-rw-r--r-- | meta/recipes-devtools/git/git.inc | 4 | ||||
-rw-r--r-- | meta/recipes-devtools/git/git/CVE-2020-5260.patch | 65 |
2 files changed, 68 insertions, 1 deletions
diff --git a/meta/recipes-devtools/git/git.inc b/meta/recipes-devtools/git/git.inc index 6e137432f0..176423e972 100644 --- a/meta/recipes-devtools/git/git.inc +++ b/meta/recipes-devtools/git/git.inc | |||
@@ -7,7 +7,9 @@ DEPENDS = "openssl curl zlib expat" | |||
7 | PROVIDES_append_class-native = " git-replacement-native" | 7 | PROVIDES_append_class-native = " git-replacement-native" |
8 | 8 | ||
9 | SRC_URI = "${KERNELORG_MIRROR}/software/scm/git/git-${PV}.tar.gz;name=tarball \ | 9 | SRC_URI = "${KERNELORG_MIRROR}/software/scm/git/git-${PV}.tar.gz;name=tarball \ |
10 | ${KERNELORG_MIRROR}/software/scm/git/git-manpages-${PV}.tar.gz;name=manpages" | 10 | ${KERNELORG_MIRROR}/software/scm/git/git-manpages-${PV}.tar.gz;name=manpages \ |
11 | file://CVE-2020-5260.patch \ | ||
12 | " | ||
11 | 13 | ||
12 | S = "${WORKDIR}/git-${PV}" | 14 | S = "${WORKDIR}/git-${PV}" |
13 | 15 | ||
diff --git a/meta/recipes-devtools/git/git/CVE-2020-5260.patch b/meta/recipes-devtools/git/git/CVE-2020-5260.patch new file mode 100644 index 0000000000..d03e701a8f --- /dev/null +++ b/meta/recipes-devtools/git/git/CVE-2020-5260.patch | |||
@@ -0,0 +1,65 @@ | |||
1 | From 9a6bbee8006c24b46a85d29e7b38cfa79e9ab21b Mon Sep 17 00:00:00 2001 | ||
2 | From: Jeff King <peff@peff.net> | ||
3 | Date: Wed, 11 Mar 2020 17:53:41 -0400 | ||
4 | Subject: [PATCH] credential: avoid writing values with newlines | ||
5 | |||
6 | The credential protocol that we use to speak to helpers can't represent | ||
7 | values with newlines in them. This was an intentional design choice to | ||
8 | keep the protocol simple, since none of the values we pass should | ||
9 | generally have newlines. | ||
10 | |||
11 | However, if we _do_ encounter a newline in a value, we blindly transmit | ||
12 | it in credential_write(). Such values may break the protocol syntax, or | ||
13 | worse, inject new valid lines into the protocol stream. | ||
14 | |||
15 | The most likely way for a newline to end up in a credential struct is by | ||
16 | decoding a URL with a percent-encoded newline. However, since the bug | ||
17 | occurs at the moment we write the value to the protocol, we'll catch it | ||
18 | there. That should leave no possibility of accidentally missing a code | ||
19 | path that can trigger the problem. | ||
20 | |||
21 | At this level of the code we have little choice but to die(). However, | ||
22 | since we'd not ever expect to see this case outside of a malicious URL, | ||
23 | that's an acceptable outcome. | ||
24 | |||
25 | Reported-by: Felix Wilhelm <fwilhelm@google.com> | ||
26 | |||
27 | Upstream-Status: Backport | ||
28 | CVE: CVE-2020-5260 | ||
29 | Signed-off-by: Li Zhou <li.zhou@windriver.com> | ||
30 | --- | ||
31 | credential.c | 2 ++ | ||
32 | t/t0300-credentials.sh | 6 ++++++ | ||
33 | 2 files changed, 8 insertions(+) | ||
34 | |||
35 | diff --git a/credential.c b/credential.c | ||
36 | index 9747f47..00ee4d6 100644 | ||
37 | --- a/credential.c | ||
38 | +++ b/credential.c | ||
39 | @@ -194,6 +194,8 @@ static void credential_write_item(FILE *fp, const char *key, const char *value) | ||
40 | { | ||
41 | if (!value) | ||
42 | return; | ||
43 | + if (strchr(value, '\n')) | ||
44 | + die("credential value for %s contains newline", key); | ||
45 | fprintf(fp, "%s=%s\n", key, value); | ||
46 | } | ||
47 | |||
48 | diff --git a/t/t0300-credentials.sh b/t/t0300-credentials.sh | ||
49 | index 03bd31e..15cc3c5 100755 | ||
50 | --- a/t/t0300-credentials.sh | ||
51 | +++ b/t/t0300-credentials.sh | ||
52 | @@ -309,4 +309,10 @@ test_expect_success 'empty helper spec resets helper list' ' | ||
53 | EOF | ||
54 | ' | ||
55 | |||
56 | +test_expect_success 'url parser rejects embedded newlines' ' | ||
57 | + test_must_fail git credential fill <<-\EOF | ||
58 | + url=https://one.example.com?%0ahost=two.example.com/ | ||
59 | + EOF | ||
60 | +' | ||
61 | + | ||
62 | test_done | ||
63 | -- | ||
64 | 1.9.1 | ||
65 | |||