Skip to content

cmd/go: arbitrary code execution during build on darwin via "-l to_library" in cgo #82574

Closed

Description

@nicholashusin

On Darwin, building a malicious package that uses cgo could cause arbitrary code
execution when using the Apple linker due to passing "-l to_library " in a
"#cgo LDFLAGS" directive.

The Apple linker recombines the separated arguments "-l" and "to_library" into
"-lto_library", which loads an arbitrary LTO plugin dynamic library at link
time.

The go command now disallows "-l" followed by "to_library" in "#cgo LDFLAGS",
rejects "-lazy_library", "-lazy_framework", "-load_hidden", "-library", and
"-library-path", and checks recombined "-l" arguments against disallowed linker
flags and patterns.

Thanks to Ali Sherif (https://www.linkedin.com/in/ali-sherif-13812b276/) for reporting this issue.

This is CVE-2026-97036 and Go issue https://go.dev/issue/82574.


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

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: #82593 (for 1.26), #82594 (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/861526 mentions this issue: [release-branch.go1.26] cmd/go: disallow separated -l flag followed by to_library

  5. gopherbot commented on Nov 10, 2026

    @gopherbot
    Contributor

    Change https://go.dev/cl/861487 mentions this issue: [release-branch.go1.27] cmd/go: disallow separated -l flag followed by to_library

  6. changed the title [-]security: fix CVE-2026-97036[/-] [+]cmd/go: arbitrary code execution during build on darwin via "-l to_library" in cgo[/+] on Nov 10, 2026
  7. gopherbot commented on Nov 10, 2026

    @gopherbot
    Contributor

    Change https://go.dev/cl/862149 mentions this issue: cmd/go: disallow separated -l flag followed by to_library

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