#12701: security: prefix bare .md file references with ./ to prevent TLD resolution
agents
size: XS
Cluster:
Heartbeat Functionality Improvements
## Summary
Since `.md` is a valid top-level domain (Moldova), bare references like `MEMORY.md`, `SOUL.md`, `HEARTBEAT.md` in LLM-facing prompts could potentially be resolved as URLs (e.g., `https://memory.md`, `https://soul.md`) instead of local file paths.
This is a security risk: an attacker could register these domains and serve malicious content that the agent might fetch and execute as instructions.
## Fix
Prefix all bare `.md` file references in system prompts, tool descriptions, and heartbeat prompts with `./` to unambiguously mark them as local paths.
## Changes (7 files, 11 lines)
| File | Change |
|------|--------|
| `src/agents/system-prompt.ts` | `MEMORY.md` → `./MEMORY.md`, `TOOLS.md` → `./TOOLS.md`, `SOUL.md` → `./SOUL.md` |
| `src/agents/system-prompt-report.ts` | `TOOLS.md` marker string → `./TOOLS.md` |
| `src/agents/system-prompt.test.ts` | Update test expectation for `./SOUL.md` |
| `src/agents/tools/memory-tool.ts` | `MEMORY.md` → `./MEMORY.md` in memory_search and memory_get descriptions |
| `src/auto-reply/heartbeat.ts` | `HEARTBEAT.md` → `./HEARTBEAT.md` in default prompt |
| `src/auto-reply/reply/session-updates.ts` | Update heartbeat filter + backward compat for old prompt format |
| `src/config/types.agent-defaults.ts` | JSDoc default string consistency |
## Background
The `.md` TLD is actively registered — for example, `heartbeat.md` is a purchasable domain. If an LLM sees a bare `HEARTBEAT.md` in its system prompt and has access to web tools, it could attempt to fetch `https://heartbeat.md` instead of reading the local file, potentially executing attacker-controlled instructions.
The `./` prefix makes the reference unambiguously a relative file path, which no URL parser will resolve as a domain.
<!-- greptile_comment -->
<h2>Greptile Overview</h2>
<h3>Greptile Summary</h3>
This PR updates multiple LLM-facing prompt strings to prefix bare `*.md` references with `./` (e.g., `MEMORY.md` → `./MEMORY.md`, `HEARTBEAT.md` → `./HEARTBEAT.md`) to prevent accidental URL/TLD resolution in models that might treat bare `heartbeat.md` as a domain.
Changes are localized to system-prompt generation/reporting, memory tool descriptions, the default heartbeat prompt, and a system-event filter intended to suppress the heartbeat prompt line from session updates.
<h3>Confidence Score: 3/5</h3>
- This PR is mostly safe to merge, but there’s a functional regression risk in session update filtering when users override the heartbeat prompt.
- The string-prefix changes are straightforward and low-risk, but `prependSystemEvents` now filters heartbeat prompts using a hard-coded prefix that only matches the default/legacy prompt format; custom heartbeat prompts will leak into system event blocks unexpectedly.
- src/auto-reply/reply/session-updates.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
#11743: fix: remove redundant file reads from AGENTS.md template
by shogunsea · 2026-02-08
76.0%
#20563: fix: skip default HEARTBEAT_OK instructions when custom prompt is set
by clawalpha · 2026-02-19
75.5%
#15422: fix(auto-reply): keep cron systemEvent payloads that start with 'Re...
by liuxiaopai-ai · 2026-02-13
75.4%
#16373: fix: suppress leaked heartbeat poll prompts in reply delivery
by luisecab · 2026-02-14
75.4%
#13524: feat: conditional bootstrap file loading for heartbeat vs DM sessions
by tarun131313 · 2026-02-10
74.8%
#3335: Fixes cron jobs
by hkirat · 2026-01-28
74.6%
#11169: fix(security): remove bundled soul-evil hook that enables silent ag...
by liuxiaopai-ai · 2026-02-07
74.4%
#9273: Add files via upload
by cyrilliu1974 · 2026-02-05
74.3%
#10514: Security: harden AGENTS.md with gateway, prompt injection, and supp...
by catpilothq · 2026-02-06
74.0%
#7983: feat(security): add secure coding guidelines to system prompt
by TGambit65 · 2026-02-03
73.8%