Skip to content

fix(approval): ignore leaked HERMES_CRON_SESSION in interactive sessions (#56771) - #56788

Closed
nankingjing wants to merge 1 commit into
NousResearch:mainfrom
nankingjing:fix/56771-cron-session-env-leak-approval
Closed

nankingjing wants to merge 1 commit into
NousResearch:mainfrom
nankingjing:fix/56771-cron-session-env-leak-approval

Conversation

@nankingjing

Copy link
Copy Markdown
Contributor

Summary

  • Add _is_cron_approval_context() so HERMES_CRON_SESSION alone does not classify a call as cron when a live interactive session is active.
  • Interactive overrides: HERMES_GATEWAY_SESSION, interactive CLI flag, or a bound HERMES_SESSION_KEY contextvar.
  • Real cron jobs (including delivery-metadata platform bindings without a session key) still honor approvals.cron_mode.

Fixes #56771

Why

The cron scheduler sets HERMES_CRON_SESSION process-wide. When that env leaks into a Telegram/gateway session, execute_code was blocked with the cron-deny message even though a user was present to approve.

Test plan

  • pytest tests/tools/test_cron_session_env_leak_56771.py (3/3)
  • pytest tests/tools/test_cron_approval_mode.py tests/tools/test_execute_code_approval_cluster.py (48/48)

…ons (NousResearch#56771)

The cron scheduler sets HERMES_CRON_SESSION process-wide; when that env leaks
into a live gateway or CLI session, execute_code was incorrectly treated as a
cron job and blocked under approvals.cron_mode: deny.

Introduce _is_cron_approval_context() so explicit gateway/interactive markers
and a bound session key override the leaked env while real cron jobs (including
delivery-metadata platform bindings) still honor cron_mode.

Fixes NousResearch#56771
@alt-glitch alt-glitch added type/bug Something isn't working comp/tools Tool registry, model_tools, toolsets P2 Medium — degraded but workaround exists sweeper:risk-security-boundary Sweeper risk: may affect sandboxing, auth, credentials, or sensitive data labels Jul 2, 2026
@alt-glitch

Copy link
Copy Markdown
Contributor

This was generated by AI during triage.

Competing fix for #56771 alongside #56784 (both edit tools/approval.py). This PR adds a new _is_cron_approval_context() predicate + _has_bound_session_key() (treats leaked HERMES_CRON_SESSION as non-cron when a live interactive session/session-key is present, and additionally covers the bound-session-key contextvar path). #56784 instead reorders _is_gateway_approval_context() so per-session gateway indicators take precedence over the process-wide cron flag. Same goal, different mechanism -- related, not a duplicate. Both also relate to the canonical source-side fixes #29854 (scheduler env save/restore) and #31184 (flag -> contextvars). Flagging the cluster so a maintainer can pick one approach.

@nankingjing

Copy link
Copy Markdown
Contributor Author

Closing to avoid parallel competing fixes for #56771 (#56784/#56796 already open). Prefer maintainers converge on one canonical path.

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

Labels

comp/tools Tool registry, model_tools, toolsets P2 Medium — degraded but workaround exists sweeper:risk-security-boundary Sweeper risk: may affect sandboxing, auth, credentials, or sensitive data type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: execute_code blocked in interactive Telegram gateway session because HERMES_CRON_SESSION env var leaks from cron scheduler into user's shell

2 participants