Skip to content

fix(approval): recognize the raw temp-dir alias in verification cleanup - #70415

Open
ildunari wants to merge 1 commit into
NousResearch:mainfrom
ildunari:upstream/approval-temp-alias-fix
Open

fix(approval): recognize the raw temp-dir alias in verification cleanup#70415
ildunari wants to merge 1 commit into
NousResearch:mainfrom
ildunari:upstream/approval-temp-alias-fix

Conversation

@ildunari

Copy link
Copy Markdown
Contributor

Problem: _is_verification_artifact_cleanup() (which lets the agent self-clean its own hermes-verify-*/hermes-ad-hoc-* temp scripts without an approval prompt) only matched the realpath()-resolved temp directory. On systems where tempfile.gettempdir() returns a top-level alias — e.g. macOS's /tmp, which resolves to /private/tmp — a cleanup command using the literal path the shell/OS actually reports (/tmp/hermes-verify-foo.py) was never recognized as safe, since it doesn't match the canonical /private/tmp/... form.

Fix: accept the raw (non-realpath) operand as an alternative match, but only when the raw temp dir's own parent is the filesystem root (os.path.dirname(raw_temp_dir) == os.path.abspath(os.sep)). This keeps the exemption narrow: an arbitrary non-root symlinked temp directory (the existing test_symlinked_temp_dir_only_exempts_canonical_target regression) still requires the canonical realpath form and is unaffected.

Testing done: full tests/tools/test_approval.py (313 tests) passes, including the existing symlink-alias regression unchanged, plus one new regression test for the top-level-alias case specifically.

_is_verification_artifact_cleanup() only matched the realpath()-resolved
temp directory, so on systems where tempfile.gettempdir() returns a
top-level alias (e.g. macOS's /tmp, which resolves to /private/tmp) a
verification-script cleanup command using the literal, unresolved path
was never recognized as safe.

Accept the raw (non-realpath) operand as an alternative match, but only
when the raw temp dir's parent is the filesystem root — the exemption
stays narrow and a non-root symlinked temp dir (arbitrary directory
symlink tricks) still requires the canonical realpath form.

Added a regression test for the top-level-alias case; the existing
symlinked_temp_dir_only_exempts_canonical_target test continues to pass
unchanged, confirming non-root symlinks are unaffected.
@alt-glitch alt-glitch added type/bug Something isn't working P3 Low — cosmetic, nice to have tool/terminal Terminal execution and process management area/auth Authentication, OAuth, credential pools sweeper:risk-security-boundary Sweeper risk: may affect sandboxing, auth, credentials, or sensitive data labels Jul 24, 2026
@teknium1

Copy link
Copy Markdown
Contributor

Thanks for the focused regression fix. The premise remains present on current main: tools/approval.py:2027-2030 accepts only the realpath-resolved temp directory spelling, while tools/approval.py:2032-2035 already constrains the resolved target and approved basename. The PR's raw top-level alias branch preserves those latter checks and retains the existing non-root symlink regression (tests/tools/test_approval.py:111-124).

Automated hermes-sweeper review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/auth Authentication, OAuth, credential pools P3 Low — cosmetic, nice to have sweeper:blast-contained Sweeper blast radius: contained — one narrow path / opt-in / few users sweeper:risk-security-boundary Sweeper risk: may affect sandboxing, auth, credentials, or sensitive data tool/terminal Terminal execution and process management type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants