Skip to content

Invalidate path-restriction cache when symlink realpath changes - #756

Merged
TheGreatAxios merged 2 commits into
mainfrom
cl-6708-invalidate-path-restriction-cache-when-symlink-realpath
Sep 2, 2026
Merged

Invalidate path-restriction cache when symlink realpath changes#756
TheGreatAxios merged 2 commits into
mainfrom
cl-6708-invalidate-path-restriction-cache-when-symlink-realpath

Conversation

@TheGreatAxios

@TheGreatAxios TheGreatAxios commented Sep 2, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Path-restriction cache entries retain the resolved target path and invalidate when a symlink retargets.
  • Nonexistent targets resolve through their nearest existing ancestor before cache validation.
  • A regression test covers an allowed workspace symlink retargeting outside the workspace.

Verification

  • bun run check

Fixes CL-6708

@linear-code

linear-code Bot commented Sep 2, 2026

Copy link
Copy Markdown

CL-6708

@TheGreatAxios
TheGreatAxios force-pushed the cl-6708-invalidate-path-restriction-cache-when-symlink-realpath branch from a3840b7 to 5728006 Compare September 2, 2026 06:56

@TheGreatAxios TheGreatAxios left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Review · Comment

The path gate revalidates cached verdicts against the nearest-existing realpath before reusing them.

Findings

  • CONTRIBUTING.md:100 — Commit 57280066 contains five body lines over the mandatory 72-character limit; git log origin/main..HEAD --format="%b" | awk "length > 72" returns each one. Could you rewrap the commit body so the branch history meets the repository rules?
  • CONTRIBUTING.md:138 — The PR body uses Problem, Fix, and Test sections instead of the required Summary and Verification shape. Could you update it so the PR metadata follows the source-of-truth template?

Notes

  • These findings should be resolved before merge; GitHub does not allow the PR author account to request changes on its own PR.
  • bun run check exits 0 locally; GitHub build, lint, formatting, typecheck, and CLA checks are green.

isRestricted cached verdicts only by lexical absolute path. After a
workspace symlink changed from inside to outside, the stale unrestricted
verdict persisted and corrupted gate ask-vs-auto decisions.

The cache stores the resolved path with each verdict and validates it
on every call. realpathNearestOr resolves symlinks through the nearest
existing ancestor, including for nonexistent targets.
@TheGreatAxios
TheGreatAxios force-pushed the cl-6708-invalidate-path-restriction-cache-when-symlink-realpath branch from 5728006 to 1897f0c Compare September 2, 2026 07:28

@TheGreatAxios TheGreatAxios left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Review · Comment

The path-restriction cache invalidation branch now meets the repository metadata rules.

No findings.

Notes

  • Commit 1897f0c7 wraps every subject and body line within 72 characters.
  • The PR description uses the required Summary and Verification sections.
  • bun run check exits 0 against the amended commit.

@TheGreatAxios TheGreatAxios left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Review · Blocking

The path restriction cache invalidates entries when a symlink's resolved target changes.

Finding

  • src/permission/path-restriction.ts:204 — The cache records currentRealpath from one filesystem snapshot but pairs it with a verdict computed by a second resolution at line 219. If the symlink retargets between those calls, the cache can associate an unrestricted verdict with an outside realpath and reuse it later. Could we compute and cache the verdict from one resolved snapshot so the security decision and key cannot diverge?

GitHub CI is green, but this time-of-check/time-of-use window affects the permission boundary and should be resolved before merge.

@TheGreatAxios TheGreatAxios left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Review · No findings

The cache now derives validation, permission verdict, and storage from one resolved-path snapshot.

The deterministic retarget race and existing inside-to-outside regression pass, bun run check exits 0 with 5,897 tests, all required GitHub checks pass, and the prior blocking finding is resolved.

@TheGreatAxios
TheGreatAxios merged commit 347b1f1 into main Sep 2, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant