Aangepaste Scripts Geblokkeerd Op SharePoint Sites

💼 Management Samenvatting

Het blokkeren van aangepaste scripts op SharePoint sites voorkomt Cross-Site Scripting (XSS) aanvallen, malicious Code injectie aanvallen en data exfiltratie door te voorkomen dat gebruikers of site owners client-side scripts kunnen embedden in pages, web parts of aangepaste solutions.

Aanbeveling
Implementeer
Risico zonder
High
Risk Score
8/10
Implementatie
16u (tech: 8u)
Van toepassing op:
SharePoint Online
M365

aangepaste script capabilities in SharePoint maken het mogelijk om JavaScript code te embedden in pages, web parts en master pages. Dit introduceert ernstige security risks: Cross-Site Scripting (XSS) attacks waarbij malicious JavaScript credentials steelt, keylogging Implementeereert of phishing overlays toont; Data exfiltration door scripts die document content naar externe servers sturen; sessie hijacking via cookie theft; Persistent backdoors in site collections die moeilijk te detecteren zijn; Bypassing van DLP beleidsregels door client-side versleuteling; Malicious iframes die externe malware hosten. Real-world scenario: Een gecompromitteerde site beheerdersaccount voegt malicious script toe aan SharePoint homepage → Script executes voor alle site visitors → credentials worden gestolen → Lateral movement door organization. aangepaste scripts zijn ook zeer moeilijk te auditen - er zijn honderden plekken waar scripts embedded kunnen zijn (web parts, page layouts, master pages, site columns, content types). Het blokkeren van aangepaste scripts via DenyAddAndCustomizePages elimineert deze Aanvalsoppervlak volledig. Site functionality blijft volledig behouden - moderne SharePoint features zoals web parts, document libraries, lists werken normaal. Alleen legacy aangepaste script injection wordt geblokkeerd.

PowerShell Modules Vereist
Primary API: SharePoint Online PowerShell
Connection: Connect-SPOService
Required Modules: Microsoft.Online.SharePoint.PowerShell

Implementatie

Deze control verifieert dat de DenyAddAndCustomizePages property is gezet op True voor alle SharePoint site collections. Deze setting voorkomt: Uploaden van aangepaste master pages en page layouts, Gebruik van SharePoint Designer voor site aanpassingen, Embedden van JavaScript in content editor web parts, aangepaste script injection via site columns/content types, User aangepaste actions met embedded scripts, en iFrames met external sources. De setting dwingt af dat alleen Microsoft-approved, security-reviewed SharePoint features kunnen worden gebruikt. Exception: Communication sites en moderne team sites hebben stricter regelt en aangepaste scripts zijn standaard al blocked. Legacy classic sites vereisen expliciete DenyAddAndCustomizePages is True. Implementeeratie: Per site via Set-SPOSite -DenyAddAndCustomizePages $true of tenant-wide Standaard beleid.

Vereisten

Voor het Implementeereren van deze control zijn de volgende vereisten van toepassing:

  1. SharePoint Online subscription (deel van M365)
  2. SharePoint Administrator of Globale beheerder rechtenistrator rol
  3. PowerShell met Microsoft.Online.SharePoint.PowerShell module
  4. Inventarisatie van legacy aangepaste solutions (kunnen worden impacted)
  5. Migration plan voor sites die aangepaste scripts gebruiken (migreer naar moderne alternatieven)
  6. Testing environment voor verification
  7. Communication naar site owners over aangepaste script restrictions

Implementeeratie

GEFASEERDE ImplementeerATIE (AANBEVOLEN):

  1. FASE 1 - INVENTORY (Week 1): List alle site collections: Get-SPOSite -Limit All, Controleer aangepaste script status: Get-SPOSite | Select Url,DenyAddAndCustomizePages, Identify sites met DenyAddAndCustomizePages is False (aangepaste scripts allowed), Document business justification voor aangepaste scripts
  2. FASE 2 - beoordeling (Week 2-3): Voor sites met aangepaste scripts Schakel ind: Audit wat exact gebruikt wordt (SharePoint Designer customizations? Content Editor Web Parts? aangepaste master pages?), Evaluate alternatieven: Modern web parts, SPFx solutions (security-reviewed), Power Apps, Review impact op site functionality
  3. FASE 3 - MIGRATION (Week 4-6): Migreer aangepaste solutions naar moderne alternatieven, Test functionality op development sites, Obtain site owner sign-off, Document migration voor audittrail
  4. FASE 4 - ENFORCEMENT (Week 7+): Schakel in DenyAddAndCustomizePages voor alle sites via Set-SPOSite -Identity -DenyAddAndCustomizePages $true, Set tenant Standaard voor nieuwe sites, monitoren voor ondersteunen tickets, Review exceptions quarterly

Gebruik PowerShell-script custom-script-sites-restricted.ps1 (functie Invoke-Monitoring) – PowerShell script voor auditing van aangepaste script settings over site collections.

PowerShell Implementeeratie:

  1. Stap 1: Verbind met SharePoint Online: Connect-SPOService -Url https://TENANT-admin.sharepoint.com
  2. Stap 2: List non-compliant sites: Get-SPOSite -Limit alle | Where-Object {$_.DenyAddAndCustomizePages -eq $false} | Select Url
  3. Stap 3: Schakel in voor specifieke site: Set-SPOSite -Identity -DenyAddAndCustomizePages $true
  4. Stap 4: Bulk Schakel in voor alle sites: Get-SPOSite -Limit alle | Set-SPOSite -DenyAddAndCustomizePages $true
  5. Stap 5: Verifieer: Get-SPOSite -Limit alle | Where-Object {$_.DenyAddAndCustomizePages -eq $false} (should return nul results)

KRITIEK: Test eerst op development/Test sites voordat je tenant-wide Implementeer! aangepaste script blocking kan legacy solutions broken.

monitoring

Gebruik PowerShell-script custom-script-sites-restricted.ps1 (functie Invoke-Monitoring) – Controleert DenyAddAndCustomizePages status voor alle site collections.

Continue monitoring via:

  1. Weekly: Get-SPOSite audit voor DenyAddAndCustomizePages is False (non-compliant sites)
  2. Alert op nieuwe sites met aangepaste scripts Schakel ind
  3. Review SharePoint audit logs: aangepaste script usage attempts (blocked actions)
  4. Site owner requests voor aangepaste script exceptions (evaluate carefully)
  5. Quarterly review: Are exceptions nog steeds justified? Can ze worden gemigreerd?
  6. Security monitoring: XSS attack attempts in audit logs
  7. User feedback: Broken functionality reports (may indicate dependency op aangepaste scripts)

Remediatie

Gebruik PowerShell-script custom-script-sites-restricted.ps1 (functie Invoke-Remediation) – Herstellen.

Voor sites waar aangepaste scripts nog Schakel ind zijn:

  1. Immediate: Set-SPOSite -Identity -DenyAddAndCustomizePages $true
  2. Investigate: Waarom was aangepaste script nodig? Business justification?
  3. Alternative solutions: Modern web parts, SPFx, Power Apps, SharePoint Framework
  4. Voor legitimate aangepaste functionality: Develop SPFx solution (security-reviewed, sandboxed)
  5. Document exception: If aangepaste scripts moet remain (zeer zeldzaam), document risk acceptance, compensating controls, review date

Voor broken functionality na aangepaste script blocking:

  1. Identify exact functionality die broke (specific web part? Page layout?)
  2. Option 1: Rebuild met moderne SharePoint features (preferred)
  3. Option 2: Migrate naar SPFx solution (security-reviewed)
  4. Option 3: Temporary exception MET approval EN scheduled remediation date
  5. Option 4: Alternative tools (Power Apps, Power Automate, Azure Functions)
  6. DO NOT permanent Sta toe aangepaste scripts - find veilige alternative

Compliance en Auditing

Deze control draagt bij aan compliance met meerdere frameworks:

  1. CIS Microsoft 365 Foundations Benchmark - control 3.1.1 (Zorg ervoor dat SharePoint Online aangepaste script execution is Schakel uitd)
  2. BIO 14.02.05 - veilige application development - Script injection preventie
  3. ISO 27001:2022 A.8.23 - Web filtering - Malicious code prevention
  4. ISO 27001:2022 A.14.2.1 - veilige development beleid
  5. NIS2 Artikel 21 - Cybersecurity measures - Preventing malicious Code-uitvoering
  6. OWASP Top 10 A03:2021 - Injection (inclusief XSS attacks)
  7. PCI-DSS Requirement 6.5.7 - Cross-site scripting (XSS) prevention
  8. NIST CSF PR.IP-1 - Baseline configurations - Schakel uit unsafe features

Compliance & Frameworks

Automation

Gebruik het onderstaande PowerShell script om deze security control te monitoren en te implementeren. Het script bevat functies voor zowel monitoring (-Monitoring) als remediation (-Remediation).

PowerShell
<# .SYNOPSIS Custom Script Sites Restricted .DESCRIPTION Restricts custom scripts on all SharePoint sites .NOTES NL Baseline v2.0 Security risk: Custom scripts can introduce XSS vulnerabilities #> #Requires -Version 5.1 #Requires -Modules ExchangeOnlineManagement [CmdletBinding()] param([switch]$Monitoring) $ErrorActionPreference = 'Stop' Write-Host "`n========================================" -ForegroundColor Cyan Write-Host "Custom Script Sites Restricted" -ForegroundColor Cyan Write-Host "========================================`n" -ForegroundColor Cyan function Invoke-Monitoring { try { Write-Host " ⚠️ Manual verification required" -ForegroundColor Yellow Write-Host "`n PowerShell Commands:" -ForegroundColor Cyan Write-Host " Connect-SPOService -Url https://TENANT-admin.sharepoint.com" -ForegroundColor Gray Write-Host " Get-SPOSite | Select-Object Url,DenyAddAndCustomizePages | Where-Object {`$_.DenyAddAndCustomizePages -eq `$false}" -ForegroundColor Gray Write-Host "`n Required Setting:" -ForegroundColor Cyan Write-Host " ✓ All sites should have DenyAddAndCustomizePages = True" -ForegroundColor Gray Write-Host "`n Security Risk:" -ForegroundColor Red Write-Host " • Custom scripts can introduce XSS vulnerabilities" -ForegroundColor Red Write-Host " • Potential for malicious code execution" -ForegroundColor Red Write-Host " • Data exfiltration risk" -ForegroundColor Red Write-Host " • Cross-site scripting attacks" -ForegroundColor Red Write-Host "`n Security Benefits:" -ForegroundColor Cyan Write-Host " • Prevents script injection attacks" -ForegroundColor Gray Write-Host " • Reduces attack surface" -ForegroundColor Gray Write-Host " • Maintains site security" -ForegroundColor Gray Write-Host " • Prevents XSS vulnerabilities" -ForegroundColor Gray Write-Host "`n ⚠️ Security Risk: Custom scripts can introduce XSS!" -ForegroundColor Red exit 0 } catch { Write-Host "ERROR: $_" -ForegroundColor Red exit 2 } } try { if ($Monitoring) { Invoke-Monitoring } else { Write-Host "Use: -Monitoring" -ForegroundColor Yellow } } catch { throw } finally { Write-Host "`n========================================`n" -ForegroundColor Cyan } function Invoke-Remediation { <# .SYNOPSIS Herstelt de configuratie naar de gewenste staat .DESCRIPTION Dit is een monitoring-only control, remediation delegeert naar monitoring #> [CmdletBinding()] param() Write-Host "[INFO] Dit is een monitoring-only control" -ForegroundColor Yellow Write-Host "[INFO] Running monitoring check..." -ForegroundColor Cyan Invoke-Monitoring }

Risico zonder implementatie

Risico zonder implementatie
High: HOOG RISICO: aangepaste scripts in SharePoint maken Cross-Site Scripting (XSS) attacks mogelijk waarmee aanvallers credentials kunnen stelen, sessies kunnen hijacken, en data kunnen exfiltreren. XSS is OWASP Top 10 threat die leidt tot: Diefstal van inloggegevens via keylogging, phishing overlays op vertrouwde SharePoint sites, malware distribution via iframes, DLP beleid bypassing, en persistent backdoors. Recent breach example: Solarwinds compromised SharePoint sites voor lateral movement. aangepaste scripts zijn zeer moeilijk te auditen (honderden injection points mogelijk).

Management Samenvatting

Blokkeer aangepaste scripts op alle SharePoint sites via DenyAddAndCustomizePages is True. Voorkomt XSS attacks, script injection en data exfiltration. Moderne SharePoint features blijven volledig werken. Voldoet aan CIS 3.1.1 L1, OWASP A03:2021, PCI-DSS 6.5.7. Implementeeratie: 8-16 uur inclusief inventory en migration planning. Voor legacy aangepaste solutions: migreer naar SPFx (security-reviewed) of moderne alternatieven.