This sheet is past its review date. Deadlines or advice may have changed since 5 Nov 2026.
Go: which habits still turn into vulnerabilities?
Before your next release, rebuild every Go binary with Go 1.27.3 or 1.26.10, as Go 1.25 is unsupported12, and make govulncheck and gosec required CI checks. Judge everything else by whether outside data can reach SQL, a shell, a template, a path or a URL unchecked, or hold memory, a connection or a goroutine without a limit.
If you only do five things
Bound every request in time and size.
Zero
http.Servertimeouts mean none, andhttp.DefaultClienthas none either10. SetReadHeaderTimeout, wrap bodies inhttp.MaxBytesReaderand time out every client.
Review a Go pull request
Where does outside data enter?
Find the handlers, gRPC methods and queue consumers it touches. Each should cap the body, decode into a struct and check the caller's right to the record: missing authorization ranks 4th in the CWE Top 259.
Does it start a goroutine?
Ask what stops it, whether it gets the request's
context.Contextand what it shares without a lock15.Does input reach SQL, a command, a template or a path?
Search for
fmt.SprintfnearQueryorExec,"sh", "-c",text/template,template.HTML(,filepath.Join,os.Openand archive readers.Does it call out over the network?
Check URLs from input, clients without a
Timeout,InsecureSkipVerifyandReverseProxy.Director, deprecated in Go 1.26 because clients can strip the headers it adds5.Does it switch off Go's checks?
unsafe, cgo,//go:debuglines andgodebugblocks ingo.modneed a second reviewer.
Go traps and what to use instead
filepath.Join(dir, name)andhttp.Dir.filepath.Join("a/b", "../../../xyz")returns../xyz11, andhttp.Dirfollows symlinks out of its tree and serves dotfiles such as.git10. Useos.OpenInRoot,os.Rootandhttp.FileServerFS(root.FS())12 on a tree without dotfiles, and patch:os.Rootescapes were fixed in March, April, July and October1314.zip.NewReaderandtar.NewReader. Both accept entry names like../xunlessGODEBUGsetszipinsecurepath=0ortarinsecurepath=019. Create each entry through anos.Rootand copy withio.CopyNto cap its size, as gosec G110 asks8.text/template,template.HTML(s)and data inside<script>. Onlyhtml/templateescapes, and it trusts template authors andtemplate.HTMLvalues20. Go fixed sevenhtml/templateescaping bugs in 2026, five in script contexts21. Pass data indata-attributes, and never parse templates from user input. Cross-site scripting ranks 1st in the CWE Top 259.db.Query(fmt.Sprintf(...))and ORM string methods. Go's docs call SQL built withfmta security risk: pass values as arguments with your driver's placeholder, such as?or$122. GORM doesn't escapeOrder,Select,Table,GrouporRaw, anddb.First(&u, id)with a stringidis injectable23. Map sort columns from a fixed list.exec.Command("sh", "-c", cmd).os/execdeliberately runs no shell24, andsh -cbrings back OS command injection, 9th in the CWE Top 259. Pass each argument separately, put--before values that may start with-, and don't clearexec.ErrDot, which stopsCommandfrom resolving a name to a program in the current directory24.http.Get(r.FormValue("url")). The default client has no timeout and follows up to 10 redirects10. Allowlist hosts, also inCheckRedirect, then reject loopback, private and link-local addresses innet.Dialer.ControlContext, which runs just before each connection is made25. Server-side request forgery ranks 22nd in the CWE Top 259.json.Unmarshal(body, &req). The v1 decoder matches names case-insensitively, lets the later of duplicate names win and ignores unknown fields, so two services can read one request differently26. On Go 1.27, useencoding/json/v2, which rejects duplicates and invalid UTF-8 and matches names exactly, withjson.RejectUnknownMembers(true)26.go func() { ... }()in a handler.net/httprecovers a panic in the handler itself10, but an unrecovered panic in a goroutine it starts ends the program. Nil map writes, nil pointers, bad indexes and one-value type assertions all panic18. Usev, ok := x.(T)and a deferredrecoverin goroutines that handle input.int32(n)and other integer conversions. They truncate with no indication of overflow, and arithmetic overflows without a panic18. Parse with the target size, as instrconv.ParseInt(s, 10, 32), and check lengths before converting them, which gosec G115 flags8.
Tools that catch it
- govulncheck. Source mode checks the standard library of the
goon yourPATH,-mode binarya built binary. Calls throughreflectare invisible, and-jsonor-format sarifoutput never fails the build6. - gosec. Fix G112 (no
ReadHeaderTimeout), G115 (integer conversion), G204, G304, G305, G402, G404 (math/rand) and G701 to G705 first8. - Race detector and fuzzer.
go test -racecan use 5 to 10 times the memory and 2 to 20 times the time16: run it in CI. Fuzz one target per run with-fuzztime17. - Goroutine leak profile. Go 1.27's
goroutineleakprofile reports goroutines that can never wake up4.
What changed in 2026
- Go 1.27 shipped on 19 August, ending support for Go 1.2521. Old
golines no longer turn TLS 1.0 or 3DES back on by default54. - Go made its first URGENT release. Go 1.27.3 and 1.26.10, out on 19 October, distrust eMudhra intermediates whose keys were trivially weak3.
- Malicious proxies could bypass the checksum database until fixes in May, August and October. Upgrade the installed Go, as pinning
GOTOOLCHAINisn't enough27. The supply-chain sheet covers the rest. - A compiler bug dropped bounds checks. Go 1.26.2 and 1.25.9 fixed loop arithmetic that could let code without
unsafecorrupt memory (CVE-2026-27143)28.
What you can skip
- Setting
GOFLAGS=-mod=readonly. Build commands have behaved that way since Go 1.1629. - FIPS 140-3 mode you don't need. Go says applications without a compliance need shouldn't enable it, and
fips140=onlyisn't meant for production30. - Rushing govulncheck's informational findings. It lists vulnerabilities your code doesn't call separately and says you may not need to act7. Fix them in routine updates.
Mistakes that cost the most
- Patching the image, not the binary. On Linux, Go checks certificates itself, without revocation checks3. Binaries rebuilt with 1.27.3 or 1.26.10 reject the eMudhra intermediates whatever trust store the image ships3. Scan what you deploy with
govulncheck -mode binary. - Leaving the
goline ingo.modbehind. Most GODEBUG defaults follow it, so ago 1.23module built with Go 1.27 still accepts RSA keys under 1,024 bits. Check withgo list -f '{{.DefaultGODEBUG}}'19.
What this looks like for your code
New project
- For services, run
go get go@1.27.3aftergo mod init, which writes an oldergoline5, and useencoding/json/v2andos.Rootfrom the start. - Give each
http.Servertimeouts, and puthttp.NewCrossOriginProtection().Handlerin front of the mux against CSRF10. - Make
govulncheck,gosecandgo test -racerequired checks.
Existing codebase
High-assurance or regulated
- For FIPS 140-3, build with
GOFIPS140=certified: Go Cryptographic Module v1.0.0 holds CMVP certificate #524730. - Fuzz every parser continuously in your own CI.
- Require CodeQL's
security-extendedsuite; private code needs a paid GitHub Code Security license31. Build releases withCGO_ENABLED=0unless a reviewed package needs cgo;-raceneeds it16.