Definition
ColdFusion Sandbox Security is a built‑in, configurable Security feature in Adobe ColdFusion and Lucee CFML that restricts what CFML code can do at runtime. A “sandbox” defines a controlled environment—usually tied to a directory or application root—where only specific resources and operations are allowed. Think of it as a whitelist-based permission model that limits file system access, database connections, CFML tags and functions, and certain system-level Features.
By isolating code within clearly defined boundaries, sandboxing helps prevent unauthorized file access, data exfiltration, command execution, and other high‑risk actions, especially in multi-tenant or Shared hosting environments.
Why Sandbox security Matters
- Enforces the principle of least privilege in CFML applications.
- Reduces blast radius if a vulnerability or malicious code is introduced.
- Helps meet Compliance requirements by controlling access to files, data sources, and system interfaces.
- Enables safer Shared hosting by isolating apps from each other.
How ColdFusion Sandbox Security Works
Scope and Security Contexts
- A sandbox is created as a “security context” associated with a directory (for example, your application root).
- All code running from that directory and its subdirectories inherits the sandbox permissions.
- There is typically a default context that applies when no explicit sandbox matches.
- Administration is done via the ColdFusion Administrator (Adobe CF) or the Lucee Server/Web Administrator.
What You Can Restrict
- File system access:
- Allow/deny read, write, execute, and directory listing operations.
- Restrict to specific directories (e.g., only allow writing to /uploads).
- Data sources (DSNs):
- Whitelist the DSNs an application can use in cfquery or ORM.
- CFML tags:
- CFML functions:
- Control functions such as FileWrite, DirectoryList, CreateObject, and others that can touch the file system, network, or the JVM.
- System-like Features:
- Limit or deny access to CreateObject(‘java’), COM/.NET Integration (on Windows), registry, and other privileged integrations.
Enforcement and Errors
- At runtime, ColdFusion checks the current code’s directory against the active sandbox rules.
- If a disallowed operation is attempted, ColdFusion throws a security exception (e.g., coldfusion.security.SecurityException).
- Violations are logged (e.g., Exception log or Security log), aiding Troubleshooting and audits.
Configuration Steps (Adobe ColdFusion)
Follow these steps in the Adobe ColdFusion Administrator:
-
Enable Sandbox Security
- Navigate to Security > Sandbox Security.
- Check “Use Sandbox Security.”
- Save changes.
-
Create a Security Context (Sandbox)
- Add a new context mapped to your application’s root directory (e.g., C:\websites\myapp or /var/www/myapp).
-
Define File System Permissions
- Allow read access to your app’s code directories.
- Allow write access only where necessary (e.g., /uploads, /tmp).
- Avoid granting access to system directories or other apps.
-
Whitelist Data Sources
- Select only the DSNs your app legitimately uses.
- Avoid broad permissions like “All DSNs.”
-
Control Tags and Functions
- Start with restrictive defaults.
- Explicitly allow only the tags/functions your app needs.
- Keep dangerous operations like CFEXECUTE and CreateObject(‘java’) disallowed unless absolutely required and risk-assessed.
-
Verify Admin/Service Access
- Ensure the sandbox does not grant access to the ColdFusion Administrator or other sensitive services.
-
Test and Iterate
- Run your app and watch logs for sandbox violations.
- Adjust permissions narrowly based on observed needs.
-
Set a Safe Default Context
- Configure a minimal default policy for any code that doesn’t match an explicit sandbox.
Tip: In modern Adobe ColdFusion versions, use the cfsetup CLI to script and version-control your Administrator settings, including sandbox definitions, for repeatable deployments.
Configuration Steps (Lucee CFML)
- Open the Lucee Server or Web Administrator.
- Go to Security > Sandbox and enable sandboxing for the desired context (typically per Web context).
- Create a sandbox for your app’s directory.
- Set permissions by category:
- File access (paths with read/write/execute/list).
- Datasources allowed.
- Tags and functions allowed/denied.
- Apply changes and test your application.
- Adjust rules iteratively until your app runs with the least privilege necessary.
Note: UI terms differ slightly from Adobe CF, but the model—directory-based context and whitelisted permissions—is similar.
Scenario: A hosting provider runs multiple customers on one ColdFusion server. Each customer has a separate webroot.
Sandbox design:
- Create a sandbox per customer directory (e.g., D:\sites\custA and D:\sites\custB).
- File permissions:
- custA: read access to D:\sites\custA, write only to D:\sites\custA\uploads.
- custB: read access to D:\sites\custB, write only to D:\sites\custB\uploads.
- DSNs:
- custA can use DSN “custA_db”; custB can use “custB_db.” No cross-access.
- Tags and functions:
- Disallow CFEXECUTE, CFREGISTRY, CreateObject(‘java’).
- Allow CFFILE only for write in /uploads and read in the app directory.
- Result:
- If custA’s code tries to read D:\sites\custB\config.cfm or execute an OS command, a security exception is thrown and logged.
- Both customers run safely side-by-side with tight isolation.
Example of a blocked operation (Adobe CFML):
- Code:
-
- Effect:
- Security exception due to blocked CFEXECUTE within the sandbox.
Example of a permitted operation:
- Code:
-
- Effect:
- Succeeds if “./uploads” is whitelisted for write.
Best practices and Patterns
Least-Privilege Checklist
- Map each application to its own sandbox context by directory.
- Allow only the exact paths your app must read or write.
- Whitelist only the DSNs the app uses.
- Deny or remove high-risk capabilities: CFEXECUTE, CreateObject(‘java’), registry access, and arbitrary file operations.
- Keep a minimal default context that denies most operations.
- Combine sandboxing with OS file permissions, patching, and WAF/IDS controls.
- Monitor logs for sandbox violations and investigate promptly.
- Script your configuration changes (e.g., cfsetup for Adobe CF) for consistency across environments.
What to Avoid
- Avoid broad wildcards like granting write to your entire webroot.
- Don’t rely solely on sandboxing; it is defense in depth, not a silver bullet.
- Don’t grant Java object creation unless you fully trust the code and understand the risk.
- Avoid granting “All DSNs” or allowing network/HTTP tags without need.
Pros and cons
Pros:
- Strong isolation for CFML applications and tenants.
- Reduces impact of vulnerabilities and misconfigurations.
- Aids Compliance by enforcing auditable runtime controls.
- Flexible and granular permissions (files, DSNs, tags, functions).
Cons:
- Requires careful planning and administrative overhead.
- Can cause initial compatibility issues until permissions are tuned.
- Developers may need to adjust code paths and deploy strategies.
- Potential for misconfiguration if not tested thoroughly.
Key Points and Quick reference
- Sandbox Security imposes a whitelist of allowed operations based on directory context.
- Control spans: file system, data sources, CFML tags, functions, and some system integrations.
- Use least privilege: allow only what your application demonstrably needs.
- Test changes under realistic workloads; watch for SecurityException logs.
- Treat sandboxing as part of a layered security program with OS hardening and ColdFusion Lockdown guidance.
Common pitfalls and Troubleshooting
- “It worked on dev, fails on prod”: Ensure prod sandbox includes the same directories (e.g., temp, uploads) and DSNs.
- Scheduled tasks failing: The task runs code within a directory; apply the same sandbox rules to that directory and allow any required write paths.
- Path mismatches: On Linux, case sensitivity matters; use ExpandPath and consistent casing.
- Unclear violation source: Check Exception/Security logs to identify the exact tag/function and path being blocked.
- Over-broad defaults: A permissive default context can quietly bypass protections. Keep it minimal and define explicit contexts.
Adobe ColdFusion vs. Lucee CFML: A Quick Comparison
- Administration:
- Adobe CF: Security > Sandbox Security in the CF Admin; cfsetup for scripted config.
- Lucee: Security > Sandbox in Server/Web Admin.
- Permissions model:
- Both support directory-based contexts with whitelists for file, DSNs, tags/functions.
- Granularity:
- Both provide granular control; naming and UI differ slightly.
- Deployment:
- Scripted/automated configuration is recommended in both; tooling differs.
FAQ
How is sandbox security different from server lockdown or OS permissions?
Sandbox security controls what CFML code can do at runtime, from within the ColdFusion engine. Server lockdown (web server connectors, admin hardening) and OS permissions operate outside ColdFusion. Use all three together: OS ACLs, ColdFusion lockdown, and sandboxing provide layered protection.
Can I enable sandbox security per application instead of server-wide?
You enable sandboxing at the server level, then define per-directory contexts that effectively enforce it per application. Each app gets its own sandbox by mapping its root directory and specifying granular permissions.
Will sandboxing slow down my application?
The Performance overhead is typically small and outweighed by the security benefits. Most apps see negligible impact when permissions are carefully scoped. If you notice latency, profile your app to ensure sandbox checks aren’t masking other bottlenecks.
What if my application needs CFEXECUTE or CreateObject(‘java’)?
Treat such requirements as high risk. Prefer safer alternatives (native CFML features, vetted libraries, or external services). If you must allow them, restrict usage to specific directories and ensure strong code reviews, logging, and monitoring.
Do Scheduled tasks and REST endpoints respect sandbox rules?
Yes. The rules apply based on the directory of the code being executed. Ensure that folders hosting scheduled scripts or REST handlers are covered by the right sandbox context and have the required file/DSN permissions.
