CSP: navigate-to

The HTTP Content-Security-Policy (CSP) navigate-to directive restricts the URLs to which a document can initiate navigations by any means including <form> (if form-action is not specified), <a>, window.location, window.open, etc. This is an enforcement on what navigations this document initiates, not on what this document is allowed to navigate to.

Note: If the form-action directive is present, the navigate-to directive will not act on navigations that are form submissions.

CSP version 3
Directive type Navigation directive
default-src fallback No. Not setting this allows anything.

Syntax

One or more sources can be set for the navigate-to policy:

Content-Security-Policy: navigate-to <source>;
Content-Security-Policy: navigate-to <source> <source>;

Sources

<source> can be any one of the values listed in CSP Source Values.

Note that this same set of values can be used in all fetch directives (and a number of other directives).

Examples

Meta tag configuration

<meta http-equiv="Content-Security-Policy" content="navigate-to 'none'">

Violation case

Using a <form> element with an action set to inline JavaScript will result in a CSP violation.

<meta http-equiv="Content-Security-Policy" content="navigate-to 'none'">

<form action="javascript:alert('Foo')" id="form1" method="post">
  <input type="text" name="fieldName" value="fieldValue">
  <input type="submit" id="submit" value="submit">
</form>

Specifications

Specification
Content Security Policy Level 3
# directive-navigate-to

Browser compatibility

BCD tables only load in the browser

See also