You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Codex advice hook: keep its state where another user cannot redirect it #95
Found in the sage's repo pass (T206, run R715). Size: tiny. Low: it matters only on a machine where several users share the temp folder (Linux); on macOS the temp folder belongs to one user.
The problem
packages/sage-codex/hooks/principles-hook.mjs (lines 48 to 58, older than PR #84) keeps its advice state in the system temp folder, under agent-kit-hooks/codex, or in AGENT_KIT_HOOKS_STATE when it is set. It writes with writeFileSync, which follows links. On a shared temp folder, another user can create that folder, or a link with the name of the state file, first. The hook then writes its JSON over the file that the link points to.
Goal
The advice hook's state cannot be redirected by another user.
Scope
Keep the state under the owner's own home folder (for example next to the Codex logbook root), or create the temp folder with mode 700 and refuse it when it belongs to another user or is a link.
Open the state file without following links (O_NOFOLLOW), and write through a temporary file and a rename in the same folder.
A test with a folder and a link made first, in a scratch temp folder.
Acceptance
The new test fails on main and passes on the branch. npm run build, npm run check and npm test pass.
Activity