Skip to content

Fix Darwin scratch traversal with O_EVTONLY directory descriptors #169

Description

@danny-avila

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions