diff options
| author | Neal Patel <nealpatel@google.com> | 2026-02-24 23:05:34 +0000 |
|---|---|---|
| committer | Gopher Robot <gobot@golang.org> | 2026-04-07 12:14:20 -0700 |
| commit | 096f21b1c50fe62bc54c1fb1ede60fca63239123 (patch) | |
| tree | 1f2a12c36785c55f13b439d092ea77b6e23d8b49 | |
| parent | 7cafb4140d5616f1a0316a194a977b0794cd7d7c (diff) | |
| download | go-096f21b1c50fe62bc54c1fb1ede60fca63239123.tar.xz | |
[release-branch.go1.26] cmd/go: disallow cgo trust boundary bypass
The cgo compiler implicitly trusts generated files
with 'cgo' prefixes; thus, SWIG files containing 'cgo'
in their names will cause bypass of the trust boundary,
leading to code smuggling or arbitrary code execution.
The cgo compiler will now produce an error if it
encounters any SWIG files containing this prefix.
Thanks to Juho Forsén of Mattermost for reporting this issue.
Fixes #78335
Fixes CVE-2026-27140
Change-Id: I44185a84e07739b3b347efdb86be7d8fa560b030
Reviewed-on: https://go-internal-review.googlesource.com/c/go/+/3520
Reviewed-by: Nicholas Husin <husin@google.com>
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-on: https://go-internal-review.googlesource.com/c/go/+/4021
Commit-Queue: Damien Neil <dneil@google.com>
Reviewed-by: Neal Patel <nealpatel@google.com>
Reviewed-on: https://go-review.googlesource.com/c/go/+/763549
TryBot-Bypass: Gopher Robot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
Auto-Submit: Gopher Robot <gobot@golang.org>
Reviewed-by: Junyang Shao <shaojunyang@google.com>
| -rw-r--r-- | src/cmd/go/internal/work/exec.go | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/src/cmd/go/internal/work/exec.go b/src/cmd/go/internal/work/exec.go index 8e30276671..01591c9c9b 100644 --- a/src/cmd/go/internal/work/exec.go +++ b/src/cmd/go/internal/work/exec.go @@ -3455,6 +3455,10 @@ func (b *Builder) swigIntSize(objdir string) (intsize string, err error) { // Run SWIG on one SWIG input file. func (b *Builder) swigOne(a *Action, file, objdir string, pcCFLAGS []string, cxx bool, intgosize string) error { + if strings.HasPrefix(file, "cgo") { + return errors.New("SWIG file must not use prefix 'cgo'") + } + p := a.Package sh := b.Shell(a) |
