Configuration

CSP Manager can be configured via appsettings.json under the CspManager key.

{
  "CspManager": {
    "DisableBackOfficeHeader": false,
    "FailureBehavior": "FailOpen",
    "DisabledNodePolicyBehavior": "FallbackToGlobal"
  }
}

Options

DisableBackOfficeHeader

Type: bool Default: false

Emergency kill switch to disable the CSP header for the Umbraco backoffice. When set to true, no Content-Security-Policy or Content-Security-Policy-Report-Only header is added to backoffice responses, regardless of what the backoffice policy is configured to do.

Use this if a misconfigured backoffice CSP policy locks you out of the Umbraco admin interface:

{
  "CspManager": {
    "DisableBackOfficeHeader": true
  }
}

Remember to set it back to false once you have fixed the policy. See Troubleshooting for more on recovering from a broken backoffice CSP.

Requests get the backoffice policy when their path is under /umbraco, except Umbraco’s public areas there: /umbraco/surface, /umbraco/api and the Delivery API at /umbraco/delivery/api. Those, and content URLs that just start with “umbraco” (such as /umbraco-partners), get the frontend policy, so this option never removes their header. Plugin controller routes (/umbraco/{area}/{controller}/{action}) get the backoffice policy.

FailureBehavior

Type: CspFailureBehavior (FailOpen or FailClosed) Default: FailOpen

Controls what happens if CSP header construction throws, for example when a configured source value is rejected as an invalid header value. Header construction failures never break the request itself - this option only controls what (if anything) is sent in place of the failed header. Either way, the failure is logged as an error.

  • FailOpen (default): the request continues with no CSP header at all. Availability is prioritized over security, and the failure is only visible in the logs.
  • FailClosed: frontend requests continue with a minimal fallback policy, default-src 'self', instead of no header. Backoffice requests still fail open, so editors can get into the backoffice to fix the policy that failed.

If the CSP definition loaded before the failure and is set to report-only, the fallback is sent as Content-Security-Policy-Report-Only too, so a policy you are only trialling is never replaced by an enforced one. If the definition could not be loaded at all (for example, a database error), the fallback is enforced.

{
  "CspManager": {
    "FailureBehavior": "FailClosed"
  }
}

The FailClosed fallback is same-origin-only, so it can block cross-origin resources on your site (CDN scripts, fonts, embeds, etc.) until the underlying construction error is fixed.

Both behaviors publish a CspHeaderConstructionFailedNotification before the fallback is written, so a handler can set the fallback policy itself for that request — see Notification Events.

See Troubleshooting for more on diagnosing header construction failures.

DisabledNodePolicyBehavior

Type: FallbackToGlobal | NoHeader Default: FallbackToGlobal

Controls which policy applies when a request matches a domain whose domain policy is disabled.

Value Behaviour
FallbackToGlobal Applies the Frontend policy, as if the node had no domain policy. Disabling a domain policy retains baseline site protection.
NoHeader Sends no CSP header on the node’s hostnames, matching the behaviour of a disabled Frontend policy.

NoHeader is an explicit fail-open setting: disabling a domain policy removes all CSP protection from every hostname of its node. Keep the default unless you specifically require an unconstrained site.

{
  "CspManager": {
    "DisabledNodePolicyBehavior": "NoHeader"
  }
}

Domains without a domain policy always use the Frontend policy; this option only applies when a configured domain policy is disabled.