From 22f65d37c46d8eb087d764a734693d0abe39080f Mon Sep 17 00:00:00 2001 From: Neal Patel Date: Tue, 24 Feb 2026 23:05:34 +0000 Subject: cmd/go: disallow cgo trust boundary bypass MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Reviewed-by: Damien Neil Reviewed-on: https://go-review.googlesource.com/c/go/+/763768 LUCI-TryBot-Result: Go LUCI Auto-Submit: David Chase Reviewed-by: Russ Cox --- src/cmd/go/internal/work/exec.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/cmd/go/internal/work/exec.go b/src/cmd/go/internal/work/exec.go index 4217aee1bf..38d19c5743 100644 --- a/src/cmd/go/internal/work/exec.go +++ b/src/cmd/go/internal/work/exec.go @@ -3463,6 +3463,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) -- cgit v1.3