#7036: Fix evil soul hooks by enforcing env properties
Cluster:
Soul Hooks Security Enhancements
Updated `resolveSoulEvilConfigFromHook` to strictly use `env` properties if the `env` object is present. This prevents configuration variables from being read from the top-level scope when an environment block is defined, enforcing a cleaner separation of configuration.
Test coverage updated to:
- Verify usage of `env` properties.
- Ensure top-level properties are ignored when `env` is present.
- Verify behavior with empty `env` blocks.
AI-Assisted: True
Testing: Fully tested (unit tests updated and passed).
<!-- greptile_comment -->
<h2>Greptile Overview</h2>
<h3>Greptile Summary</h3>
This PR changes `resolveSoulEvilConfigFromHook` to prefer `entry.env` as the sole source of configuration when an `env` block exists, preventing accidental reads from top-level keys. The unit tests were updated to cover env precedence, ignoring top-level keys when `env` exists, and the empty-`env` behavior.
This is used by the bundled `soul-evil` hook handler (`src/hooks/bundled/soul-evil/handler.ts`) to parse hook config before applying the SOUL override during agent bootstrap.
<h3>Confidence Score: 4/5</h3>
- This PR is likely safe to merge; the behavior change is small and covered by updated tests.
- Core change is a localized precedence rule in `resolveSoulEvilConfigFromHook` with added tests. Main remaining concern is the new truthy check for `env` that can mis-handle non-object values, which could confuse users with misconfigured hooks.
- src/hooks/soul-evil.ts
<!-- greptile_other_comments_section -->
<sub>(3/5) Reply to the agent's comments like "Can you suggest a fix for this @greptileai?" or ask follow-up questions!</sub>
<!-- /greptile_comment -->
Most Similar PRs
#8716: fix(soul-evil): minimal simplification of env config merging
by myberry2026 · 2026-02-04
90.9%
#11169: fix(security): remove bundled soul-evil hook that enables silent ag...
by liuxiaopai-ai · 2026-02-07
81.8%
#9914: fix(hooks): resolve bundled hook dist paths and packaging checks
by zimmra · 2026-02-05
75.7%
#14222: core: add needsApproval to before_tool_call; move AgentShield to ex...
by Eventedge · 2026-02-11
72.9%
#11339: fix: resolve bundled hooks path on npm global install
by matthewpoe · 2026-02-07
71.7%
#11778: fix(plugins): enforce monotonic hook deny merges
by coygeek · 2026-02-08
71.6%
#11817: fix(build): compile bundled hook handlers into dist
by AnonO6 · 2026-02-08
71.5%
#16915: fix: await compaction hooks with timeout to prevent cross-session d...
by maximalmargin · 2026-02-15
71.5%
#3392: fix(hooks): remove debug console.log statements from session-memory...
by WinJayX · 2026-01-28
71.5%
#12871: fix: use bash and warn about shell injection (issue #12836)
by ambicuity · 2026-02-09
71.2%