Skip to content

cmd/go: arbitrary code execution via crafted .syso files and cgo linker input files #82572

Closed

Description

@nicholashusin

Building a malicious package containing ".syso" files or cgo linker inputs could
inject arbitrary linker flags or execute arbitrary code at link time.

Linker input files—including ".syso" files, direct object or library inputs in
"#cgo LDFLAGS", and libraries in "-L" directories—were passed to the external
linker without validating their format or checking for embedded linker options.
Across platforms, this allowed executing GNU ld implicit linker scripts
disguised as libraries or ".syso" files (or loaded via "-l:" or "-l"
containing path separators), injecting unallowlisted linker flags via PE/COFF
".drectve" sections on Windows or Mach-O "LC_LINKER_OPTION" load commands on
Darwin, or invoking LTO plugins via GCC or LLVM LTO intermediate representation
sections in ELF, PE/COFF, or Mach-O objects.

The go command now verifies that ".syso" files, direct linker inputs, and
libraries in "-L" directories are valid binary objects or archives that do not
contain unallowlisted ".drectve" directives, "LC_LINKER_OPTION" load commands,
or LTO IR sections, and disallows "-l:" and ":", "=", or path
separators in "-l" flags.

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

This is CVE-2026-97038 and Go issue https://go.dev/issue/82572.


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

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: #82589 (for 1.26), #82590 (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/861528 mentions this issue: [release-branch.go1.26] cmd/go: validate .syso and linker input files against scripts and embedded options

  5. gopherbot commented on Nov 10, 2026

    @gopherbot
    Contributor

    Change https://go.dev/cl/861489 mentions this issue: [release-branch.go1.27] cmd/go: validate .syso and linker input files against scripts and embedded options

  6. changed the title [-]security: fix CVE-2026-97038[/-] [+]cmd/go: arbitrary code execution via crafted .syso files and cgo linker input files[/+] on Nov 10, 2026
  7. gopherbot commented on Nov 10, 2026

    @gopherbot
    Contributor

    Change https://go.dev/cl/862151 mentions this issue: cmd/go: validate .syso and linker input files against scripts and embedded options

  8. corani commented on Nov 11, 2026

    @corani

    This change introduces a false positive when a #cgo LDFLAGS library search directory contains checksum files alongside shared libraries.

    For example, our SDK ships both libexample.so and libexample.so.sha256 . After upgrading to Go 1.27.4, building fails with:

    invalid linker input file in #cgo LDFLAGS: .../libexample.so.sha256 (unrecognized binary format)

    The reLinkerLibFile regex includes .so. , which matches the checksum filename. scanLinkerSearchDir consequently attempts to validate it as a binary, even though it is not selected by any linker flag.

    We worked around this by copying only the required shared libraries into a separate build-only search directory, while preserving the original directory and checksum files for runtime integrity verification.

    Could the filename detection be refined to avoid treating checksum files as versioned shared libraries?

  9. CynanX commented on Nov 11, 2026

    @CynanX

    I'm seeing this also when using pact-go.

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