Skip to content

cmd/go: unexpected code execution via --sysroot, -target, -isysroot, -Wl,-syslibroot, and -x cgo flags #82577

Closed

Description

@nicholashusin

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.

This issue was found by the Go Security Team during an internal audit.

This is CVE-2026-97033 and Go issue https://go.dev/issue/82577.


This was a PRIVATE track issue originally tracked in http://b/568056421.

Activity

  1. added this to the Go1.28 milestone on Oct 26, 2026
  2. nicholashusin commented on Oct 26, 2026

    @nicholashusin
    MemberAuthor

    Hi @gopherbot, please open backport issues for this security issue.

  3. gopherbot commented on Oct 26, 2026

    @gopherbot
    Contributor

    Backport issue(s) opened: #82599 (for 1.26), #82600 (for 1.27).

    Remember to create the cherry-pick CL(s) as soon as the patch is submitted to master, according to https://go.dev/wiki/MinorReleases.

  4. gopherbot commented on Nov 10, 2026

    @gopherbot
    Contributor

    Change https://go.dev/cl/861484 mentions this issue: [release-branch.go1.27] cmd/go: disallow --sysroot and -target, validate -isysroot/-syslibroot, and restrict -x

  5. gopherbot commented on Nov 10, 2026

    @gopherbot
    Contributor

    Change https://go.dev/cl/861523 mentions this issue: [release-branch.go1.26] cmd/go: disallow --sysroot and -target, validate -isysroot/-syslibroot, and restrict -x

  6. changed the title [-]security: fix CVE-2026-97033[/-] [+]cmd/go: unexpected code execution via --sysroot, -target, -isysroot, -Wl,-syslibroot, and -x cgo flags[/+] on Nov 10, 2026
  7. gopherbot commented on Nov 10, 2026

    @gopherbot
    Contributor

    Change https://go.dev/cl/862146 mentions this issue: cmd/go: disallow --sysroot and -target, validate -isysroot/-syslibroot, and restrict -x

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions