You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/spfx/content-securty-policy-trusted-script-sources.md
+74-4Lines changed: 74 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,7 +1,7 @@
1
1
---
2
2
title: Support for Content Security Policy (CSP) in SharePoint Online
3
3
description: Learn how SharePoint Online implements Content Security Policy to protect against various attack vectors, and how you can ensure your SharePoint Framework components are valid.
4
-
ms.date: 11/17/2025
4
+
ms.date: 12/16/2025
5
5
author: andrewconnell-msft2
6
6
ms.author: bjansen
7
7
---
@@ -24,9 +24,6 @@ If the enforcement on March 1, 2026, is too soon because you need more time to r
> This option will be available in the SPO Management Shell version that will be released by the end of November 2025.
29
-
30
27
## How Content Security Policy Works in SharePoint Online
31
28
32
29
When a browser requests a script, if CSP is enabled on the site, the browser checks the script location against the CSP rules. If the CSP restrictions allow the location of the script to be loaded by the browser, the browser proceeds with the request. However, if CSP rules to not allow the location, the browser doesn't load the script and logs the error in the browser's Console.
@@ -244,3 +241,76 @@ Selecting a search result opens the side panel with the audit details. Take note
244
241
## Testing with CSP Enforced
245
242
246
243
The enforcement of Content Security Policy (CSP) for SharePoint Online will start from March 1, 2026, but you can already now verify your application's behavior by adding the `csp=enforce` URL parameter to the page containing the SPFx solution you want to test. To enforce CSP in reporting mode, use `csp=report`.
244
+
245
+
## Frequently Asked Questions
246
+
247
+
### I need to load the script https://code.jquery.com/jquery-3.6.0.min.js, in what ways can I define this as trusted source?
248
+
249
+
- The most secure way is qualifying the exact script you want load as then only the specific version of the script can be loaded: `https://code.jquery.com/jquery-3.6.0.min.js`
250
+
- If you want to allow all scripts in a specific domain (code.jquery.com) then use `https://code.jquery.com`. Note that `https://code.jquery.com/*` is not working.
251
+
- If you want to allow all script sources in specific domain +folder (root folder ofcode.jquery.com) then use `https://code.jquery.com/`. Note that `https://code.jquery.com/*` is not working.
252
+
- If you want to allow all subdomains inside a domain use `*.jquery.com`, this will allow loading anything under `jquery.com`
253
+
254
+
### I'm hitting the 300 max sources limit, what should I do?
255
+
256
+
When you hit this limit then the recommendation is to consolidate sources using the model described in the FAQ question above. Note that when the 300 limit is reached uploading new solutions to your app catalog can be impacted. If you're using an automated deployment system with unique script sources per build then the 300 limit can be reached soon, recommended workarounds are:
257
+
- Adding script sources in way that cover all versions (see above)
258
+
- Automatically removing the auto added scripts sources using the model described below
259
+
260
+
Currently the logic to auto add script sources will always add the source, even though there's already a source listed that qualifies. This is somthing we're evaluating for fixing.
261
+
262
+
### Can I update the trusted script sources list using script or code?
263
+
264
+
Yes, you can update the trusted script sources using SPO Management shell:
Yes, using `eval()` will stay possible because the 'unsafe-eval' directive is part of the standard CSP header
300
+
301
+
### Can I get the nonce value to 'allow' my inline script snippets?
302
+
303
+
No, the nonce value is avaiable foruse. Recommendation is to move inline script to script files.
304
+
305
+
### Does CSP apply to SPFx components hosted on 'classic' pages?
306
+
307
+
No, when an SPFx web part is hosted on a classic page CSP will not be enforced
308
+
309
+
### Does CSP apply to the retired SharePoint Add-Ins?
310
+
311
+
No, CSP does not apply to Add-Ins. Add-Ins will stop working from April 2, 2026.
312
+
313
+
### Auto populating trusted script sources is not working when an solution is uploaded to a site collection app catalog?
314
+
315
+
Correct, auto populating of trusted script sources will only apply to solutions uploaded in the tenant app catalog. Currentlythis only applies to uploading via the modern app catalog (https://contoso-admin.sharepoint.com/_layouts/15/tenantAppCatalog.aspx), we're evaluating bringing this option to the classic app catalog.
0 commit comments