---
id: "CVE-2026-97043"
page: "https://infrastack.ai/live/CVE-2026-97043"
kind: "vulnerability"
aliases: ["CVE-2026-97043", "GO-2026-6848"]
title: "Unexpected code execution via escaped quotes in //go:cgo_ldflag in cmd/go and cmd/compile"
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: ["cgo", "ci", "go", "runtime"]
not_affected_if: ["pure-go-only", "trusted-sources-only"]
published_at: "2026-11-11T02:51:11+00:00"
first_seen_at: "2026-11-11T03:37:16+00:00"
updated_at: "2026-11-11T03:38:52+00:00"
sources: [{"source": "govuln", "url": "https://pkg.go.dev/vuln/GO-2026-6848", "first_seen_at": "2026-11-11T03:37:16+00:00"}]
exploit_sources: []
---

# Unexpected code execution via escaped quotes in //go:cgo_ldflag in cmd/go and cmd/compile

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

The Go toolchain mishandles escaped quotes in //go:cgo_ldflag directives, so a malicious package using cgo can smuggle disallowed linker flags past validation. The same flaw can also make the go command panic during LDFLAGS deduplication.

_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 releases listed in the sources.
- Check whether builds compile packages that use cgo with `#cgo LDFLAGS` from third-party modules.

## Fix

- Go `1.26.11`
- Go `1.27.4`

## Timeline

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

## From the sources

Building a malicious package that uses cgo could bypass "#cgo LDFLAGS" validation and cause unexpected code execution at build time, or cause the go command to panic, via crafted quoting in "//go:cgo_ldflag" directives.

When "cmd/cgo" generates "_cgo_gotypes.go", it quotes each "#cgo LDFLAGS" argument with strconv.Quote in a "//go:cgo_ldflag" directive, but "cmd/compile" and "cmd/go" parsed those directives by splitting on raw quote characters without handling backslash escapes or unquoting the string. This mismatch allowed disallowed linker flags or unvalidated linker search paths to be smuggled past the go command's flag checks and passed to the external linker. In addition, deduplicating LDFLAGS in the go command could panic with an out-of-bounds slice index when a prefix of the flag list matched near the end of the slice.

"cmd/compile" and "cmd/go" now properly handle backslash-escaped quotes and unquote "//go:cgo_*" pragma strings with strconv.Unquote, and the slice bounds check in processCgoOutputs has been fixed.

---

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