Supply Chain Security�with Go
Michael Stapelberg�<stapelberg@golang.org>��Zürich Go Meetup, 2024-Jul-3
Agenda
Context / Lens
Part 1: Keeping your Go environment up to date
Setting the scene
module github.com/robustirc/robustirc
�require github.com/google/renameio/v2 v2.0.0
// …
Is my build environment up to date?
% go version
go version go1.22.0 darwin/arm64
Is my build environment up to date?
% go version
go version go1.22.0 darwin/arm64
Can you use the latest toolchain?
Backward compatibility: GODEBUG
Forward compat: build with a newer Go toolchain
% go mod edit -toolchain go1.22.2��% go install ./cmd/scan2drive
go: downloading go1.22.2 (darwin/arm64)
�% go version -m =scan2drive
/Users/michael/go/bin/scan2drive: go1.22.2
[…]
Forward compat: build with a newer Go toolchain
Recap: go.mod file
module github.com/robustirc/robustirc
�go 1.21
�toolchain go1.22.2
�require github.com/google/renameio/v2 v2.0.0
// …
Go language version
minimum Go toolchain version (optional)
Where can you get informed about new releases?
Part 2: Is my program vulnerable?
Is my program vulnerable?
% go version -m ./scan2drive
./scan2drive: go1.22.2
path github.com/stapelberg/scan2drive/cmd/scan2drive
mod github.com/stapelberg/scan2drive (devel)
dep github.com/gorilla/sessions v1.2.0� […]� build vcs=git
build vcs.revision=7e8a2ca85438f0bcc43603bde2337fd0c644b9d2
build vcs.time=2023-03-07T07:51:30Z
build vcs.modified=false
Is my program vulnerable?
govulncheck example
% govulncheck ./... ��Scanning for dependencies with known vulnerabilities...
Found 1 known vulnerability.
�Vulnerability #1: GO-2024-2730
Directory traversal in FilesystemStore in github.com/gorilla/sessions
More info: https://pkg.go.dev/vuln/GO-2024-2730
Module: github.com/gorilla/sessions
Found in: github.com/gorilla/sessions@v1.2.0
Fixed in: N/A
Example traces found:
#1: internal/webui/web.go:93:30: webui.UI.indexHandler calls sessions.FilesystemStore.Get
#2: internal/webui/web.go:76:25: webui.UI.constantsHandler calls sessions.Session.Save
Mitigating vulnerabilities (1): updating
Mitigating vulnerabilities (2): patching
Mitigating vulnerabilities (2): patching
path github.com/stapelberg/scan2drive/cmd/scan2drive
mod github.com/stapelberg/scan2drive (devel)
dep github.com/golang/protobuf v1.5.2 h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw=
dep github.com/stapelberg/airscan v0.0.0-20230123183513-bed4bafc7ef4
=> /home/michael/go/src/github.com/stapelberg/airscan (devel)
dep go.opencensus.io v0.22.4 h1:LYy1Hy3MJdrCdMwwzxA/dRok4ejH+RwNGbuoD9fCjto=
[…]
Mitigating vulnerabilities (3): removing
Easy & Fast Rollouts means Fast Mitigation!
Part 3: Can we trust Go modules?
Go Modules
Go Module Proxy
go.sum / Go Checksum Database
Part 4: Best practices: sandboxing,�separation, least privilege
Best practice: separation
Best practice: least privilege / sandboxing
Best practice: immutability
Part 5: Supply chain minimalism:�the gokrazy appliance platform
gokrazy
gokrazy: how far will it get you?
gokrazy: what can you build this way?
gokrazy: supply chain
Conclusion
Thank you for your attention!