oliver-zehentleitner / maity
runner: other_credentials fails open on Python 3.15 (pathlib is_dir swallows PermissionError)
tsk-0tje3vzzedtx Done An agent
Bug: supervisor.other_credentials fails open on Python 3.15 (pathlib is_dir() no longer raises PermissionError)
Found by maity-test-team while analysing a side finding from the #2089 test, as lotse asked (seq 189006).
Symptom. 17 cases in cli/tests/test_antigravity.py fail on Python 3.15.2. Examples: test_a_place_that_cannot_be_looked_at_refuses_the_start[*-single] (DID NOT RAISE Refused) and test_every_side_answers_as_the_runners_own_side_whatever_the_modes[*-agent_user|ssh] ('refused' == []). On Python 3.13.x the same file gives 239 passed, 1 skipped, at the same commit (main b38fadf7, and b38fadf7^ too). CI runs only 3.11 to 3.13, so it is green there.
Repro (uid 1000, no capabilities, ext4; same result in /tmp and /workspace):
# a clone slot linked into a chmod-0 directory
ws/maity/agent-3/.git/maity/ # own clone
ws/maity/agent-4 -> elsewhere/locked/agent-4 ; chmod 0 elsewhere/locked
supervisor.other_credentials(ws, ws/"maity"/"agent-3", AsUser())
# 3.13: raises workspace.Refused("harness_refused")
# 3.15: returns [] <- the start goes on, without a deny for what the locked place could hide
Cause (verified): in the as_user.direct branch (supervisor.py about line 2170), the listing relies on Path.is_dir() raising for an unsearchable path, which the except OSError then turns into Refused. On 3.15, Path("<chmod-0 dir>/x").is_dir() returns False instead of raising PermissionError, so the unreadable place is skipped silently. os.listdir/os.stat on the same path still raise PermissionError. The agent_user and ssh cases go wrong too; probably the same pattern on the comparing path, but that is not traced.
Impact: requires-python = ">=3.11" allows 3.14+/3.15. A runner on a new Python would start a sandbox without the deny for another clone's credential directory that the agents' user cannot list. The fail-closed contract in the docstring does not hold there.
Suggestion (hunch, coder to verify): don't let is_dir()/is_file()/exists() decide a security listing. Use os.stat/os.scandir and let the OSError raise, and audit other fail-closed listings (other_scratches, skills, scratchop) for the same pattern. Add Python 3.14/3.15 to the CI matrix, or cap requires-python until then.
Notes
Maity Test Team · Nov 21, 2026, 14:23 UTC
Tester note (maity-test-team): Python 3.14 is affected too.
- Python 3.14.10:
Path("<chmod-0 dir>/x").is_dir()→ False (no PermissionError). tests/test_antigravity.pyat main b38fadf7: 3.14.10 gives 17 failed, 222 passed, 1 skipped; 3.15.2 gives the same 17 failed; 3.13.x gives 239 passed, 1 skipped.
So the fail-open hits every Python ≥3.14. The CI matrix (3.11 to 3.13) does not see it.
- Python 3.14.10:
Maity Test Team · Nov 21, 2026, 15:41 UTC
Reporter's check of PR #2095 head bc1534f7 on Python 3.15.2 (uid 1000, no capabilities, ext4), before the merge:
cli/tests/test_antigravity.py: 244 passed, 1 skipped. The same Python on main af07490c gives 17 failed, 222 passed, 1 skipped, the failures this card reported.cli/tests/test_supervisor*.pyon the PR head: 356 passed.
The fail-closed listings refuse again on 3.15, so the fix holds for the case I found. I'll re-check on main once it is merged, if wanted.