CVE-2024-36137 Overview
A vulnerability has been identified in Node.js affecting users of the experimental permission model when the --allow-fs-write flag is used. The Node.js Permission Model does not operate on file descriptors, however, operations such as fs.fchown or fs.fchmod can use a "read-only" file descriptor to change the owner and permissions of a file, effectively bypassing the intended security restrictions.
Critical Impact
This vulnerability allows attackers to modify file ownership and permissions using read-only file descriptors, potentially bypassing the experimental permission model's security controls and enabling unauthorized file system modifications.
Affected Products
- Node.js (versions using experimental permission model)
- Systems utilizing --allow-fs-write flag
- Applications relying on Node.js permission model for file system security
Discovery Timeline
- 2024-09-07 - CVE-2024-36137 published to NVD
- 2024-11-22 - Last updated in NVD database
Technical Details for CVE-2024-36137
Vulnerability Analysis
This vulnerability represents an Authorization Bypass in Node.js's experimental permission model. The core issue stems from a fundamental design gap where the permission model validates file paths but fails to enforce the same restrictions on file descriptor-based operations.
When a user opens a file with read-only permissions through the permission model, the resulting file descriptor can still be used with certain file system operations that should require write permissions. Specifically, the fs.fchown() and fs.fchmod() functions accept file descriptors and can modify file ownership and permissions without triggering the permission model's validation logic.
This creates a security gap where an attacker with limited read access could escalate their capabilities to modify critical file attributes, potentially leading to privilege escalation scenarios or enabling subsequent attacks against protected files.
Root Cause
The root cause lies in the incomplete implementation of the Node.js experimental permission model. While the model correctly restricts path-based file operations, it does not extend these restrictions to file descriptor-based operations. The fs.fchown() and fs.fchmod() functions operate directly on file descriptors rather than paths, bypassing the permission checks that are path-centric in nature.
Attack Vector
The attack requires local access to the system and involves exploiting the gap between path-based and file descriptor-based permission enforcement. An attacker would:
- Obtain a read-only file descriptor through permitted operations
- Use the file descriptor with fs.fchown() or fs.fchmod() to modify file metadata
- Change ownership or permissions to gain additional access to the file
The vulnerability is exploited locally, requiring the attacker to have some level of access to execute Node.js code with the permission model enabled.
Detection Methods for CVE-2024-36137
Indicators of Compromise
- Unexpected calls to fs.fchown() or fs.fchmod() functions in Node.js applications using the permission model
- File ownership or permission changes on files that should be protected by the permission model
- Anomalous file descriptor usage patterns where read-only descriptors are passed to write-oriented functions
- Log entries indicating permission model bypass attempts
Detection Strategies
- Monitor Node.js applications using the experimental permission model for calls to fs.fchown() and fs.fchmod() with file descriptors obtained from read-only operations
- Implement file integrity monitoring on critical files to detect unauthorized ownership or permission changes
- Review application code for patterns that open files with limited permissions but subsequently use the file descriptor for metadata modifications
- Enable verbose logging for permission model operations to identify potential bypass attempts
Monitoring Recommendations
- Deploy file system auditing to track chown and chmod operations on sensitive files
- Implement runtime application self-protection (RASP) solutions that can monitor Node.js function calls
- Establish baseline behavior for file descriptor operations in Node.js applications to detect anomalies
- Configure alerts for permission or ownership changes on files within protected directories
How to Mitigate CVE-2024-36137
Immediate Actions Required
- Update Node.js to the latest patched version that addresses this vulnerability
- Review applications using the experimental permission model to identify potential exposure
- Implement additional access controls at the operating system level for critical files
- Consider disabling the experimental permission model until patches are applied if file system security is critical
Patch Information
Node.js has released security patches addressing this vulnerability as part of their July 2024 security releases. Organizations should consult the Node.js July 2024 Vulnerability Blog for specific version information and upgrade instructions. Additionally, NetApp users should review the NetApp Security Advisory NTAP-20241122-0005 for product-specific guidance.
Workarounds
- Avoid using the experimental permission model for security-critical applications until the vulnerability is patched
- Implement additional file system permissions at the OS level to restrict chown and chmod operations
- Use application-level validation to prevent fs.fchown() and fs.fchmod() calls on file descriptors obtained through read operations
- Consider running Node.js applications in containerized environments with restricted capabilities to limit the impact of permission changes
# Example: Restrict file capabilities at the OS level
# Remove chown capability from Node.js process
setcap -r /usr/bin/node
# Use file system ACLs to protect critical files
setfacl -m u:nodeuser:r-- /path/to/protected/file
Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.


