Plugin Sandboxing¶
The Sandbox provides a secure execution environment for third-party or untrusted plugins, ensuring they cannot compromise the host system.
Security Layers¶
Xcore applies multiple isolation mechanisms to every sandboxed plugin:
- AST Scanning — Static code analysis before execution to detect forbidden imports.
- Import Restrictions — A
sys.meta_pathhook blocks access to non-whitelisted modules. - Filesystem Guard — Intercepts
open(),pathlib, andosto restrict file access. - Resource Limits — Enforces CPU time, memory (RSS), and disk quotas.
- IPC Protocol — Communication through JSON over stdin/stdout pipes, not shared memory.
Resource Isolation¶
Sandboxed plugins are restricted in their resource consumption to prevent "noisy neighbor" issues or intentional Denial of Service.
Default Limits (integration.yaml)¶
| integration.yaml | |
|---|---|
Per-Plugin Limits (plugin.yaml)¶
| plugin.yaml | |
|---|---|
AST-Based Whitelisting¶
The AST analyzer scans every .py file in the plugin's src/ directory before the first load.
- Allowed: Only modules listed in
security.allowed_importscan be imported. - Blocked: Modules in
security.forbidden_importsraise aPermissionErrorat import time.
| integration.yaml | |
|---|---|
Sandbox Bypass Attempt
Attempting to bypass the sandbox via reflection (__subclasses__, __globals__) or other advanced Python techniques is detected by the AST scanner and will result in the plugin being refused.
Managing the Sandbox¶
Use the sandbox command group to inspect the isolation layer:
| Global sandbox statistics | |
|---|---|
| Inspect a specific plugin | |
|---|---|
Trusted vs. Sandboxed
Plugins run in Sandboxed mode unless execution_mode: trusted is declared in plugin.yaml. A trusted plugin must also be signed when strict_trusted: true is enabled.
See Also¶
- Sandboxed Plugin Development
- How to write plugins designed for sandboxed execution.
- Security Architecture
- Deep dive into the FilesystemGuard and AST scanner.