diff options
| author | Sakib Sajal <sakib.sajal@windriver.com> | 2023-05-24 01:28:53 -0400 |
|---|---|---|
| committer | Steve Sakoman <steve@sakoman.com> | 2023-05-30 04:11:15 -1000 |
| commit | 8af917d5727e0f9c6a0d10060b61168a5cce1a2b (patch) | |
| tree | 4c01ce22f93919b6a17fba49fe4185a972febca6 /meta/recipes-devtools/go | |
| parent | f72863d66e8d4588f53253283e50fb474afa2ebb (diff) | |
| download | poky-8af917d5727e0f9c6a0d10060b61168a5cce1a2b.tar.gz | |
go: fix CVE-2023-24540
References:
https://nvd.nist.gov/vuln/detail/CVE-2023-24540
Upstream patch:
https://github.com/golang/go/commit/ce7bd33345416e6d8cac901792060591cafc2797 (go 1.19.9)
(From OE-Core rev: 5defed7d5dc8bc6f68f021d19c4f42832d33472b)
Signed-off-by: Sakib Sajal <sakib.sajal@windriver.com>
Signed-off-by: Steve Sakoman <steve@sakoman.com>
Diffstat (limited to 'meta/recipes-devtools/go')
| -rw-r--r-- | meta/recipes-devtools/go/go-1.17.13.inc | 1 | ||||
| -rw-r--r-- | meta/recipes-devtools/go/go-1.19/CVE-2023-24540.patch | 93 |
2 files changed, 94 insertions, 0 deletions
diff --git a/meta/recipes-devtools/go/go-1.17.13.inc b/meta/recipes-devtools/go/go-1.17.13.inc index d7cb47ebf4..e5e9d841c4 100644 --- a/meta/recipes-devtools/go/go-1.17.13.inc +++ b/meta/recipes-devtools/go/go-1.17.13.inc | |||
| @@ -30,6 +30,7 @@ SRC_URI += "\ | |||
| 30 | file://CVE-2023-24537.patch \ | 30 | file://CVE-2023-24537.patch \ |
| 31 | file://CVE-2023-24534.patch \ | 31 | file://CVE-2023-24534.patch \ |
| 32 | file://CVE-2023-24538.patch \ | 32 | file://CVE-2023-24538.patch \ |
| 33 | file://CVE-2023-24540.patch \ | ||
| 33 | " | 34 | " |
| 34 | SRC_URI[main.sha256sum] = "a1a48b23afb206f95e7bbaa9b898d965f90826f6f1d1fc0c1d784ada0cd300fd" | 35 | SRC_URI[main.sha256sum] = "a1a48b23afb206f95e7bbaa9b898d965f90826f6f1d1fc0c1d784ada0cd300fd" |
| 35 | 36 | ||
diff --git a/meta/recipes-devtools/go/go-1.19/CVE-2023-24540.patch b/meta/recipes-devtools/go/go-1.19/CVE-2023-24540.patch new file mode 100644 index 0000000000..7e6e871e38 --- /dev/null +++ b/meta/recipes-devtools/go/go-1.19/CVE-2023-24540.patch | |||
| @@ -0,0 +1,93 @@ | |||
| 1 | From 2305cdb2aa5ac8e9960bd64e548a119c7dd87530 Mon Sep 17 00:00:00 2001 | ||
| 2 | From: Roland Shoemaker <bracewell@google.com> | ||
| 3 | Date: Tue, 11 Apr 2023 16:27:43 +0100 | ||
| 4 | Subject: [PATCH] html/template: handle all JS whitespace characters | ||
| 5 | |||
| 6 | Rather than just a small set. Character class as defined by \s [0]. | ||
| 7 | |||
| 8 | Thanks to Juho Nurminen of Mattermost for reporting this. | ||
| 9 | |||
| 10 | For #59721 | ||
| 11 | Fixes #59813 | ||
| 12 | Fixes CVE-2023-24540 | ||
| 13 | |||
| 14 | [0] https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions/Character_Classes | ||
| 15 | |||
| 16 | Change-Id: I56d4fa1ef08125b417106ee7dbfb5b0923b901ba | ||
| 17 | Reviewed-on: https://team-review.git.corp.google.com/c/golang/go-private/+/1821459 | ||
| 18 | Reviewed-by: Julie Qiu <julieqiu@google.com> | ||
| 19 | Run-TryBot: Roland Shoemaker <bracewell@google.com> | ||
| 20 | Reviewed-by: Damien Neil <dneil@google.com> | ||
| 21 | Reviewed-on: https://team-review.git.corp.google.com/c/golang/go-private/+/1851497 | ||
| 22 | Run-TryBot: Damien Neil <dneil@google.com> | ||
| 23 | Reviewed-by: Roland Shoemaker <bracewell@google.com> | ||
| 24 | Reviewed-on: https://go-review.googlesource.com/c/go/+/491355 | ||
| 25 | Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> | ||
| 26 | Reviewed-by: Carlos Amedee <carlos@golang.org> | ||
| 27 | TryBot-Bypass: Carlos Amedee <carlos@golang.org> | ||
| 28 | Run-TryBot: Carlos Amedee <carlos@golang.org> | ||
| 29 | |||
| 30 | CVE: CVE-2023-24540 | ||
| 31 | Upstream-Status: Backport [https://github.com/golang/go/commit/ce7bd33345416e6d8cac901792060591cafc2797] | ||
| 32 | |||
| 33 | Signed-off-by: Sakib Sajal <sakib.sajal@windriver.com> | ||
| 34 | --- | ||
| 35 | src/html/template/js.go | 8 +++++++- | ||
| 36 | src/html/template/js_test.go | 11 +++++++---- | ||
| 37 | 2 files changed, 14 insertions(+), 5 deletions(-) | ||
| 38 | |||
| 39 | diff --git a/src/html/template/js.go b/src/html/template/js.go | ||
| 40 | index b888eaf..35994f0 100644 | ||
| 41 | --- a/src/html/template/js.go | ||
| 42 | +++ b/src/html/template/js.go | ||
| 43 | @@ -13,6 +13,11 @@ import ( | ||
| 44 | "unicode/utf8" | ||
| 45 | ) | ||
| 46 | |||
| 47 | +// jsWhitespace contains all of the JS whitespace characters, as defined | ||
| 48 | +// by the \s character class. | ||
| 49 | +// See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_expressions/Character_classes. | ||
| 50 | +const jsWhitespace = "\f\n\r\t\v\u0020\u00a0\u1680\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u2028\u2029\u202f\u205f\u3000\ufeff" | ||
| 51 | + | ||
| 52 | // nextJSCtx returns the context that determines whether a slash after the | ||
| 53 | // given run of tokens starts a regular expression instead of a division | ||
| 54 | // operator: / or /=. | ||
| 55 | @@ -26,7 +31,8 @@ import ( | ||
| 56 | // JavaScript 2.0 lexical grammar and requires one token of lookbehind: | ||
| 57 | // https://www.mozilla.org/js/language/js20-2000-07/rationale/syntax.html | ||
| 58 | func nextJSCtx(s []byte, preceding jsCtx) jsCtx { | ||
| 59 | - s = bytes.TrimRight(s, "\t\n\f\r \u2028\u2029") | ||
| 60 | + // Trim all JS whitespace characters | ||
| 61 | + s = bytes.TrimRight(s, jsWhitespace) | ||
| 62 | if len(s) == 0 { | ||
| 63 | return preceding | ||
| 64 | } | ||
| 65 | diff --git a/src/html/template/js_test.go b/src/html/template/js_test.go | ||
| 66 | index d7ee47b..8f5d76d 100644 | ||
| 67 | --- a/src/html/template/js_test.go | ||
| 68 | +++ b/src/html/template/js_test.go | ||
| 69 | @@ -81,14 +81,17 @@ func TestNextJsCtx(t *testing.T) { | ||
| 70 | {jsCtxDivOp, "0"}, | ||
| 71 | // Dots that are part of a number are div preceders. | ||
| 72 | {jsCtxDivOp, "0."}, | ||
| 73 | + // Some JS interpreters treat NBSP as a normal space, so | ||
| 74 | + // we must too in order to properly escape things. | ||
| 75 | + {jsCtxRegexp, "=\u00A0"}, | ||
| 76 | } | ||
| 77 | |||
| 78 | for _, test := range tests { | ||
| 79 | - if nextJSCtx([]byte(test.s), jsCtxRegexp) != test.jsCtx { | ||
| 80 | - t.Errorf("want %s got %q", test.jsCtx, test.s) | ||
| 81 | + if ctx := nextJSCtx([]byte(test.s), jsCtxRegexp); ctx != test.jsCtx { | ||
| 82 | + t.Errorf("%q: want %s got %s", test.s, test.jsCtx, ctx) | ||
| 83 | } | ||
| 84 | - if nextJSCtx([]byte(test.s), jsCtxDivOp) != test.jsCtx { | ||
| 85 | - t.Errorf("want %s got %q", test.jsCtx, test.s) | ||
| 86 | + if ctx := nextJSCtx([]byte(test.s), jsCtxDivOp); ctx != test.jsCtx { | ||
| 87 | + t.Errorf("%q: want %s got %s", test.s, test.jsCtx, ctx) | ||
| 88 | } | ||
| 89 | } | ||
| 90 | |||
| 91 | -- | ||
| 92 | 2.40.0 | ||
| 93 | |||
