Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.
Sources: National Vulnerability Database, CISA KEV, Exploit-DB
CVE-2023-54406 Overview
CVE-2023-54406 is a sandbox escape vulnerability in the Frappe framework. The flaw affects Frappe versions before 14.59.0 and 15.x versions before 15.5.0. The vulnerability resides in how Frappe manages the frappe.flags.in_safe_exec global flag during Server Script execution. When one Server Script triggers another, the flag can be reset to False, causing subsequent code to run outside the safe execution sandbox. Authenticated high-privileged users can abuse this behavior to execute code without the intended sandbox restrictions. The issue is classified under CWE-372: Incomplete Internal State Distinction.
Critical Impact
Authenticated high-privileged users can bypass the Frappe Server Script sandbox and execute unrestricted code within the application process.
Affected Products
- Frappe Framework versions before 14.59.0
- Frappe Framework 15.x versions before 15.5.0
- Applications built on vulnerable Frappe versions (including ERPNext deployments)
Discovery Timeline
- 2026-10-12 - CVE-2023-54406 published to NVD
- 2026-10-15 - Last updated in NVD database
Technical Details for CVE-2023-54406
Vulnerability Analysis
Frappe implements a Server Script feature that executes user-authored Python code inside a restricted sandbox. The sandbox relies on a process-global flag, frappe.flags.in_safe_exec, to enforce safe-execution semantics such as restricted builtins and limited attribute access. The framework toggles this flag when entering and exiting the sandboxed execution context.
The vulnerability occurs when a Server Script triggers another Server Script during its execution. For example, saving a document inside the sandbox can invoke document hooks that run additional Server Scripts. When the nested script completes, it resets frappe.flags.in_safe_exec to False. The outer script continues executing, but the sandbox is no longer active for the remaining statements.
Root Cause
The root cause is improper state management of the in_safe_exec flag. The flag is treated as a boolean rather than a counter or stack. A nested exit incorrectly clears the flag for the entire call stack. This is a classic case of incomplete internal state distinction between inner and outer execution contexts.
Attack Vector
Exploitation requires an authenticated user with privileges to create or modify Server Scripts. The attacker crafts a Server Script that performs an action triggering a secondary Server Script, such as frappe.get_doc(...).save() on a document with configured server-side hooks. After the nested call returns, the primary script executes Python operations that would otherwise be blocked by the sandbox, enabling unrestricted access to the Frappe application context. The attack vector is network-based and does not require user interaction.
No verified public exploit code is available. See the GitHub Security Advisory GHSA-v3vh-7qx4-f582 and the VulnCheck advisory for additional technical context.
Detection Methods for CVE-2023-54406
Indicators of Compromise
- Server Script records that invoke frappe.get_doc(...).save() or similar document operations followed by sensitive Python operations such as __import__, open, or attribute access to private objects.
- Unexpected changes to Frappe Server Script documents by System Manager or Script Manager users.
- Audit log entries showing Server Script execution preceding unusual filesystem, network, or subprocess activity by the Frappe application process.
Detection Strategies
- Review all Server Script definitions for nested document-save or script-trigger patterns that could chain multiple scripts.
- Enable and inspect Frappe's Activity Log and Error Log for Server Script execution events correlated with privileged operations.
- Monitor the Frappe application process for child process spawns, outbound connections, or filesystem writes that originate during Server Script execution.
Monitoring Recommendations
- Alert on creation or modification of Server Script documents outside approved change windows.
- Track role assignments for System Manager and any custom role granting Server Script write access.
- Forward Frappe application and web server logs to a centralized analytics platform for correlation with endpoint telemetry.
How to Mitigate CVE-2023-54406
Immediate Actions Required
- Upgrade Frappe to version 14.59.0 or 15.5.0 or later as soon as feasible.
- Audit the list of users with permission to create or modify Server Scripts and remove unnecessary privileges.
- Review existing Server Scripts for nested script invocations and disable any that are not required for business operations.
- Rotate API keys and session secrets if unauthorized Server Script modifications are discovered.
Patch Information
The Frappe maintainers addressed the flaw in versions 14.59.0 and 15.5.0. The fix corrects state management of the frappe.flags.in_safe_exec flag so that nested Server Script execution no longer disables sandboxing for the outer script. Patch details are documented in the GitHub Security Advisory GHSA-v3vh-7qx4-f582.
Workarounds
- Disable the Server Script feature entirely by setting server_script_enabled to 0 in site_config.json until the patch is applied.
- Restrict Server Script creation and modification to a minimal set of trusted administrators.
- Remove or quarantine Server Scripts that call .save(), .insert(), or .submit() on documents configured with additional server-side script hooks.
# Configuration example: disable Server Scripts in Frappe site_config.json
# Edit sites/<your-site>/site_config.json and add:
{
"server_script_enabled": 0
}
# Then restart the Frappe application
bench restart
Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.
Sources: National Vulnerability Database, CISA KEV, Exploit-DB

