W3cubDocs

/HTTP

CSP: navigate-to

CSP: navigate-to

Experimental: This is an experimental technology
Check the Browser compatibility table carefully before using this in production.

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

Browser compatibility

Desktop Mobile
Chrome Edge Firefox Internet Explorer Opera Safari WebView Android Chrome Android Firefox for Android Opera Android Safari on IOS Samsung Internet
navigate-to
No
No
No
No
No
No
No
No
No
No
No
No

See also

© 2005–2022 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/navigate-to