Skip to content

cmd/go, cmd/link: cgo directive injection via .syso files disguised as Go object files #82570

Closed

Description

@nicholashusin

Building a package containing a crafted ".syso" file could bypass cgo flag
validation and inject arbitrary linker flags when linking.

When loading ".syso" entries from a package archive, the linker only checked for
recognized host object headers (ELF, Mach-O, PE, and XCOFF) before falling
through to Go object parsing. A ".syso" file beginning with a "go object" header
was parsed as a Go compiler object, allowing untrusted cgo metadata directives
(such as "cgo_ldflag" or "cgo_dynamic_linker") embedded in the ".syso" file to
be passed to the external linker without validation. Additionally, ".syso"
filenames longer than 16 bytes lost their ".syso" extension when truncated in
archive headers, and unrecognized ".syso" formats forced external linking in
pure-Go builds.

The linker now rejects ".syso" files that are not recognized host object
formats, and "cmd/go" and "cmd/pack" preserve the ".syso" suffix when truncating
long archive member names.

Thanks to RyotaK (https://ryotak.net) of GMO Flatt Security Inc. for reporting this issue.

This is CVE-2026-97040 and Go issue https://go.dev/issue/82570.


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

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: #82585 (for 1.26), #82586 (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/861530 mentions this issue: [release-branch.go1.26] cmd/go, cmd/link: reject .syso files with Go object or unrecognized formats

  5. gopherbot commented on Nov 10, 2026

    @gopherbot
    Contributor

    Change https://go.dev/cl/861491 mentions this issue: [release-branch.go1.27] cmd/go, cmd/link: reject .syso files with Go object or unrecognized formats

  6. changed the title [-]security: fix CVE-2026-97040[/-] [+]cmd/go, cmd/link: cgo directive injection via .syso files disguised as Go object files[/+] on Nov 10, 2026
  7. gopherbot commented on Nov 10, 2026

    @gopherbot
    Contributor

    Change https://go.dev/cl/862153 mentions this issue: cmd/go, cmd/link: reject .syso files with Go object or unrecognized formats

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

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions