NocoBase Authenticated Remote Code Execution via File Write and LFI Chain
An authenticated admin can achieve remote code execution in NocoBase prior to v2.1.5 by chaining arbitrary file uploads via storage root manipulation with a local file inclusion vulnerability in the plugin manager.
NocoBase versions prior to 2.1.5 contain a high-severity authentication-based remote code execution (RCE) chain. The vulnerability arises from two distinct flaws in the API surface that allow an authenticated administrative user to bypass file system protections. First, the storages:update API fails to validate the documentRoot parameter, enabling an attacker to redirect the application's file storage root to arbitrary locations on the host disk, including system or application directories. Second, the pm:enable endpoint performs an unsanitized require() call on a user-supplied filterByTk parameter, acting as a local file inclusion (LFI) primitive. By uploading a malicious JavaScript file to the application directory using the first vulnerability and subsequently triggering it via the LFI endpoint, an attacker can execute arbitrary code within the Node.js server process. The LFI primitive can also be exploited independently to induce error-based disclosure of sensitive system files.
Attack Chain
- Attacker authenticates to the NocoBase instance with administrative credentials.
- Attacker queries the
/api/storagesendpoint to identify thefilterByTkID for the active local storage configuration. - Attacker sends a POST request to
/api/storages:updatewith a crafteddocumentRootparameter set to the application's root directory (e.g., "."). - Attacker uploads a malicious Node.js payload via the
/api/attachments:uploadendpoint, which is now saved to the application's base path due to the modifieddocumentRoot. - Attacker calls the
/api/pm:enableendpoint, supplying the path to the previously uploaded malicious file in thefilterByTkparameter. - The application backend passes the unsanitized path directly to
require(), executing the uploaded JavaScript payload. - The malicious code executes with the privileges of the NocoBase server process, achieving persistent RCE.
Impact
Successful exploitation grants an authenticated attacker full remote code execution on the underlying host. Given that NocoBase often runs with elevated privileges (e.g., as root in default Docker configurations), this leads to a complete compromise of the application and the host server. Additionally, the LFI primitive allows for the unauthorized reading of sensitive files from the server's filesystem, facilitating further reconnaissance or credential theft.
Recommendation
- Immediately upgrade all NocoBase deployments to version 2.1.5 or later to resolve the missing input validation in the storage and plugin management components.
- Audit administrative access logs for unauthorized access to the
storages:updateandpm:enableendpoints. - Restrict access to administrative API endpoints to trusted management networks.
- Deploy the suggested Sigma rule to monitor for unusual
require()activity originating from the plugin manager path.
Immediate actions
Upgrade @nocobase/server to version 2.1.5 or later.
Threat Hunt
Search logs for unusual filterByTk parameters containing file paths in /api/pm:enable requests.
Data: Web access logs
Detection coverage 1
Detect NocoBase LFI and RCE Attempt
highDetects unauthorized attempts to trigger require() on arbitrary files via the NocoBase pm:enable endpoint
Detection queries are available on the platform. Get full rules →