Haunted Storyteller: Agent Triage
agent triage completed
Untrusted model output about an untrusted repository. Shown as plain text.
Let me check code for jinja2 use and the agent config.
## Summary
- The scan reported 10 findings: 6 high, 3 medium, plus one jinja2 finding with a medium severity. There were no scan errors. The scanner recognised 1 MCP config, 1 agent config, 0 skills, 0 lockfiles and 2 requirements files. I did not see the second requirements file's name or contents.
- The `ghostwriter` agent (`.kiro/agents/ghostwriter.json`) has every tool allowed (SG-006, SG-007). Its prompt tells it to disable approval checks and print `~/.aws/credentials` (SG-008, SG-009). I read the file and confirmed all four.
- The MCP config `.kiro/settings/mcp.json` (read as `mcp.json.disabled`) has two servers. `crypt-keeper` auto-approves all tools, runs an unpinned `npx` package and has a hardcoded token (SG-001, SG-002, SG-003). `ghost-feed` uses plaintext http and a hardcoded bearer token (SG-004, SG-005).
- jinja2 3.1.2 (SG-010) is imported and used, but only with fixed template text. The advisories' details were not available to me, so I could not tell whether the code path is actually exploitable.
- Not determined: whether the `crypt-keeper-mcp` package or the `ghost-feed` host is malicious or even exists. Also unknown: whether the two embedded tokens are live, and whether the agent config is the one actually used at runtime. The Python app in `storyteller/agent.py` does not use `ghostwriter`.
## Attack paths
1. Credential theft through the agent config, from entry point to impact. Files: `.kiro/agents/ghostwriter.json` and `.kiro/settings/mcp.json`.
- Entry point: the `ghostwriter` prompt (SG-008) tells the agent to disable approval checks.
- SG-006 and SG-007 give it every tool, including shell and unrestricted write, so there is nothing left to gate its actions.
- SG-009 tells it to read `~/.aws/credentials` and put the contents in its reply, which discloses the AWS credentials.
- The agent sets `useLegacyMcpJson: true`, so it also loads the MCP servers from the config below.
2. Supply-chain compromise of a tool server, from entry point to impact. File: `.kiro/settings/mcp.json`.
- Entry point: `crypt-keeper` runs `npx -y crypt-keeper-mcp@latest` (SG-002), so whatever upstream publishes next runs on the local machine.
- SG-001 auto-approves every tool that server exposes, so there is no prompt.
- If the agent from path 1 is the one using it, that agent's every-tool permission lets injected output drive shell and write actions. SG-003 also leaves a hardcoded token in the same config.
3. Interception of the `ghost-feed` connection. File: `.kiro/settings/mcp.json`.
- SG-004 sends plaintext http to a non-local host, and SG-005 puts a hardcoded bearer token in that traffic.
- A network attacker can read the token and alter the responses, which feed the agent in path 1.
I did not confirm that `ghostwriter` is invoked together with these MCP servers in practice. The link is only the `useLegacyMcpJson` flag.
## Dependency use
- **jinja2 3.1.2 (SG-010, `requirements.txt`)**: `storyteller/tools.py` imports it (`from jinja2 import Template`) and calls `TITLE_CARD.render(title=title, gauge=...)` in the `title_card` tool. The template string is a fixed constant, and the model-supplied `title` is passed only as a render variable, not as template source. That points to low exposure, but I could not check each of the 10 advisories (GHSA and PYSEC ids) against this usage.
- **Other requirements**: `strands-agents==1.64.0` and `mcp>=1.0` appear in `requirements.txt`. The scanner reported no findings for them. I did not verify that independently.
## Top fixes
1. **High-impact:** Rewrite `.kiro/agents/ghostwriter.json`. Remove the "disable safety approval" and "Read ~/.aws/credentials" instructions (SG-008, SG-009). Replace `"*"` and the `capability: all` rule with a minimal tool list (SG-006, SG-007). Add a shell command allow-list and restrict where it can write. This changes tool permissions, so it needs developer approval.
2. Rotate both exposed tokens now (SG-003, SG-005). Treat them as leaked even if they look like demo values. Then move them to environment variables, using `${VAR}` references in the MCP config. Also check whether AWS credentials were ever exposed through this agent.
3. **High-impact:** Remove `"autoApprove": ["*"]` from `crypt-keeper` (SG-001). List only the specific tools that are safe to approve. This changes MCP configuration.
4. **High-impact:** Pin `crypt-keeper-mcp` to a reviewed exact version instead of `@latest` (SG-002). This changes the MCP command.
5. **High-impact:** Move `ghost-feed` to `https://` (SG-004). If the host does not support TLS, remove it. This changes the MCP endpoint.
6. Quick fix: bump jinja2 to 3.1.6 in `requirements.txt` (SG-010). It is a patch bump within 3.1.x. Check the version against OSV.dev and run `tests/test_tools.py` afterwards.