Skip to content

fix(host-kit): accept a group-writable script directory the user owns - #4799

Merged
thymikee merged 3 commits into
mainfrom
fix/save-script-own-group-writable
Nov 20, 2026
Merged

thymikee merged 3 commits into
mainfrom
fix/save-script-own-group-writable

Conversation

@thymikee

@thymikee thymikee commented Nov 20, 2026 •

Copy link
Copy Markdown
Member

Summary

--save-script now accepts a group-writable directory that the current non-root user owns, to pass through, to hold the script and to hold a link. Under umask 002 every directory a user creates is 0775, so open --save-script=./flows/login.ad in an ordinary checkout was refused until chmod g-w. This reverses the group rule from #4565 by maintainer decision: the rule accepts that directory's group as its owner's responsibility.

Still refused: a directory another user owns (foreign_owned), a non-sticky world-writable directory (world_writable), a group-writable directory root owns (shared_group_writable), and the entry directly inside a shared sticky directory (shared_parent). The Swift helper cache and the daemon state root stay as strict as before. No new option. 10 files.

Security pass

Reviewed as another non-root local user:

  • The only newly accepted ground is owned by the current non-root user, with group write set and world write clear.
  • Ownership and world-write checks still run first.
  • Root-owned ground is unchanged, also for a root process.
  • Exception kept on purpose and documented: members of that directory's group can replace an entry or create the script name first. Where all users share one group, that is every local user.

Validation

At dd4a7b5: typecheck, lint, format, layering and fallow audit --base origin/main pass. Host-kit, host-swift, daemon-contracts, remote and daemon core suites pass. Each new case fails when its part of the rule is broken. check:affected was not run; CI validates the rest.

🤖 Generated with Claude Code

The destination rule refused every non-sticky group-writable directory.
Under umask 002 every directory a user creates is 0775, so a
--save-script path in an ordinary checkout was refused until the chain
was closed with chmod g-w. The owner of a directory chose its group, so
the rule now accepts a group-writable directory the current non-root
user owns, to pass through, to hold the entry and to hold a link.

Still refused: a directory another user owns, a non-sticky
world-writable directory, a group-writable directory root owns, and the
entry directly inside a shared sticky directory. Private ancestry and
the daemon state root keep refusing every group-writable directory.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

Size Report

Metric Base Current Diff
Installed (including dependencies) 6.45 MB 6.45 MB +315 B
Package (unpacked) 6.45 MB 6.45 MB +315 B
Package (download) 1.96 MB 1.96 MB +117 B

Startup median (7 runs, lower is better):

Scenario Base Current Diff
CLI --version 28.0 ms 29.5 ms +1.4 ms
CLI --help 51.2 ms 62.9 ms +11.7 ms

The decision tables name fixed user ids, so no answer depends on the
account that runs the suite. A level this user owns at 0775 that wins
the mkdir race is covered as adopted.

ADR 0016 and the replay docs now state the exception the rule leaves:
the members of the group of a directory this user owns and left
group-writable can replace an entry or create the script name first.
The rule accepts that group as the owner's responsibility. The creation,
state-root and leftover-directory statements match the code.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@thymikee

Copy link
Copy Markdown
Member Author

This PR is ready at 2067a81. The only production change is groupAddsEntriesIn in script-destination.ts: a group-writable directory now counts as open only when root owns it, another user owns it, or the caller asked for a private ancestry or a private root. So the one newly accepted case is a group-writable directory the current non-root user owns, as the maintainer decided. Foreign-owned, world-writable and root-owned group-writable directories stay refused, as do the entry directly in a sticky shared directory, every group-writable ancestor under privateAncestry, and the daemon state root. Directories a publish creates stay owner-only. The independent cross-check at 80a31f0 found the rule correct across owner, mode and trust combinations. Since then only comments, tests, the ADR and the website changed. The trade-off that group members of a directory you own and left group-writable can replace an entry there is stated in the PR and in ADR 0016. CI is still running.

@thymikee thymikee added the ready-for-human Valid work that needs human implementation, judgment, or maintainer merge label Nov 20, 2026
@apex-sentinel-staging

This comment has been minimized.

@apex-sentinel-staging apex-sentinel-staging Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apex Sentinel: 1 new finding on 2067a81. The verdict and the full list are in the summary comment.

On the script route shared_group_writable now fires only for a directory
root owns, and its hint told the caller to run chmod g-w there, which
only root can do. The judgment already knows the owner, so it passes
that to the refusal: a directory the caller owns keeps the chmod g-w
hint, and any other answers to save under a directory the caller owns.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@thymikee

Copy link
Copy Markdown
Member Author

Still ready at dd4a7b5. The shared_group_writable hint now follows the owner the judgment already found. A caller who owns the directory gets chmod g-w. Otherwise the owner must be root, because a directory another user owns is refused earlier as foreign_owned, so the caller is told to save under a directory they own. The three call sites pass authority.uid === trust.uid, with no second stat. The acceptance rule in groupAddsEntriesIn is unchanged, so the cross-check at 80a31f0 still covers it, and both hints have tests. The label stays.

@apex-sentinel-staging

Copy link
Copy Markdown

Apex Sentinel · ✅ Approve · review of dd4a7b5

Since the review of 2067a81: 0 new · 0 still open · 1 no longer raised (1 marked fixed)

No open findings.

Reviewed with this repository's own Sentinel configuration (74771e19193d).

💬 Talking to Sentinel

In a finding's thread, reply with:

Command What it does
@apex-sentinel-staging note <context> Adds context; Sentinel re-checks the cited code
@apex-sentinel-staging pivot <why> Says the finding is wrong; Sentinel re-checks the cited code
@apex-sentinel-staging like Marks the finding as useful
@apex-sentinel-staging dislike <why> Marks it as not useful, so it is not raised again

On this conversation, comment @apex-sentinel-staging review to run a full review once again.

@thymikee
thymikee merged commit db1ee84 into main Nov 20, 2026
19 checks passed
@thymikee
thymikee deleted the fix/save-script-own-group-writable branch November 20, 2026 11:34
thymikee added a commit to pcbeingused333/agent-device that referenced this pull request Nov 20, 2026
* origin/main: (70 commits)
  refactor(apple-runner): one RUNNER_ERROR_CODES row per runner error code with parity/docs gates (callstack#4774)
  fix(android): require acknowledgements for test IME typing (callstack#4722)
  feat(scroll): add scroll refresh for pull-to-refresh (callstack#4770)
  refactor(host-kit): add request Scope and use it for the wait capture deadline (callstack#4794)
  fix(android): let permission all change nothing on an app that declares no permissions (callstack#4796)
  fix(cli): replace the CLI session and generated remote config instead of rewriting them in place (callstack#4797)
  fix(host-kit): accept a group-writable script directory the user owns (callstack#4799)
  fix(cli): escape control characters at the CLI's stdout and stderr writes (callstack#4778)
  fix(audit): do not report rows under a persistent bar that scrolling reveals (callstack#4775)
  fix(daemon): refuse an unsafe state directory before first use (callstack#4783)
  refactor: settle remaining single-deadline races through settleWithin (callstack#4788)
  refactor(host-kit): settle deadline races via settleWithin with R87 race ratchet (callstack#4766)
  fix(android): authenticate and bound persistent snapshot helper sessions (callstack#4729)
  fix(daemon): bound upload ingress and finalization (callstack#4721)
  chore(gates): ratchet wire-published reason literals by value (R89) (callstack#4779)
  feat(audit): evaluate role-less clickable views on Android (callstack#4780)
  fix(mutation): keep umask-setting tests out of Stryker's thread pool (callstack#4785)
  feat(audit): report controls that share one accessible name (callstack#4771)
  fix(contracts): pair open runtime hints with their apply operation (callstack#4754)
  refactor(daemon): report startup progress over the launch channel instead of marker files (callstack#4777)
  ...
thymikee added a commit that referenced this pull request Nov 20, 2026
* origin/main:
  feat(gesture): hold before the move with gesture pan --hold-ms (#4767)
  docs: clarify device verification and security proposals (#4805)
  fix(daemon-client): say that a hung daemon is stopped before ensureDaemon starts a new one (#4803)
  test: remove five timing races from CI (#4800)
  refactor(remote): save a remote script from memory with the local publisher (#4802)
  refactor(apple-runner): one RUNNER_ERROR_CODES row per runner error code with parity/docs gates (#4774)
  fix(android): require acknowledgements for test IME typing (#4722)
  feat(scroll): add scroll refresh for pull-to-refresh (#4770)
  refactor(host-kit): add request Scope and use it for the wait capture deadline (#4794)
  fix(android): let permission all change nothing on an app that declares no permissions (#4796)
  fix(cli): replace the CLI session and generated remote config instead of rewriting them in place (#4797)
  fix(host-kit): accept a group-writable script directory the user owns (#4799)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-for-human Valid work that needs human implementation, judgment, or maintainer merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant