Skip to content

cmd/go: arbitrary command execution via GCC spec files in cgo linker search directories #82576

Closed

Description

@nicholashusin

When using GCC, building a malicious package that uses cgo could cause arbitrary
command execution at link time via untrusted GCC spec files ("specs" or
"*.spec").

When linking with "-fopenmp", "-fopenacc", or "-fsanitize=" in "#cgo LDFLAGS",
GCC's built-in link spec evaluates "%:include(libgomp.spec)" or
"%:include(libsanitizer.spec)" and searches for spec files in "-L" and sysroot
directories (including subdirectories and multilib sibling directories such as
"../lib64"), as well as the working directory when "-fopenmp" or "-fopenacc" is
used or when "-fsanitize=" is combined with "-static" or "-static-lib*".

The go command now rejects "-L", "-isysroot", and "-Wl,-syslibroot" directories
(and the working and package directories when applicable) that contain GCC spec
files, and disallows "@" and "-" prefixes in "-fsanitize=" compiler flag values.

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

This is CVE-2026-97034 and Go issue https://go.dev/issue/82576.


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

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: #82597 (for 1.26), #82598 (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/861524 mentions this issue: [release-branch.go1.26] cmd/go: reject GCC spec files in linker search directories

  5. gopherbot commented on Nov 10, 2026

    @gopherbot
    Contributor

    Change https://go.dev/cl/861485 mentions this issue: [release-branch.go1.27] cmd/go: reject GCC spec files in linker search directories

  6. changed the title [-]security: fix CVE-2026-97034[/-] [+]cmd/go: arbitrary command execution via GCC spec files in cgo linker search directories[/+] on Nov 10, 2026
  7. gopherbot commented on Nov 10, 2026

    @gopherbot
    Contributor

    Change https://go.dev/cl/862147 mentions this issue: cmd/go: reject GCC spec files in linker search directories

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