Skip to content

Commit 4e85b67

Browse files
authored
docs(security): clarify resolver exposure (#66)
1 parent 3749731 commit 4e85b67

3 files changed

Lines changed: 19 additions & 1 deletion

File tree

‎CHANGELOG.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
### Security and Correctness
1515

16-
- **Security:** Resolve symlink aliases component-by-component before applying later `..` segments in the exported root-path validator, and validate raw `root()` inputs before normalized I/O, preventing alias-dependent traversal from being approved under a different lexical path.
16+
- **Security — `resolveRootPath()` / `resolveRootPathSync()`:** Published releases through 0.4.7 validated a lexically normalized path spelling, so a caller-supplied path traversing an in-root symlink could pass validation while resolving outside the root. Version 0.5 fixes this with component-wise alias resolution. `root()` handles were **not** affected: their operations have contained this case since `5ddca80`, so exposure is limited to direct users of these two exported helpers.
1717
- Prefer macOS 15.4's `O_RESOLVE_BENEATH` for native opens, retain the guarded component walk on older kernels, and apply an `F_GETPATH` post-open escape detector to both routes without claiming rename-race atomicity.
1818
- Report open containment explicitly: native `openBeneath()` returns `{ fd, containment }` with `kernel-atomic` on Linux and `best-effort` on macOS/Windows, while JavaScript root open/read/writable results report `best-effort`.
1919
- Serialize async `jsonStore` writes and read-modify-write updates in-process by canonical store path before taking the cross-process sidecar lock, preventing overlapping `write`, `update`, and `updateOr` calls from silently losing updates; reject nested same-path mutations with typed `store-reentrant-update` errors. Thanks @yetval for reporting this.

‎docs/migrating-to-0.5.md‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,11 @@ optional.
2121
import fs-safe, but native-only features and missing JS archive decoders fail
2222
with actionable errors.
2323

24+
If you call `resolveRootPath()` or `resolveRootPathSync()` directly, upgrade to
25+
0.5: versions through 0.4.7 could approve an in-root symlink traversal that
26+
resolved outside the root. `root()` handles were not affected. See the
27+
[affected versions and exposure](security-model.md#affected-versions-exposure).
28+
2429
## 2. Replace Python helper configuration
2530

2631
Change startup configuration before the first filesystem operation:

‎docs/security-model.md‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,19 @@
44

55
The same shape exists in other languages: Go's [`os.Root` / `OpenInRoot`](https://go.dev/blog/osroot) and Rust's [`cap-std`](https://github.com/bytecodealliance/cap-std) both expose a root handle whose operations refuse to escape it. `fs-safe` is the Node-side equivalent: a single `root()` capability that carries the boundary across every read, write, move, and remove, instead of leaving each call site to redo `path.resolve(...).startsWith(...)` and hope.
66

7+
## Affected versions / exposure
8+
9+
In published releases through 0.4.7, the exported `resolveRootPath()` and
10+
`resolveRootPathSync()` helpers validated a lexically normalized path spelling.
11+
A caller-supplied path traversing an in-root symlink could therefore pass
12+
validation while resolving outside the root. Version 0.5 fixes this with
13+
component-wise alias resolution, resolving each alias before applying later
14+
path components.
15+
16+
`root()` handles were **not** affected: their operations have contained this
17+
case since `5ddca80`. Exposure is limited to consumers that call
18+
`resolveRootPath()` or `resolveRootPathSync()` directly.
19+
720
## Threat model
821

922
You hand a `root()` boundary to a piece of code that takes caller-controlled relative paths. The library defends against a caller that:

0 commit comments

Comments
 (0)