Summary
Nuxt versions before 3.4.2 have a file-read vulnerability in the vite-node development server middleware. An unauthenticated attacker who can reach an exposed middleware endpoint may supply an absolute path to read files accessible to the server process.
Affected context
The issue affects Nuxt 3.0.0 before 3.4.2 when the vite-node development server middleware is available and reachable. The middleware handles requests to /__nuxt_vite_node__/module/; accepting an absolute path as the module identifier can expose files readable by the process.
Exploit preconditions
- Attack surface: The vite-node development server middleware endpoint
- Required access: Network access to the endpoint; authentication is not required
- Trigger point: A GET request to
/__nuxt_vite_node__/module/with an absolute path as the module identifier - Why exploitation is possible: The middleware may process an absolute path without adequately restricting file access to an intended directory
Why this happens
The underlying issue is insufficient path validation and containment when handling a module identifier. If an absolute path is accepted without checking that the resolved file remains within an authorized directory, a request can access files outside the intended scope. This behavior is associated with CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal').
Potential impact
- An attacker may read sensitive files accessible to the server process
- Exposed files could reveal secrets, configuration, or other confidential information
- Disclosure of sensitive data could support further attacks against the application or its environment
General mitigation guidance
Common defensive patterns focus on limiting file access and reducing exposure:
- Resolve requested paths and enforce that they remain within an explicitly allowed directory
- Prefer a strict allowlist of permitted module identifiers over accepting arbitrary paths
- Keep development middleware disabled or inaccessible in environments where it is not needed
- Run the server with least-privilege filesystem permissions so it can access only required files
- Treat request-derived path values as untrusted and validate them before file operations
How teams detect issues like this
High-level detection approaches include:
- Review file-serving and module-loading code for use of request-controlled paths without canonicalization and directory-boundary checks
- Use static analysis to flag filesystem operations that receive unsanitized request values
- Monitor logs for requests to the vite-node module endpoint containing absolute paths or unusual path patterns
- Enforce deployment policies that restrict access to development middleware in production environments
- Use automated code review checks to identify unsafe path construction and file-access patterns

