Repository navigation
Description
tests/test_agent_hooks.py::Harnesses::test_cursor_edit_tools_are_decided_as_edits fails on Windows on main: both Windows jobs of CI run 43464937068 (c69e406), and the same two jobs on #825. The StrReplace of <tmp>\.env gets (0, 'allow'), where the test expects (2, 'deny').
The test is right. This is a real miss: on Windows, the v1 hooks let an agent edit .env and other credential files.
Cause
TK-D005 in tracekit/policy/default.yaml:41-46 matches file_path against (^|/)(\.env…|id_rsa|id_ed25519|credentials)$|/\.ssh/|/\.aws/. Every separator in it is /. A Windows path, as agents on Windows send it, has backslashes (C:\w\.env), so nothing in it matches. policy.evaluate (tracekit/policy.py:246) passes the path to the rule as it is, and nothing in the v1 hook path turns \ into / first. The test builds its path with os.path.join, which is why it fails only on Windows.
It isn't specific to Cursor, and it isn't specific to StrReplace: any v1 Write or Edit with a backslash path misses every file rule written with /.
The v1 default policy on Windows-style paths, from a fork run on ubuntu-latest and windows-latest (the same on both, since it's string matching):
| tool | file_path |
main | with the fix |
|---|---|---|---|
| Edit | C:\w\.env |
allow | deny, TK-D005 |
| Edit | C:/w/.env |
deny, TK-D005 | deny, TK-D005 |
| Write | C:\Users\u\.ssh\authorized_keys |
allow | deny, TK-D005 |
| Write | C:\Users\u\.ssh\id_rsa |
allow | deny, TK-D005 |
| Write | C:\w\.aws\credentials |
allow | deny, TK-D005 |
| Edit | /w/.env |
deny, TK-D005 | deny, TK-D005 |
| Edit | C:\w\app.py |
allow | allow |
| Edit | C:\w\.env.example |
allow | allow |
The v2 packs already read Windows paths (test_a_windows_path_is_also_read_as_windows_opens_it), so this is v1 only.
Proposed fix
In policy.evaluate, also hand the rules each file_path and notebook_path with its backslashes read as /. The deny, ask and flag loops then see both forms. This touches no YAML, so the policy hash is unchanged, and the scope check keeps the path as given. Treating \ as a separator can only add matches: a POSIX file name with a backslash in it is decided at least as strictly as before.
I have it on my fork with a regression test in test_hardening.py (PolicySafety): Windows-style .env, .env.production, .ssh\authorized_keys and .aws\config paths, and one in a patch's paths, are denied by TK-D005; app.py and .env.example are not.
Fork runs, ubuntu-latest and windows-latest, Python 3.13:
- with the fix,
test_cursor_edit_tools_are_decided_as_editspasses on Windows; on main it fails there, as in CI; tests/test_hardening.pypasses on both (64 passed on Linux; 61 passed and 3 skipped on Windows), along with the Cursor and Windows tests intest_agent_hooks.pyand pyflakes;- run against main's
policy.py, the new test's 5 deny cases fail, on both.
I'd be glad to send it as a PR if you'd like the fix.
Activity
LoopGlitch26 commentedon Nov 13, 2026
Confirmed, and thank you for such a complete write-up. We found the same gap from that test's Windows failure, and a broader fix (the v1 path rules and the related shell forms) is going into 1.7.0. Your fix is right and well tested, so please send it as a PR. It turns main's Windows jobs green now, and the release builds on it. You'll be credited for the report in the release notes.
One request for next time: a hole like this one (a credentials write the policy should stop) is best reported privately first, through a security advisory, as SECURITY.md describes. That gives us a few days to ship the fix before the details are public. No harm done here, since the fix is close.
v1 policy: read a Windows path's backslashes as separators in the fil…
khushi-git-7 commentedon Nov 14, 2026
Thanks @LoopGlitch26. The PR is #838, rebased onto current main.
You're right about the advisory, and sorry for posting the details in the open. I should have read SECURITY.md first. Next time I find a hole like this, I'll report it privately through an advisory.
v1 policy: read a Windows path's backslashes as separators in the fil…