mirror of
https://github.com/coder/coder.git
synced 2025-07-03 16:13:58 +00:00
security: add X-Content-Type-Options: nosniff
to block MIME-sniffing (#6344)
coder/security#12
This commit is contained in:
@ -319,6 +319,16 @@ func New(options *Options) *API {
|
||||
next.ServeHTTP(w, r)
|
||||
})
|
||||
},
|
||||
// This header stops a browser from trying to MIME-sniff the content type and
|
||||
// forces it to stick with the declared content-type. This is the only valid
|
||||
// value for this header.
|
||||
// See: https://github.com/coder/security/issues/12
|
||||
func(next http.Handler) http.Handler {
|
||||
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
w.Header().Add("X-Content-Type-Options", "nosniff")
|
||||
next.ServeHTTP(w, r)
|
||||
})
|
||||
},
|
||||
httpmw.CSRF(options.SecureAuthCookie),
|
||||
)
|
||||
|
||||
|
Reference in New Issue
Block a user