Description
Writing a panic dump or debug.Stack() to an HTTP response reveals details of the running server.
Potential impact
Package names, file paths and runtime values in a trace can disclose sensitive information about the application.
Remediation
Return a short HTTP error to the caller. If diagnostics require a trace, remove sensitive values, record it on the server, and limit log access and retention.
Examples
Before
go
w.Write(debug.Stack())
After
go
log.Print(string(debug.Stack()))
http.Error(w, "internal server error", http.StatusInternalServerError)
The revised handler sends HTTP 500 with http.Error. log.Print receives the trace, so configure its output as a protected log.