Skip to content

Commit

Permalink
Disable browser MIME confusion attacks via content-type sniffing
Browse files Browse the repository at this point in the history
  • Loading branch information
blakestoddard authored and willnorris committed Oct 16, 2020
1 parent c6206ea commit c08b3c5
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions imageproxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,9 @@ func (p *Proxy) serveImage(w http.ResponseWriter, r *http.Request) {
// Add a Content-Security-Policy to prevent stored-XSS attacks via SVG files
w.Header().Set("Content-Security-Policy", "script-src 'none'")

// Disable Content-Type sniffing
w.Header().Set("X-Content-Type-Options", "nosniff")

w.WriteHeader(resp.StatusCode)
if _, err := io.Copy(w, resp.Body); err != nil {
p.logf("error copying response: %v", err)
Expand Down

0 comments on commit c08b3c5

Please sign in to comment.