Skip to content

v1 policy: read a Windows path's backslashes as separators in the file rules (#827) - #838

Merged
LoopGlitch26 merged 1 commit into
Cygnux-Labs:mainfrom
khushi-git-7:agent/issue-827
Nov 14, 2026
Merged

LoopGlitch26 merged 1 commit into
Cygnux-Labs:mainfrom
khushi-git-7:agent/issue-827

Conversation

@khushi-git-7

Copy link
Copy Markdown
Contributor

Fixes #827.

TK-D005 and the other v1 file rules are written with /. A Windows path (C:\w\.env) matched none of them, so on Windows the v1 hooks let an agent edit .env, .ssh\… and .aws\…. policy.evaluate now also hands the deny, ask and flag rules each file_path and notebook_path with its backslashes read as /.

  • No YAML changes, so the policy hash is the same.
  • The scope check keeps the path as given.
  • Reading \ as a separator can only add matches.

Tests

tests/test_hardening.py, PolicySafety.test_a_windows_path_is_read_with_its_backslashes_as_separators:

  • Windows-style .env, .env.production, .ssh\authorized_keys and .aws\config paths, and a .env in a patch's paths, are denied by TK-D005;
  • app.py and .env.example are not.

On my fork, ubuntu-latest and windows-latest, Python 3.13 (before rebasing onto cda2997; the rebase was clean):

  • tests/test_hardening.py: 64 passed on Linux; 61 passed and 3 skipped on Windows;
  • test_cursor_edit_tools_are_decided_as_edits passes on Windows, where it fails on main;
  • the new test against main's policy.py: its 5 deny cases fail on both;
  • pyflakes is clean.

…e rules (Cygnux-Labs#827)

TK-D005 and the other v1 file rules are written with '/', so a Windows
path (C:\w\.env) matched none of them, and the v1 hooks let an agent
edit .env and other credential files on Windows. policy.evaluate now
also hands the rules each file_path and notebook_path with its
backslashes read as '/'. No YAML changes, so the policy hash is the same.

Signed-off-by: Khushi Jain <jainkhushibts@gmail.com>

@LoopGlitch26 LoopGlitch26 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Reviewed (read against main; nothing run here). This is right, and it's the smallest fix in the right place. I checked each claim in the description:

  • Only adds matches. ruled is calls plus a / copy of each backslash path, and deny, ask and flag each take any over it, so nothing that matched on main stops matching.
  • The evidence doesn't change. The copies exist only for the rule match; the recorded call keeps the path as the agent sent it, and the scope check still reads calls.
  • Same policy hash. No YAML changes. And neither verifier re-runs v1's evaluate, so old bundles aren't touched.
  • It also fixes TK-D009 (writes to the harness transcripts, such as .claude\projects\…), which is written with / as well.
  • The test fails on main for its five deny cases (none of them has a / before .env, .ssh or .aws) and keeps two controls (app.py, .env.example).

Like the other policy PRs, this merges right after the coming release, which changes the same rules; we'll settle any conflict at merge. Nothing for you to do until then unless CI says otherwise.

@LoopGlitch26
LoopGlitch26 merged commit a14d842 into Cygnux-Labs:main Nov 14, 2026
34 checks passed
@LoopGlitch26

Copy link
Copy Markdown
Member

Merged now instead of after the release: this also turns main's Windows jobs green (test_cursor_edit_tools_are_decided_as_edits failed there for the same reason). Thanks, khushi.

munjikesh added a commit to munjikesh/Tracekit that referenced this pull request Nov 14, 2026
Brings in a14d842 (Cygnux-Labs#838), whose Windows path fix makes
test_cursor_edit_tools_are_decided_as_edits pass on the Windows jobs.
No pack, policy corpus or E17/E21 result changed on main, so the
recorded evals stand.

Signed-off-by: Munjikesh N <Munjikesh.N@iiitb.ac.in>
wanjinhao1 pushed a commit to wanjinhao1/Tracekit that referenced this pull request Nov 15, 2026
munjikesh merged main into Cygnux-Labs#828 (6c76dbe, for Cygnux-Labs#838's Windows test fix)
after the train took its earlier head 3ee777e. Its pack, test and
policy-doc changes are 3ee777e's, and the train already holds that main,
so this merge changes no file; it puts Cygnux-Labs#828's current head in the train,
so Cygnux-Labs#828 shows as merged. The review's podman-remote exception and the
nice/nohup rows stay in the train's own commit on top of 3ee777e.

Signed-off-by: LoopGlitch26 <53336715+LoopGlitch26@users.noreply.github.com>
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.

v1 policy: on Windows, a backslash path slips past TK-D005, so an edit of .env is allowed

2 participants