Skip to content

cmd/go: harden against cgo LDFLAGS allowing arbitrary file read at build time on darwin #78750

Description

@thatnealpatel

cmd/go/internal/work/security.go:225 contains the canonical allowlist.

A module containing -Wl,-sectcreate:

// #cgo LDFLAGS: -Wl,-sectcreate,__TEXT,__info,/Users/victim/.ssh/super_secret
import "C"

And a victim using CGO_ENABLED=1 and go build on darwin/arm64 will read the contents of /Users/victim/.ssh/super_secret and embed it in the binary. Since exfiltration of this information, even on a multi-user system, requires significant privilege, this is considered to be a hardening measure.

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugReportIssues describing a possible bug in the Go implementation.NeedsFixThe path to resolution is known, but the work has not been done.Security

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions