{"id":"CVE-2026-97035","kind":"vulnerability","aliases":["CVE-2026-97035","GO-2026-6856"],"related":[],"title":"Unexpected code execution and arbitrary file write via Clang -gen-* and GCC -gnat* flags in cgo in cmd/go","description":"When using Clang or GCC, building a malicious package that uses cgo could cause unexpected code execution at build time or write files to arbitrary directories via \"-gen-*\" or \"-gnat*\" flags in \"#cgo\" directives.\n\nThe \"-g*\" wildcard in the compiler and linker flag allowlists previously matched Clang's two-argument \"-gen-cdb-fragment-path <dir>\" flag and GCC's two-argument \"-gnatO <file>\" flag, permitting compilation database fragments and sidecar output files to be written to arbitrary directories and desynchronizing flag argument parsing between the go command and the compiler driver so that subsequent arguments could be passed as unvalidated positional inputs to the linker.\n\n\"-gen-*\" and \"-gnat*\" flags are now disallowed in \"#cgo\" compiler and linker flags.","summary":"A Go package that uses cgo can smuggle Clang or GCC flags through #cgo directives, letting it write files to arbitrary directories or slip extra arguments into the linker during build. An attacker who gets a malicious package into a build gets code execution or file writes on the build machine.","severity":"high","cvss":null,"epss":null,"exploited":false,"exploited_at":null,"products":[{"name":"toolchain","fixed":["1.26.11","1.27.4"],"affected":">= 1.27.0-0, < 1.27.4","ecosystem":"go"}],"ecosystems":["go"],"tags":["build-servers","cgo","ci","go","runtime"],"not_affected_if":["no-cgo","trusted-dependencies-only"],"how_to_check":"- Run `go version` and compare against the fixed versions.\n- Check whether builds compile cgo packages from untrusted or third-party sources.","fix":"- Go toolchain: `1.26.11` for the 1.26 line, `1.27.4` for the 1.27 line.","status":"open","published_at":"2026-11-11T02:51:11+00:00","first_seen_at":"2026-11-11T03:37:17+00:00","triaged_at":"2026-11-11T03:38:59+00:00","updated_at":"2026-11-11T03:38:59+00:00","category":"runtime","confidence":0.7,"triage":{"at":"2026-11-11T03:38:59Z","model":"claude-haiku-5-5","output":{"fix":"- Go toolchain: `1.26.11` for the 1.26 line, `1.27.4` for the 1.27 line.","reach":"unknown","title":"Go toolchain: malicious cgo package runs code or writes files at build time","impact":"high","summary":"A Go package that uses cgo can smuggle Clang or GCC flags through #cgo directives, letting it write files to arbitrary directories or slip extra arguments into the linker during build. An attacker who gets a malicious package into a build gets code execution or file writes on the build machine.","audience":"developers","category":"runtime","nicknames":[],"who_cares":["go","cgo","ci","build-servers"],"confidence":0.7,"fix_status":"available","needs_auth":"no","worst_case":"Code runs on build machine; arbitrary files written to disk","analyst_note":"","how_to_check":"- Run `go version` and compare against the fixed versions.\n- Check whether builds compile cgo packages from untrusted or third-party sources.","plain_action":"","product_name":"","needs_analyst":false,"not_affected_if":["no-cgo","trusted-dependencies-only"],"who_is_affected":"Teams whose Go builds compile cgo code with Clang or GCC, especially when they pull in third-party packages that were not reviewed. Builds that never use cgo, or that only use trusted code and do not run dependency builds on shared machines, are less exposed. The sources do not say whether default configurations are affected beyond this.","user_interaction":"no","product_ecosystem":"","needs_special_setup":"unknown","severity_if_unknown":"high"},"cost_usd":0.000745,"input_tokens":4776,"output_tokens":535,"severity_before":"unknown"},"analyst_status":null,"analyst_note":null,"search":"'-2026':20A,23A,26A '-6856':24A '-97035':21A,27A 'allowlist':130C 'arbitrari':5A,56B,111C,164C 'argument':61B,137C,149C,169C,182C 'attack':68B 'build':30B,66B,76B,85B,92C,105C 'build-serv':29B 'caus':100C 'cdb':140C 'cgo':16A,32B,41B,49B,98C,119C,201C 'ci':33B 'clang':9A,44B,89C,133C 'cmd/go':18A 'code':2A,78B,102C 'command':174C 'compil':126C,153C,177C,202C 'could':99C,183C 'cve':19A,25A 'databas':154C 'desynchron':167C 'direct':50B,120C 'directori':57B,112C,165C 'disallow':199C 'driver':178C 'execut':3A,79B,103C 'extra':60B 'file':6A,54B,81B,109C,159C 'flag':14A,47B,117C,129C,143C,151C,168C,196C,205C 'fragment':141C,155C 'g':122C 'gcc':12A,46B,91C,145C 'gen':10A,114C,139C,193C 'gen-cdb-fragment-path':138C 'get':70B,77B 'gnat':13A,116C,195C 'gnato':150C 'go':22A,34B,37B,173C 'input':189C 'let':51B 'linker':64B,128C,192C,204C 'machin':86B 'malici':72B,94C 'match':132C 'output':158C 'packag':38B,73B,95C 'pars':170C 'pass':185C 'path':142C 'permit':152C 'posit':188C 'previous':131C 'runtim':35B 'server':31B 'sidecar':157C 'slip':59B 'smuggl':43B 'subsequ':181C 'time':106C 'toolchain':28A 'two':136C,148C 'two-argu':135C,147C 'unexpect':1A,101C 'unvalid':187C 'use':40B,88C,97C 'via':8A,113C 'wildcard':123C 'write':7A,53B,82B,108C 'written':162C","nicknames":[],"mitigations":[],"who_affected":"Teams whose Go builds compile cgo code with Clang or GCC, especially when they pull in third-party packages that were not reviewed. Builds that never use cgo, or that only use trusted code and do not run dependency builds on shared machines, are less exposed. The sources do not say whether default configurations are affected beyond this.","tier":"B","verified":{},"analyst_revisit_at":null,"fix_status":"available","audience":"developers","plain_action":null,"pkeys":["toolchain"],"ptokens":["toolchain"],"labels":["buildservers","cgo","ci","go","high","runtime"],"campaign_type":null,"search_a":"'-2026':20A,23A,26A '-6856':24A '-97035':21A,27A 'arbitrari':5A 'cgo':16A 'clang':9A 'cmd/go':18A 'code':2A 'cve':19A,25A 'execut':3A 'file':6A 'flag':14A 'gcc':12A 'gen':10A 'gnat':13A 'go':22A 'toolchain':28A 'unexpect':1A 'via':8A 'write':7A","search_b":"'arbitrari':56B 'argument':61B 'attack':68B 'build':30B,66B,76B,85B 'build-serv':29B 'cgo':32B,41B,49B 'ci':33B 'clang':44B 'code':78B 'direct':50B 'directori':57B 'execut':79B 'extra':60B 'file':54B,81B 'flag':47B 'gcc':46B 'get':70B,77B 'go':34B,37B 'let':51B 'linker':64B 'machin':86B 'malici':72B 'packag':38B,73B 'runtim':35B 'server':31B 'slip':59B 'smuggl':43B 'use':40B 'write':53B,82B","search_c":"'allowlist':130C 'arbitrari':111C,164C 'argument':137C,149C,169C,182C 'build':92C,105C 'caus':100C 'cdb':140C 'cgo':98C,119C,201C 'clang':89C,133C 'code':102C 'command':174C 'compil':126C,153C,177C,202C 'could':99C,183C 'databas':154C 'desynchron':167C 'direct':120C 'directori':112C,165C 'disallow':199C 'driver':178C 'execut':103C 'file':109C,159C 'flag':117C,129C,143C,151C,168C,196C,205C 'fragment':141C,155C 'g':122C 'gcc':91C,145C 'gen':114C,139C,193C 'gen-cdb-fragment-path':138C 'gnat':116C,195C 'gnato':150C 'go':173C 'input':189C 'linker':128C,192C,204C 'malici':94C 'match':132C 'output':158C 'packag':95C 'pars':170C 'pass':185C 'path':142C 'permit':152C 'posit':188C 'previous':131C 'sidecar':157C 'subsequ':181C 'time':106C 'two':136C,148C 'two-argu':135C,147C 'unexpect':101C 'unvalid':187C 'use':88C,97C 'via':113C 'wildcard':123C 'write':108C 'written':162C","cause_entry":null,"cause_path":null,"disclosures_checked_at":null,"first_public_at":"2026-11-11T02:51:11+00:00","kev":null,"cvss_vector":null,"cvss_by":null,"poc_count":0,"sources":[{"source":"govuln","external_id":"GO-2026-6856","url":"https://pkg.go.dev/vuln/GO-2026-6856","severity":null,"published_at":"2026-11-11T02:51:11+00:00","modified_at":"2026-11-11T02:51:11+00:00","first_seen_at":"2026-11-11T03:37:17+00:00","fetched_at":"2026-11-11T03:37:17+00:00","note":null}],"documents":[],"disclosures":[],"exploit_sources":[],"notice":"Free to read, with fair use of about 60 pages a minute. For higher limits or API access: sales@infrastack.ai"}