---
id: "CVE-2026-97033"
page: "https://infrastack.ai/live/CVE-2026-97033"
kind: "vulnerability"
aliases: ["CVE-2026-97033", "GO-2026-6858"]
title: "Unexpected code execution via --sysroot, -target, -isysroot, -Wl,-syslibroot, and -x cgo flags in cmd/go"
severity: "high"
cvss: null
epss: null
exploited: false
status: "open"
category: "runtime"
products: [{"name": "toolchain", "fixed": ["1.26.11", "1.27.4"], "affected": ">= 1.27.0-0, < 1.27.4", "ecosystem": "go"}]
ecosystems: ["go"]
tags: ["build-systems", "cgo", "ci", "go", "runtime"]
not_affected_if: ["cgo-disabled", "patched-toolchain", "trusted-sources-only"]
published_at: "2026-11-11T02:51:11+00:00"
first_seen_at: "2026-11-11T03:37:17+00:00"
updated_at: "2026-11-11T03:39:00+00:00"
sources: [{"source": "govuln", "url": "https://pkg.go.dev/vuln/GO-2026-6858", "first_seen_at": "2026-11-11T03:37:17+00:00"}]
exploit_sources: []
---

# Unexpected code execution via --sysroot, -target, -isysroot, -Wl,-syslibroot, and -x cgo flags in cmd/go

Link for people: https://infrastack.ai/live/CVE-2026-97033 (this .md is for agents)

A Go package that uses cgo can pass certain compiler and linker flags in its #cgo directives that make the build run attacker-chosen code. Building or installing such a package can give the attacker code execution on the build machine.

_Summary, check and fix written by a model from the sources; labelled as such._

## Affected

- go:toolchain affected >= 1.27.0-0, < 1.27.4 fixed 1.26.11, 1.27.4

## How to check

- Run `go version` and compare against the fixed versions.
- Check whether your build pipelines fetch and compile third-party packages that use cgo.

## Fix

- Go toolchain: move to `1.26.11` on the 1.26 line or `1.27.4` on the 1.27 line.

## Timeline

- 2026-11-11T03:37:17+00:00 govuln https://pkg.go.dev/vuln/GO-2026-6858

## From the sources

Building a malicious package that uses cgo could cause arbitrary code execution at build time through several compiler and linker flags permitted in "#cgo" directives.

Specifically, "--sysroot" in GCC and Clang relocates compiler subprograms, spec files, and CRT startup objects to an attacker-controlled directory; "-target" in Clang falls back to executing target helper tools from the current working directory when not found in PATH; "-isysroot" and "-Wl,-syslibroot" can pass a regular file on disk to GNU ld.bfd, which interprets it as a positional linker script; and "-x" permitted specifying arbitrary compiler input languages beyond those supported by cgo.

"--sysroot" and "-target" are now disallowed in "#cgo" flags, "-isysroot" and "-Wl,-syslibroot" are verified not to point to regular files, and "-x" is restricted to the C, C++, Objective-C, and assembler languages supported by cgo.

---

_Free to read, with fair use of about 60 pages a minute. For higher limits or API access: sales@infrastack.ai_
