~cytrogen/masto-fe

fed9cbfd2ba8db8bffb03f554c24d83b6f8aa059 — Claire 2 years ago 000b835
Add hardened headers to user-uploaded files (#25756)

2 files changed, 7 insertions(+), 0 deletions(-)

M dist/nginx.conf
M lib/public_file_server_middleware.rb
M dist/nginx.conf => dist/nginx.conf +2 -0
@@ 109,6 109,8 @@ server {
  location ~ ^/system/ {
    add_header Cache-Control "public, max-age=2419200, immutable";
    add_header Strict-Transport-Security "max-age=63072000; includeSubDomains";
    add_header X-Content-Type-Options nosniff;
    add_header Content-Security-Policy "default-src 'none'; form-action 'none'";
    try_files $uri =404;
  }


M lib/public_file_server_middleware.rb => lib/public_file_server_middleware.rb +5 -0
@@ 32,6 32,11 @@ class PublicFileServerMiddleware
      end
    end

    # Override the default CSP header set by the CSP middleware
    headers['Content-Security-Policy'] = "default-src 'none'; form-action 'none'" if request_path.start_with?(paperclip_root_url)

    headers['X-Content-Type-Options'] = 'nosniff'

    [status, headers, response]
  end