diff options
| author | Shubham Kulkarni <skulkarni@mvista.com> | 2023-04-18 17:24:23 +0530 |
|---|---|---|
| committer | Steve Sakoman <steve@sakoman.com> | 2023-04-26 04:03:21 -1000 |
| commit | 82be2c179a235e66f30eab58232e9384c087157e (patch) | |
| tree | 1fbd4c8afb2f40a6a767438fe5c0d165bbfc0ff8 | |
| parent | d8ff3c3fb31b7fb8b6a003fef899aa3dceab2491 (diff) | |
| download | poky-82be2c179a235e66f30eab58232e9384c087157e.tar.gz | |
go-runtime: Security fix for CVE-2022-41722
path/filepath: do not Clean("a/../c:/b") into c:\b on Windows
Backport from https://github.com/golang/go/commit/bdf07c2e168baf736e4c057279ca12a4d674f18c
(From OE-Core rev: f60637b3c9045656047d6ffcfaadbef5ad1d3d06)
Signed-off-by: Shubham Kulkarni <skulkarni@mvista.com>
Signed-off-by: Steve Sakoman <steve@sakoman.com>
| -rw-r--r-- | meta/recipes-devtools/go/go-1.17.13.inc | 1 | ||||
| -rw-r--r-- | meta/recipes-devtools/go/go-1.18/CVE-2022-41722.patch | 103 |
2 files changed, 104 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 23380f04c3..15d19ed124 100644 --- a/meta/recipes-devtools/go/go-1.17.13.inc +++ b/meta/recipes-devtools/go/go-1.17.13.inc | |||
| @@ -26,6 +26,7 @@ SRC_URI += "\ | |||
| 26 | file://cve-2022-41724.patch \ | 26 | file://cve-2022-41724.patch \ |
| 27 | file://add_godebug.patch \ | 27 | file://add_godebug.patch \ |
| 28 | file://cve-2022-41725.patch \ | 28 | file://cve-2022-41725.patch \ |
| 29 | file://CVE-2022-41722.patch \ | ||
| 29 | " | 30 | " |
| 30 | SRC_URI[main.sha256sum] = "a1a48b23afb206f95e7bbaa9b898d965f90826f6f1d1fc0c1d784ada0cd300fd" | 31 | SRC_URI[main.sha256sum] = "a1a48b23afb206f95e7bbaa9b898d965f90826f6f1d1fc0c1d784ada0cd300fd" |
| 31 | 32 | ||
diff --git a/meta/recipes-devtools/go/go-1.18/CVE-2022-41722.patch b/meta/recipes-devtools/go/go-1.18/CVE-2022-41722.patch new file mode 100644 index 0000000000..426a4f925f --- /dev/null +++ b/meta/recipes-devtools/go/go-1.18/CVE-2022-41722.patch | |||
| @@ -0,0 +1,103 @@ | |||
| 1 | From a826b19625caebed6dd0f3fbd9d0111f6c83737c Mon Sep 17 00:00:00 2001 | ||
| 2 | From: Damien Neil <dneil@google.com> | ||
| 3 | Date: Mon, 12 Dec 2022 16:43:37 -0800 | ||
| 4 | Subject: [PATCH] path/filepath: do not Clean("a/../c:/b") into c:\b on Windows | ||
| 5 | |||
| 6 | Do not permit Clean to convert a relative path into one starting | ||
| 7 | with a drive reference. This change causes Clean to insert a . | ||
| 8 | path element at the start of a path when the original path does not | ||
| 9 | start with a volume name, and the first path element would contain | ||
| 10 | a colon. | ||
| 11 | |||
| 12 | This may introduce a spurious but harmless . path element under | ||
| 13 | some circumstances. For example, Clean("a/../b:/../c") becomes `.\c`. | ||
| 14 | |||
| 15 | This reverts CL 401595, since the change here supersedes the one | ||
| 16 | in that CL. | ||
| 17 | |||
| 18 | Thanks to RyotaK (https://twitter.com/ryotkak) for reporting this issue. | ||
| 19 | |||
| 20 | Updates #57274 | ||
| 21 | Fixes #57276 | ||
| 22 | Fixes CVE-2022-41722 | ||
| 23 | |||
| 24 | Change-Id: I837446285a03aa74c79d7642720e01f354c2ca17 | ||
| 25 | Reviewed-on: https://team-review.git.corp.google.com/c/golang/go-private/+/1675249 | ||
| 26 | Reviewed-by: Roland Shoemaker <bracewell@google.com> | ||
| 27 | Run-TryBot: Damien Neil <dneil@google.com> | ||
| 28 | Reviewed-by: Julie Qiu <julieqiu@google.com> | ||
| 29 | TryBot-Result: Security TryBots <security-trybots@go-security-trybots.iam.gserviceaccount.com> | ||
| 30 | (cherry picked from commit 8ca37f4813ef2f64600c92b83f17c9f3ca6c03a5) | ||
| 31 | Reviewed-on: https://team-review.git.corp.google.com/c/golang/go-private/+/1728944 | ||
| 32 | Run-TryBot: Roland Shoemaker <bracewell@google.com> | ||
| 33 | Reviewed-by: Tatiana Bradley <tatianabradley@google.com> | ||
| 34 | Reviewed-by: Damien Neil <dneil@google.com> | ||
| 35 | Reviewed-on: https://go-review.googlesource.com/c/go/+/468119 | ||
| 36 | Reviewed-by: Than McIntosh <thanm@google.com> | ||
| 37 | Run-TryBot: Michael Pratt <mpratt@google.com> | ||
| 38 | TryBot-Result: Gopher Robot <gobot@golang.org> | ||
| 39 | Auto-Submit: Michael Pratt <mpratt@google.com> | ||
| 40 | |||
| 41 | CVE: CVE-2022-41722 | ||
| 42 | Upstream-Status: Backport from https://github.com/golang/go/commit/bdf07c2e168baf736e4c057279ca12a4d674f18 | ||
| 43 | Signed-off-by: Shubham Kulkarni <skulkarni@mvista.com> | ||
| 44 | --- | ||
| 45 | src/path/filepath/path.go | 27 ++++++++++++++------------- | ||
| 46 | 1 file changed, 14 insertions(+), 13 deletions(-) | ||
| 47 | |||
| 48 | diff --git a/src/path/filepath/path.go b/src/path/filepath/path.go | ||
| 49 | index 8300a32..94621a0 100644 | ||
| 50 | --- a/src/path/filepath/path.go | ||
| 51 | +++ b/src/path/filepath/path.go | ||
| 52 | @@ -15,6 +15,7 @@ import ( | ||
| 53 | "errors" | ||
| 54 | "io/fs" | ||
| 55 | "os" | ||
| 56 | + "runtime" | ||
| 57 | "sort" | ||
| 58 | "strings" | ||
| 59 | ) | ||
| 60 | @@ -117,21 +118,9 @@ func Clean(path string) string { | ||
| 61 | case os.IsPathSeparator(path[r]): | ||
| 62 | // empty path element | ||
| 63 | r++ | ||
| 64 | - case path[r] == '.' && r+1 == n: | ||
| 65 | + case path[r] == '.' && (r+1 == n || os.IsPathSeparator(path[r+1])): | ||
| 66 | // . element | ||
| 67 | r++ | ||
| 68 | - case path[r] == '.' && os.IsPathSeparator(path[r+1]): | ||
| 69 | - // ./ element | ||
| 70 | - r++ | ||
| 71 | - | ||
| 72 | - for r < len(path) && os.IsPathSeparator(path[r]) { | ||
| 73 | - r++ | ||
| 74 | - } | ||
| 75 | - if out.w == 0 && volumeNameLen(path[r:]) > 0 { | ||
| 76 | - // When joining prefix "." and an absolute path on Windows, | ||
| 77 | - // the prefix should not be removed. | ||
| 78 | - out.append('.') | ||
| 79 | - } | ||
| 80 | case path[r] == '.' && path[r+1] == '.' && (r+2 == n || os.IsPathSeparator(path[r+2])): | ||
| 81 | // .. element: remove to last separator | ||
| 82 | r += 2 | ||
| 83 | @@ -157,6 +146,18 @@ func Clean(path string) string { | ||
| 84 | if rooted && out.w != 1 || !rooted && out.w != 0 { | ||
| 85 | out.append(Separator) | ||
| 86 | } | ||
| 87 | + // If a ':' appears in the path element at the start of a Windows path, | ||
| 88 | + // insert a .\ at the beginning to avoid converting relative paths | ||
| 89 | + // like a/../c: into c:. | ||
| 90 | + if runtime.GOOS == "windows" && out.w == 0 && out.volLen == 0 && r != 0 { | ||
| 91 | + for i := r; i < n && !os.IsPathSeparator(path[i]); i++ { | ||
| 92 | + if path[i] == ':' { | ||
| 93 | + out.append('.') | ||
| 94 | + out.append(Separator) | ||
| 95 | + break | ||
| 96 | + } | ||
| 97 | + } | ||
| 98 | + } | ||
| 99 | // copy element | ||
| 100 | for ; r < n && !os.IsPathSeparator(path[r]); r++ { | ||
| 101 | out.append(path[r]) | ||
| 102 | -- | ||
| 103 | 2.7.4 | ||
