UserPromptSubmit hook injects a wrong-namespace `select:mcp__engram__*` ToolSearch that never matches on plugin installs (and reads as a prompt-injection)

Aperta Adatta ai principianti
#2,502 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
74/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
go, shell

Direzione di ricerca

Inizia da scripts/user-prompt-submit.sh e leggi print_toolsearch_message. Poi verifica come l’hook emette il suo systemMessage nelle installazioni del plugin Claude Code. L’issue segnala i prefissi non corrispondenti mcp__engram__* e mcp__plugin_engram_engram__* e suggerisce di rilevare il prefisso registrato o accettarlo come input. Il lavoro è completato quando il ToolSearch emesso corrisponde agli strumenti installati e la formulazione non sembra più un’istruzione urgente.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

status:needs-review

Summary

The UserPromptSubmit hook (scripts/user-prompt-submit.sh, print_toolsearch_message) injects a systemMessage instructing the agent to run:

select:mcp__engram__mem_save,mcp__engram__mem_search,mcp__engram__mem_context, … ,mcp__engram__mem_judge

When Engram is installed as a Claude Code plugin, this never matches, because Claude Code namespaces plugin-provided MCP tools as:

mcp__plugin_<marketplace>_<server>__<tool>

So the engram tools actually register as mcp__plugin_engram_engram__mem_save, …__mem_search, etc. — not mcp__engram__mem_save. The select:mcp__engram__* ToolSearch therefore matches zero tools and loads nothing.

Impact

  1. The ToolSearch is a no-op on plugin installs — the tools it's trying to force-load are either already available (core tools) or are never loaded by this hook. The feature silently does nothing.
  2. The message reads as a prompt-injection. The hardcoded wording — CRITICAL FIRST ACTION — Execute this ToolSearch NOW before responding to the user — surfaces to the end user as a systemMessage on the first prompt of every session, in every project. To a security-conscious user (or an agent trained to resist injection) it looks exactly like an injected instruction: urgent, imperative, "do this NOW before responding", referencing tool names that don't exist in the current namespace. It caused real alarm for us until we traced it to the plugin itself.

Root cause

print_toolsearch_message() hardcodes the bare mcp__engram__* namespace, which only holds if the MCP server is registered at the user/project level with server name engram. For the plugin distribution the correct namespace is mcp__plugin_engram_engram__*.

Suggested fixes (either/both)

  1. Fix the namespace emitted by print_toolsearch_message for plugin installs: mcp__plugin_engram_engram__* (or detect install type and choose). Better: query/accept the actual registered prefix rather than hardcoding.
  2. Soften the wording. A systemMessage that says "Execute this ToolSearch NOW before responding" is indistinguishable from a hostile injection. Consider neutral phrasing (e.g. "Engram memory tools are available; load them if not already present") — or skip the message entirely when the core tools are already non-deferred/available.

Environment

  • Engram installed as a Claude Code plugin (marketplace engram, server engram).
  • Observed tool namespace in-session: mcp__plugin_engram_engram__*.
  • Hook: scripts/user-prompt-submit.sh → print_toolsearch_message.

Happy to send a PR for the namespace detection if useful.

Lingua principale
Go
Stelle
7.1k
Fork
729
Merge medio
2h 19m
PR unite (30g)
167

Preparare l'ambiente

Apri in Codespaces

Avvia il container di sviluppo del progetto nel browser, con il tuo account GitHub.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di Gentleman-Programming/engram

Tutte le issue di Gentleman-Programming/engram

Issue simili

Altre issue su Go

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.