Summary
SurrealDB's Windows bucket storage can interpret backslashes in object keys as directory separators even though its traversal check only examines forward slashes. If an attacker can submit crafted keys to the affected storage layer, they may bypass the check and read or modify files in other buckets.
Affected context
The issue affects SurrealDB versions 3.0.0 up to, but not including, 4.0.0 when using the bucket storage layer on Windows. It occurs when object keys are checked for traversal using one path-separator convention but later converted to operating-system paths using Windows separator behavior.
Exploit preconditions
- Attack surface: Object-key handling in the bucket storage layer on Windows
- Required access: Ability to submit or control object keys through an exposed bucket operation
- Trigger point: The key is checked and then converted into a filesystem path
- Why exploitation is possible: The traversal check splits on forward slashes, while Windows path handling also treats backslashes as directory separators
Why this happens
The underlying bug is inconsistent path interpretation across validation and filesystem access. A check that recognizes only one separator can miss traversal when a later path conversion treats another character as a separator. This is a path traversal weakness, mapped to CWE-22: Improper Limitation of a Pathname to a Restricted Directory.
Potential impact
- An attacker may read files belonging to other buckets.
- An attacker could modify files outside the intended bucket boundary.
- Data confidentiality or integrity across storage buckets may be affected.
General mitigation guidance
Defensive patterns focus on ensuring that validation and filesystem resolution use consistent, platform-aware path semantics.
- Prefer storage APIs that keep object names separate from filesystem paths.
- Normalize and canonicalize paths before enforcing directory boundaries, then verify the resolved path remains within the intended bucket.
- Reject path components that could escape the storage root, accounting for separators used by the target operating system.
- Restrict access to bucket operations and run storage processes with only the filesystem permissions they need.
- Treat object keys as untrusted input, even when they originate from authenticated clients.
How teams detect issues like this
- Use static analysis or targeted searches to identify path checks that recognize fewer separators than the later filesystem APIs.
- Review code paths that construct filesystem paths from object keys, especially where validation and path resolution use different libraries or normalization rules.
- Add policy checks and tests for platform-specific path handling and for ensuring resolved paths remain within their intended storage roots.
- Monitor access patterns for object operations that target unexpected bucket paths.

