fix(hooks): rebind hook agent session keys to the target agent#58225
Conversation
Greptile SummaryThis PR fixes a one-line bug in Key changes:
Confidence Score: 5/5Safe to merge — the fix is minimal, correct, and backed by both unit and integration tests with no regressions. The change is a single-line fix to a clear bug where No files require special attention. Reviews (1): Last reviewed commit: "fix(hooks): rebind hook agent session ke..." | Re-trigger Greptile |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a778dfa83d
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
a778dfa to
04bbf27
Compare
🔒 Aisle Security AnalysisWe found 1 potential security issue(s) in this PR:
1. 🔵 Hooks endpoint discloses allowed session key prefixes in error responses
DescriptionThe hooks HTTP handler returns an error string that includes the full configured allowlist of
Vulnerable response construction: sendJson(res, 400, { ok: false, error: getHookSessionKeyPrefixError(allowedPrefixes) });And the error string includes the allowlist: `sessionKey must start with one of: ${prefixes.join(", ")}`RecommendationAvoid echoing the full configured allowlist to external callers.
Example: if (allowedPrefixes && !isSessionKeyAllowedByPrefix(normalizedDispatchSessionKey, allowedPrefixes)) {
logHooks.warn({ allowedPrefixes }, "hook sessionKey rejected by prefix policy");
sendJson(res, 400, { ok: false, error: "sessionKey is not allowed by policy" });
return true;
}If you need client guidance, consider returning only the count of allowed prefixes or a link to documentation rather than the literal prefixes. Analyzed PR: #58225 at commit Last updated on: 2026-03-31T15:18:51Z |
…law#58225) * fix(hooks): rebind hook agent session keys * fix(hooks): preserve scoped hook session keys * fix(hooks): validate normalized dispatch keys
…law#58225) * fix(hooks): rebind hook agent session keys * fix(hooks): preserve scoped hook session keys * fix(hooks): validate normalized dispatch keys
…law#58225) * fix(hooks): rebind hook agent session keys * fix(hooks): preserve scoped hook session keys * fix(hooks): validate normalized dispatch keys
…law#58225) * fix(hooks): rebind hook agent session keys * fix(hooks): preserve scoped hook session keys * fix(hooks): validate normalized dispatch keys
…law#58225) * fix(hooks): rebind hook agent session keys * fix(hooks): preserve scoped hook session keys * fix(hooks): validate normalized dispatch keys
…law#58225) * fix(hooks): rebind hook agent session keys * fix(hooks): preserve scoped hook session keys * fix(hooks): validate normalized dispatch keys
Summary
agent:session key even when the run was explicitly routed to a different target agent.agent:session keys to the actual target agent, keeps duplicate-target stripping intact, and adds focused unit/server tests for both cases.Root Cause
The hook dispatch normalizer handled duplicate target-agent prefixes, but when the incoming key was already agent-scoped for a different agent it preserved that foreign prefix instead of rebinding it to the real target agent.
Test Plan
src/gateway/hooks.test.ts.src/gateway/server.hooks.test.ts.pnpm test -- src/gateway/hooks.test.ts src/gateway/server.hooks.test.tspnpm checkValidation Notes
pnpm checkcurrently fails in untouched code atsrc/tasks/flow-registry.ts:252andsrc/tasks/flow-registry.ts:253withstring | nulltostring | undefinedtype errors.Human Verification
agent:<other>:...toagent:<target>:....Compatibility
AI-assisted: yes