
A security tool to detect malicious Go packages by verifying checksums in go.sum against the original source code
A security tool to detect malicious Go packages by verifying checksums in go.sum against the original source code, bypassing the Go Module Proxy cache.
This tool helps protect against supply chain attacks that exploit the Go Module Proxy cache, as recently demonstrated by the malicious github.com/boltdb-go/bolt package.
These attacks take advantage of the Go Module Proxy's indefinite caching mechanism to serve malicious code even after the source repository has been cleaned.
For more details about this type of attack, see:
The tool works by:
go install github.com/knqyf263/go-mal-pkgs@latest
Basic usage:
go-mal-pkgs /path/to/your/go/project
The tool will analyze your project's go.sum file and verify each module's integrity.
Successful verification:
$ go-mal-pkgs /path/to/project
Checking golang.org/x/[email protected]...
✅ Verified golang.org/x/[email protected]
Checking github.com/stretchr/[email protected]...
✅ Verified github.com/stretchr/[email protected]
Detection of a potentially malicious package:
$ go-mal-pkgs /path/to/compromised-project
Checking github.com/boltdb-go/[email protected]...
⚠️ WARNING: checksum mismatch for github.com/boltdb-go/[email protected]:
expected: h1:abc123def456...
actual: h1:xyz789uvw012...
The tool implements Go's checksum verification algorithm using the golang.org/x/mod/sumdb/dirhash package. When it detects a mismatch between the checksum in your go.sum and the one calculated from the source repository, it could indicate:
This is an experimental tool created as a proof of concept in response to the recent Go module proxy cache exploitation. The entire codebase was generated using Claude 3.5 Sonnet AI assistant.