Skip to content

feat(agent-vault): ask the session's hook, matched by rules - #512

Open
saifsmailbox98 wants to merge 1 commit into
mainfrom
saif/av-hooks-flat
Open

saifsmailbox98 wants to merge 1 commit into
mainfrom
saif/av-hooks-flat

Conversation

@saifsmailbox98

@saifsmailbox98 saifsmailbox98 commented Nov 19, 2026 •

Copy link
Copy Markdown
Member

Description 📣

Moves the hook from each service to the session. Resolve now sends one top-level hook with rules, and the proxy only asks it for requests a rule matches.

  • A rule names a service, optionally narrowed by methods and paths (HTTP, matched on the path before substitution) or tools (MCP, any tools/call in the body, batches included). Postgres, MySQL and SSH match by service name only. No rules means every request goes to the hook
  • Matching leans towards asking: method-override headers count as the method, an MCP body the proxy can't read matches a tool rule, and a narrowing field that doesn't fit the service's type matches the whole service
  • Payload adds hook: { id, name } (name is null for an inline hook) and session.metadata; version stays 1
  • MCP inspection runs whenever the hook has a tool rule for that service, independent of the allowlist and session log settings

Companion PR: Infisical/infisical#9697

Type ✨

  • Bug fix
  • New feature
  • Improvement
  • Breaking change
  • Documentation

Tests 🛠️

# Here's some code block to paste some code snippets

  • New or changed commands follow CLI.md, and new commands and flags are recorded in packages/cmd/testdata/command_surface.json
  • Updated AGENTS.md files (if needed)
  • I have read the contributing guide, agreed and acknowledged the code of conduct. 📝

@infisical-review-police

Copy link
Copy Markdown

💬 Discussion in Slack: #pr-review-cli-512-feat-agent-vault-ask-the-session-s-hook-matched-by-rules

Posted by Review Police — reviews, comments, new commits, and CI failures will stream into this channel.

@veria-ai

veria-ai Bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

PR overview

The PR adds rule-based selection of a session’s hook in agent-vault, matching request paths and methods to determine when to invoke it before forwarding requests.

Two hook-selection bypasses remain open, with none addressed so far. A session holder can use a percent-encoded path to skip hook approval while the upstream handles the credentialed request as a protected operation. Form-based method overrides can similarly bypass method-specific hooks when the upstream supports method spoofing.

Open issues (2)

Fixed/addressed: 0 · PR risk: 7/10

Reviews

@greptile-apps

greptile-apps Bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 3/5 Tier: plus

[Medium impact] The change affects hook decisions across Agent Vault service traffic.

Fix the encoded-path bypass and update the required hook guide before merging.

Findings

  1. P1 Security Encoded paths skip approval ▶
  2. P2 Hook guide is outdated ▶

Summary

Moves Agent Vault hooks from individual services to the session, with rules that choose which requests need approval.

  • Agent Vault sessions now carry one hook for their services.
  • Hook rules now choose which service traffic the hook checks.

saifsmailbox98 explicitly marks this as a breaking change.

Reviews (1) · Last reviewed commit: "feat(agent-vault): ask the session's hoo..." · Reviewed by Greptile

Comment on lines +195 to +196
func hookPathMatches(escaped string, prefixes []string) bool {
return isAmbiguousPath(escaped) || matchesPrefix(escaped, prefixes)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 security Encoded paths skip approval. With a hook rule for /admin and no service path allowlist, GET /%61dmin skips the hook. isAmbiguousPath accepts %61, and matchesPrefix compares the escaped spelling, while the upstream routes the decoded path to /admin. The proxy still adds the service credential. Check decoded prefixes too, or conservatively ask the hook for escaped paths.

How this was verified: askHook returns without approval when this escaped-path comparison misses, and forward then injects the credential and sends the request.

Comment on lines +98 to +99
// Asked before the credential is attached, for the traffic its rules pick. Nil when the session has none.
hook *sessionHook

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Hook guide is outdated. AGENTS.md still says hooks belong to services and every HTTP or MCP request asks them. The hook now belongs to the session, and unmatched requests skip it. The guide requires updates when a change adds a new convention. Update its hook section to describe the new resolve format and matching rules so future changes follow the right contract.

File Used: AGENTS.md (source)

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

// The path the agent sent, before substitution. An ambiguous one matches, since the upstream may route it under a
// listed prefix.
func hookPathMatches(escaped string, prefixes []string) bool {
return isAmbiguousPath(escaped) || matchesPrefix(escaped, prefixes)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

High: Percent-encoded paths bypass hook selection

For a POST rule under /v1/refunds, a session holder can send POST /v1/%72efunds/1: isAmbiguousPath returns false and the escaped-byte prefix comparison fails, so the hook is not called but forward still attaches the credential. An upstream such as Go's ServeMux routes this to /v1/refunds/1, allowing the protected operation without hook approval; compare canonicalized paths, or conservatively select percent-encoded paths as below. (pkg.go.dev)

Suggested change
return isAmbiguousPath(escaped) || matchesPrefix(escaped, prefixes)
return strings.Contains(escaped, "%") || isAmbiguousPath(escaped) || matchesPrefix(escaped, prefixes)

}

// An override header counts as the method, since a framework that honours it performs the method it names.
func (r hookRule) matchesMethod(req *http.Request) bool {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Medium: Form method overrides bypass hook selection

Against an upstream with form method spoofing enabled, a session holder can send form-encoded POST /items/1 containing _method=DELETE to skip a methods: ["DELETE"] hook: this matcher checks only the wire method and headers, while frameworks such as Laravel route the credentialed request as DELETE. (laravel.com) Upstream method-spoofing configuration isn't available here; conservatively invoke the hook for override-capable form POSTs, or include their effective method in matching before deciding to skip it.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant