Skip to content

Update: HTTP_Headers_Cheat_Sheet #1401

Closed
@jfhr

Description

@jfhr

What is missing or needs to be updated?

Some security headers such as Content-Security-Policy are (as far as I can tell) relevant on all HTML pages, including error pages. But the recommended configuration for Apache or nginx only sets headers on successful responses (2xx or 3xx).

See the Apache docs on Header set:

The optional condition argument determines which internal table of responses headers this directive will operate against: onsuccess (default, can be omitted) or always. The difference between the two lists is that the headers contained in the latter are added to the response even on error, and persisted across internal redirects (for example, ErrorDocument handlers). [...]

And the nginx docs on add_header:

Adds the specified field to a response header provided that the response code equals 200, 201 (1.3.10), 204, 206, 301, 302, 303, 304, 307 (1.1.16, 1.0.13), or 308 (1.13.0). Parameter value can contain variables. [...]
If the always parameter is specified (1.7.5), the header field will be added regardless of the response code.

Example of how that could be problematic: A site that shows user generated content has an XSS vulnerability in their app code, but it doesn't take effect because the server admin configured a strong CSP using the recommended Apache/nginx configuration. However, the CSP is not sent on 404 pages. If the app adds a feature to show content on 404 pages (ie. "What you're looking for doesn't exist, but check out this instead"), the XSS vulnerability could now be exploited.

How should this be resolved?

Add always to the recommended configuration for Apache and nginx, or add an explanation that the default is to only set headers on success responses.

Apache:

<IfModule mod_headers.c>
Header always set X-Frame-Options "DENY"
</IfModule>

nginx:

add_header "X-Frame-Options" "DENY" always;

Metadata

Metadata

Assignees

No one assigned

    Labels

    ACK_OBTAINEDIssue acknowledged from core team so work can be done to fix it.HELP_WANTEDIssue for which help is wanted to do the job.UPDATE_CSIssue about the update/refactoring of a existing cheat sheet.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions