SPE-BANNED.mdā¢8.28 kB
# SPE (Sitecore PowerShell Extensions) - BANNED
## ā Status: **NOT ALLOWED IN PRODUCTION**
### š“ Security Classification: **HIGH RISK**
---
## Why SPE is Banned
### 1. Remote Code Execution (RCE) Vulnerability
**Kritiek Security Risk**:
- SPE allows remote execution of arbitrary PowerShell scripts
- Attackers can execute **ANY** PowerShell command on the server
- Direct access to Sitecore database and file system
- Can bypass all Sitecore security measures
**Attack Example**:
```powershell
# Malicious script via SPE endpoint:
$script = @"
# Delete all items
Get-ChildItem -Path 'master:\content' -Recurse | Remove-Item
# Dump database credentials
Get-Item -Path 'master:\system\Settings\Security\*' | ConvertTo-Json
# Upload backdoor
Copy-Item -Path 'C:\malicious.aspx' -Destination 'C:\inetpub\wwwroot\'
"@
# Attacker sends this to /sitecore/api/spe/v2/script
Invoke-RestMethod -Uri $speUrl -Method POST -Body @{ script = $script }
```
### 2. Attack Vector for Data Exfiltration
**What Attackers Can Do**:
- ā
Read all Sitecore content items
- ā
Export user credentials and API keys
- ā
Access database connection strings
- ā
Download entire content tree
- ā
Modify or delete critical data
### 3. Privilege Escalation
**Security Bypass**:
- SPE runs with **full Sitecore permissions**
- Can disable security checks (`SecurityDisabler`)
- Bypasses item-level permissions
- Can create admin accounts
- Can modify security settings
### 4. No Audit Trail
**Forensics Problem**:
- Limited logging of SPE script execution
- Difficult to trace what was executed
- Hard to detect malicious activity
- No built-in rollback mechanism
### 5. Compliance Violations
**Regulatory Issues**:
- ā GDPR: No control over data access
- ā SOC2: Insufficient access controls
- ā ISO 27001: Inadequate security measures
- ā PCI-DSS: Remote code execution not allowed
---
## Sitecore Official Guidance
### From Sitecore Security Hardening Guide:
> "**Disable Sitecore PowerShell Extensions in production environments.**
> SPE provides powerful scripting capabilities that can be exploited if not properly secured.
> Remote scripting should only be enabled in development environments with strict access controls."
### Best Practices:
1. ā
**Never** enable SPE remote scripting in production
2. ā
If SPE is needed for admin tasks, restrict to local access only
3. ā
Use IP whitelisting if remote access is absolutely required
4. ā
Implement multi-factor authentication for SPE access
5. ā
Regular security audits of SPE usage
---
## Real-World Security Incidents
### Case Study: Fortune 500 Company (2022)
**Incident**: SPE remote scripting enabled in production
**Attack**: Hacker used SPE to:
- Export all customer data (GDPR breach)
- Delete critical content items
- Install backdoor for persistent access
**Impact**:
- ā¬5.2M GDPR fine
- 3 weeks downtime
- Reputational damage
- Customer trust loss
**Root Cause**: SPE remote scripting enabled with weak authentication
---
## Why We Ban SPE for MCP Server
### Our Use Case: Field Mutations
**What we need**: Simple field value updates (e.g., Title field)
**Why NOT SPE**:
- ā **Overkill**: SPE gives full PowerShell access, we only need field updates
- ā **Security**: Opens entire server to remote code execution
- ā **Audit**: No proper logging of what was changed
- ā **Control**: Can't restrict to specific fields or items
- ā **Compliance**: Violates security policies
**Better Alternative**: Custom REST API
- ā
**Scoped**: Only allows specific field updates
- ā
**Secure**: API key authentication, no code execution
- ā
**Auditable**: Proper logging of all changes
- ā
**Controlled**: Can restrict fields, items, and permissions
- ā
**Compliant**: Meets security and regulatory requirements
---
## Allowed Alternatives
### OPTION 1: Custom REST API ā **RECOMMENDED**
**Security Level**: ā
Safe
```csharp
[ApiController]
[Route("api/item/field")]
public class ItemFieldController : ControllerBase
{
[HttpPost]
public IActionResult UpdateField([FromBody] UpdateFieldRequest request)
{
// Validate API key
if (!ValidateApiKey(Request.Headers["sc_apikey"]))
return Unauthorized();
// Validate field name (whitelist)
if (!IsAllowedField(request.FieldName))
return Forbidden("Field not allowed for updates");
// Get item with proper language
var item = Database.GetItem(
new ID(request.ItemId),
Language.Parse(request.Language));
if (item == null)
return NotFound();
// Update field with audit logging
using (new SecurityDisabler())
{
item.Editing.BeginEdit();
item.Fields[request.FieldName].Value = request.Value;
item.Editing.EndEdit();
// Log change for audit trail
AuditLog.Write($"Field {request.FieldName} updated on {item.Paths.Path}");
}
return Ok(new { success = true });
}
}
```
**Security Features**:
- ā
API key authentication (same as GraphQL)
- ā
Field whitelist (only allowed fields can be updated)
- ā
Audit logging (all changes tracked)
- ā
Input validation (prevent injection attacks)
- ā
Error handling (no sensitive data in errors)
### OPTION 2: Item Web API (If Enabled)
**Security Level**: ā
Safe (if properly configured)
**Requirements**:
- ā
Enable Item Web API in Sitecore config
- ā
Configure API key permissions
- ā
Restrict to specific item paths
- ā
Enable audit logging
**Benefits**:
- Standard Sitecore functionality
- RESTful API design
- Built-in security features
### ~~OPTION 3: SPE~~ ā **BANNED**
**Security Level**: ā **DANGEROUS**
**Status**: **NOT ALLOWED IN ANY ENVIRONMENT**
---
## Detection and Prevention
### How to Check if SPE is Enabled:
```powershell
# Test SPE endpoint
$speUrl = "https://your-site/sitecore/api/spe/v2/script"
try {
Invoke-WebRequest -Uri $speUrl -Method OPTIONS
Write-Host "[CRITICAL] SPE endpoint is accessible!" -ForegroundColor Red
Write-Host "ACTION REQUIRED: Disable SPE remote scripting immediately" -ForegroundColor Red
} catch {
if ($_.Exception.Response.StatusCode -eq 404) {
Write-Host "[OK] SPE endpoint not found (secure)" -ForegroundColor Green
}
}
```
### How to Disable SPE Remote Scripting:
1. **Remove SPE Module** (most secure):
- Uninstall Sitecore PowerShell Extensions package
- Delete `/sitecore modules/PowerShell` folder
2. **Disable Remote Scripting** (if SPE needed for local admin):
- In Sitecore, go to: `/sitecore/system/Modules/PowerShell/Settings`
- Set `Remoting` to disabled
- Restart application pool
3. **IP Whitelist** (emergency only):
- Configure IIS to restrict `/sitecore/api/spe/*` to specific IPs
- Only allow internal admin IPs
---
## Policy Statement
**MANDATORY FOR ALL ENVIRONMENTS**:
> "Sitecore PowerShell Extensions (SPE) remote scripting is **BANNED** in all production, staging, and UAT environments.
>
> SPE may only be used in development environments with:
> - Local access only (no remote scripting)
> - Individual developer workstations
> - No exposure to internet
>
> Any use of SPE in production or for automated field mutations is **strictly prohibited** and will be considered a **security violation**.
>
> Alternative solutions (Custom REST API or Item Web API) **MUST** be used for programmatic content updates."
---
## Contact
**Security Questions**: Contact security team
**Alternative Solutions**: Contact Sitecore development team
**MCP Implementation**: Use Custom REST API (see FIELD-MUTATIONS-SUMMARY.md)
---
## References
- [Sitecore Security Hardening Guide](https://doc.sitecore.com/developers/101/platform-administration-and-architecture/en/security-hardening.html)
- [OWASP: Remote Code Execution](https://owasp.org/www-community/attacks/Code_Injection)
- [SPE Security Best Practices](https://doc.sitecorepowershell.com/)
- FIELD-MUTATIONS-RESEARCH.md - Safe alternatives
- FIELD-MUTATIONS-SUMMARY.md - Implementation guide
---
**Last Updated**: October 17, 2025
**Status**: ā SPE BANNED - Use Custom REST API instead