You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 396504b
Browse filesBrowse the repository at this point in the historyBrowse files
fix: harden lock contention and permission verification (#101)
Stress testing the locking and permission surfaces found seven defects.
Empty icacls output was accepted as verified ACL data, so an inspection that
returned nothing parseable produced a permissive answer instead of failing
closed. Sidecar inspection could follow a pathname swapped to a symlink, and
both the async and sync sidecar reads were unbounded. Foreign synchronous
.reclaim guards could be deleted after mkdir reported EEXIST. An old mtime
overrode a valid future createdAt, falsely marking live locks stale. Sync
acquisition spun forever on dangling-symlink sidecars, ignoring timeoutMs: 0.
Every lock-manager domain permanently added another exit listener.
Mutual exclusion itself held: forty in-process contenders and eight real child
processes never overlapped. Reentrant-owner isolation, double release, throw
cleanup, the eight-retry Windows boundary, durability semantics, and descriptor
and process-handle accounting all verified clean.
PID reuse remains application-owned through shouldReclaim, and corrupt or
truncated lock files remain fail-closed.
Copy file name to clipboardExpand all lines: CHANGELOG.md
+2Lines changed: 2 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,6 +4,8 @@
4
4
5
5
### Security and Correctness
6
6
7
+
- Reject non-file sidecars without spinning, and read contended async and synchronous sidecar locks through bounded, no-follow, identity-checked descriptors; keep valid `createdAt` timestamps authoritative under filesystem clock skew; fail closed when fallback Windows ACL inspection returns no verifiable access entries; preserve synchronous stale-reclaim guards owned by another acquirer; and share one process-exit cleanup listener across file-lock manager domains.
8
+
7
9
- Route `Root.copyIn()` and overwrite-capable `Root.write()` commits through a new descriptor-relative native replace rename, closing a parent-symlink swap that could create a missing destination directory outside the root before the JavaScript fallback detected the escape. Native `auto` and `require` mode now protect both create-only and replacing pinned writes; the explicitly best-effort JavaScript fallback remains available in `off` mode or when `auto` cannot load a binding.
8
10
9
11
- Apply `movePathWithCopyFallback()` file and POSIX directory modes through staging descriptors before publication, so a replaceable staging pathname cannot redirect `chmod` to an unrelated symlink target. Windows no longer uses a pathname fallback for directory modes because Node cannot portably open a directory descriptor there and does not enforce POSIX modes.
Copy file name to clipboardExpand all lines: docs/sidecar-lock.md
+15-5Lines changed: 15 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -96,6 +96,12 @@ type FileLockRetryOptions = {
96
96
result is passed to `shouldReclaim` and `shouldRemoveStaleLock`, allowing PID,
97
97
process-start, argv, or role schemas to remain application-owned.
98
98
99
+
On Windows, a pathed `EPERM` from creating or opening the lock file can be a
100
+
short teardown race after another holder unlinks it. The async lock retries that
101
+
specific denial at most eight times. A parent-directory denial, a denial from a
102
+
callback, or a ninth consecutive lock-file denial surfaces as the original
103
+
`EPERM`; it is not converted to `file_lock_timeout`.
104
+
99
105
## Owner-scoped reentrancy
100
106
101
107
Version 0.5 removes the unsound process-scoped `allowReentrant` boolean and
@@ -167,10 +173,10 @@ progress.
167
173
## Synchronous locks
168
174
169
175
`acquireFileLockSync()` and `withFileLockSync()` mirror filesystem arbitration,
170
-
retry, payload parsing, stale policy, guarded identity-conditioned reclaim,
171
-
verification, and compromise monitoring. They do not use the async manager
172
-
queue, support async callbacks, or provide same-process reentrancy. Retry waits
173
-
block the calling thread; use the async API in request-serving code.
176
+
retry, payload parsing, stale policy, owner-scoped reentrancy, guarded
177
+
identity-conditioned reclaim, verification, and compromise monitoring. They do
178
+
not use the async manager queue or support async callbacks. Retry waits block
179
+
the calling thread; use the async API in request-serving code.
174
180
175
181
Always release in a `finally`:
176
182
@@ -236,7 +242,11 @@ await locks.drain();
236
242
237
243
## Stale policy: `shouldReclaim`
238
244
239
-
The default policy treats locks whose `createdAt` is older than `staleMs` as stale. Pass a custom callback when you want a richer notion of "is the holder still alive":
245
+
The default policy treats locks whose valid `createdAt` is older than `staleMs`
246
+
as stale. A valid current or future timestamp remains authoritative under
247
+
filesystem clock skew; only absent or malformed timestamps fall back to the
248
+
sidecar `mtime`. Pass a custom callback when you want a richer notion of "is the
0 commit comments