Problem
The hardened native scratch cleanup introduced by #168 opens child directories with O_EVTONLY on Darwin, then attempts to enumerate them through /dev/fd/<fd>. An event-only descriptor does not grant directory-read access through /dev/fd, so opendir can fail after repairing the first child. Nested chmod 000 or deny-ACL trees may then remain undeleted and close() can fail.
Relevant locations
packages/code/src/native-scratch.ts, Darwin directory flags around lines 60–63
- traversal/listing around lines 151–153
Suggested direction
Use a descriptor mode on Darwin that preserves the no-follow safety properties while permitting directory enumeration, and add a macOS regression test covering nested protected directories.
Reported while syncing #168 into ClickHouse/ai; Cursor Bugbot discussion: https://github.com/ClickHouse/ai/pull/3673#discussion_r3964522729
Problem
The hardened native scratch cleanup introduced by #168 opens child directories with
O_EVTONLYon Darwin, then attempts to enumerate them through/dev/fd/<fd>. An event-only descriptor does not grant directory-read access through/dev/fd, soopendircan fail after repairing the first child. Nestedchmod 000or deny-ACL trees may then remain undeleted andclose()can fail.Relevant locations
packages/code/src/native-scratch.ts, Darwin directory flags around lines 60–63Suggested direction
Use a descriptor mode on Darwin that preserves the no-follow safety properties while permitting directory enumeration, and add a macOS regression test covering nested protected directories.
Reported while syncing #168 into ClickHouse/ai; Cursor Bugbot discussion: https://github.com/ClickHouse/ai/pull/3673#discussion_r3964522729