Skip to main content
LowSupply chainOWASP A05:2021CWE-540

How to fix: Go go.mod exposed

The response is a Go module file: a module directive followed by a go language-version directive.

Why it matters

The module path is frequently a private repository URL, which discloses an internal git host and the organisation's internal module naming. The require block gives every direct dependency and version, and the go directive pins the toolchain version, which reveals whether the build predates a known Go runtime fix.

Go binaries are statically linked and ship without go.mod, so a served copy means the source tree is under the document root rather than just the built binary. Where the module path names a private host, the more useful follow-up is dependency confusion: an internal module path that is not reserved on the public proxy can be claimed by someone else.

How to fix it

  1. 1Deploy the compiled binary, not the source tree.
  2. 2Check whether the internal module path disclosed here is claimable on proxy.golang.org, and reserve it if so.
  3. 3Set GOPRIVATE / GONOSUMDB for internal module prefixes so the toolchain never resolves them through the public proxy.
  4. 4Run govulncheck against the module now that its dependency set is public.

Code examples

Keep internal modules off the public proxy

bash
go env -w GOPRIVATE=git.internal.example.com/*
go env -w GONOSUMCHECK=1

Audit the module

bash
go install golang.org/x/vuln/cmd/govulncheck@latest
govulncheck ./...

References

Detected automatically by VulnRadar. The check id is supply-chain-go-mod-exposed, stable across every scan so you can filter or diff on it.

See every supply chain check

Questions

How severe is Go go.mod exposed?
VulnRadar rates this low severity in the supply chain category. The severity is fixed per check, not scored per site, so the same finding is the same severity on every scan.
Does VulnRadar check for this automatically?
Yes. It runs as part of every scan under the check id supply-chain-go-mod-exposed, which stays the same between runs so you can filter, diff, or gate CI on it.
Which standards does Go go.mod exposed map to?
It maps to CWE-540. In the OWASP Top 10 it falls under A05:2021.

Missing a check?

The detection set is open. If you know a misconfiguration this does not catch, propose it: the issue template asks for the threat model, how to detect it, the false-positive risk, and a test fixture, which is the same thing a maintainer would have to work out anyway.

Propose a checkHow a check is built

Scan your own site for go go.mod exposed

VulnRadar runs this check and hundreds more against a URL in seconds. No agent to install, just paste a URL.

Or scan this site as a demoRead the docs

How to fix: Go go.mod exposed | VulnRadar