Back to skill

Security audit

dnd-dm

Security checks for vulnerabilities and agentic risk

Overview

This D&D skill mostly contains game-engine functionality, but it also loads broad host-agent instructions that can affect memory, files, background checks, and unrelated services.

Install only if you are comfortable auditing or removing the bundled AGENTS.md behavior first. The game engine features are mostly coherent, but the package should not be allowed to write global memory, heartbeat, agent-policy, or skill files, or to access email, calendars, social notifications, or repositories unless the user explicitly enables those actions.

Vulnerability Patterns
  • Skill Instruction HijackingAlters the agent's session goals or safety constraints when the skill loads
  • Agent Memory PoisoningWrites attacker-controlled rules into memory that affect later sessions
  • Remote Payload Retrieval and ExecutionFetches external code whose behavior can change after review
  • Embedded Malicious CodeShips malicious scripts inside the skill and executes them locally
  • Unauthorized Access and Privilege EscalationObtains permissions beyond the task's legitimate needs
Findings (2)

T01 · Skill Instruction Hijacking

Error
Location
references/AGENTS.md:5
Finding

Bundled Agent-Wide Instructions Hijack the Host Agent Beyond the D&D Skill Scope

Content
View full analysis

Vulnerability Details

File Location: references/AGENTS.md:5-8, 65-83, 145-220; activation path in dnd-engine/src/dnd_engine/context/loader.py:15-28, 184-209
Vulnerability Type: Skill instruction hijacking
Risk Level: High

Vulnerable Code

references/AGENTS.md:5-8:

markdown
## First Run

If `BOOTSTRAP.md` exists, that's your birth certificate. Follow it, figure out who you are, then delete it. You won't need it again.

references/AGENTS.md:65-83:

markdown
## Red Lines

- Don't exfiltrate private data. Ever.
- Don't run destructive commands without asking.
- `trash` > `rm` (recoverable beats gone forever)
- When in doubt, ask.

## External vs Internal

**Safe to do freely:**

- Read files, explore, organize, learn
- Search the web, check calendars
- Work within this workspace

**Ask first:**

- Sending emails, tweets, public posts
- Anything that leaves the machine
- Anything you're uncertain about

references/AGENTS.md:145-177, 203-209:

markdown
## 💓 Heartbeats - Be Proactive!

When you receive a heartbeat poll (message matches the configured heartbeat prompt), don't just reply `HEARTBEAT_OK` every time. Use heartbeats productively!

You are free to edit `HEARTBEAT.md` with a short checklist or reminders. Keep it small to limit token burn.

### Heartbeat vs Cron: When to Use Each

**Use heartbeat when:**

- Multiple checks can batch together (inbox + calendar + notifications in one turn)
- You need conversational context from recent messages
- Timing can drift slightly (every ~30 min is fine, not exact)
- You want to reduce API calls by combining periodic checks

**Use cron when:**

- Exact timing matters ("9:00 AM sharp every Monday")
- Task needs isolation from main session history
- You want a different model or thinking level for the task
- One-shot reminders ("remind me in 20 minutes")
- Output should deliver directly to a channel without main session involvement

**Tip:** Batch similar periodic checks into 
...[truncated 4131 chars]
Remediation
View remediation

Remediation Suggestions

  1. Remove AGENTS.md and TOOLS.md from CORE_REFERENCES.
  2. Remove AGENTS.md from the persona loop in build_system_prompt().
  3. Do not package generic host-agent workspace templates inside a game Skill.
  4. Restrict the generated system prompt to files required for D&D behavior, such as game rules, game-state formats, and the DM persona.
  5. Prohibit Skill content from directing access to email, calendars, social accounts, unrelated repositories, heartbeat configuration, cron facilities, or workspace bootstrap files.
  6. If an optional integration is genuinely needed, expose it through a narrowly scoped capability that is disabled by default and requires explicit user authorization for each external action.
  7. Add an allowlist for prompt reference files and reject instructions that attempt to alter host-level policy or operate outside the Skill workspace.
  8. Require explicit confirmation before destructive operations, external communications, repository pushes, or modifications to host-agent configuration.

T02 · Agent Memory Poisoning

Error
Location
references/AGENTS.md:39
Finding

Skill Instructions Direct Persistent Writes to Agent Memory and Policy Files

Content
View full analysis

Vulnerability Details

File Location: references/AGENTS.md:39-62, 145-149, 177-186, 203-220; activation path in dnd-engine/src/dnd_engine/context/loader.py:15-28, 118-166, 184-209
Vulnerability Type: Persistent agent memory poisoning
Risk Level: High

Vulnerable Code

references/AGENTS.md:39-62:

markdown
## Memory

You wake up fresh each session. These files are your continuity:

- **Daily notes:** `memory/YYYY-MM-DD.md` (create `memory/` if needed) — raw logs of what happened
- **Long-term:** `MEMORY.md` — your curated memories, like a human's long-term memory

Capture what matters. Decisions, context, things to remember. Skip the secrets unless asked to keep them.

### 🧠 MEMORY.md - Your Long-Term Memory

- **ONLY load in main session** (direct chats with your human)
- **DO NOT load in shared contexts** (Discord, group chats, sessions with other people)
- This is for **security** — contains personal context that shouldn't leak to strangers
- You can **read, edit, and update** MEMORY.md freely in main sessions
- Write significant events, thoughts, decisions, opinions, lessons learned
- This is your curated memory — the distilled essence, not raw logs
- Over time, review your daily files and update MEMORY.md with what's worth keeping

### 📝 Write It Down - No "Mental Notes"!

- **Memory is limited** — if you want to remember something, WRITE IT TO A FILE
- "Mental notes" don't survive session restarts. Files do.
- When someone says "remember this" → update `memory/YYYY-MM-DD.md` or relevant file
- When you learn a lesson → update AGENTS.md, TOOLS.md, or the relevant skill
- When you make a mistake → document it so future-you doesn't repeat it

references/AGENTS.md:145-149, 177-186:

markdown
## 💓 Heartbeats - Be Proactive!

When you receive a heartbeat poll (message matches the configured heartbeat prompt), don't just reply `HEARTBEAT_OK` every time. Use heartbeats productively!

You are free to edit `HEARTBEAT.md` with a 
...[truncated 3929 chars]
Remediation
View remediation

Remediation Suggestions

  1. Delete all instructions that authorize writes to MEMORY.md, AGENTS.md, TOOLS.md, HEARTBEAT.md, daily memory files, or host-agent configuration.
  2. Store game continuity only in a dedicated, Skill-owned directory such as saves/ with a documented schema.
  3. Enforce a filesystem boundary that prevents the Skill from writing outside its game-state directory.
  4. Do not load host-level MEMORY.md, USER.md, or HEARTBEAT.md when constructing the D&D system prompt.
  5. Change build_system_prompt() to call load_context(..., include_optional=False) and remove host-state filenames from OPTIONAL_REFERENCES.
  6. Require explicit, per-operation user approval before persisting any information outside D&D save data.
  7. Never permit a Skill to modify global agent policy files or its own instruction files at runtime.
  8. Separate transient game context from host long-term memory, and clear transient state when the game session ends.
  9. Add tests verifying that invoking the Skill cannot create or modify files outside its designated save and cache directories.
Vulnerability Patterns
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
  • Excessive AgencyUnrestricted Tool Access, Autonomous Decision Making, Scope Creep
  • Rogue AgentSelf-Modification, Session Persistence
  • Behavioral ASTexec() Call, eval() Call, Dynamic Import
  • YARA SignaturesMalware Match, Webshell Match, Cryptominer Match
Findings (184)

Harmful Content Injection

Critical
Category
Prompt Injection
Confidence
95% confidence
Finding

This content may contain harmful instructions that could cause physical harm if followed. CRITICAL: Review carefully before use.

Content

Scanner excerpt · srd/references/DND5eSRD_077-086.md (reported line 427)May include surrounding context.

md
| True Polymorph | Transmutation | C |
| Weird | Illusion | C |
| Wish | Conjuration | — |

## Wizard Subclass: Evoker
*Create Explosive Elemental Effects*

Your studies focus on magic that creates powerful elemental effects such as bitter cold, searing flame, rolling thunder, crackling lightning, and burning acid. Some Evokers find employment in military forces, serving as artillery to blast armies from afar. Others use their power to protect others, while some seek their own gain.

### Level 3: Evocation Savant
Choose two Wizard spells from the Evocation school, each of which must be no higher than level 2, and add them to your spellbook for free.

Hidden Instructions

High
Category
Prompt Injection
Confidence
70% confidence
Finding

Hidden instructions were detected in comments or invisible text. These could contain malicious directives. Manual review is recommended.

Content

Scanner excerpt · CHANGELOG.md (reported line 122)May include surrounding context.

md
- **SKILL.md metadata**:声明支持 darwin/linux/win32

### 规则架构修复
- **6层规则重排**:26条规则按层0-5排序,每条规则添加 `<!-- layer: N -->` 标记
- **重复规则清理**:移除重复的规则21副本;规则X恢复(层5模组控制)
- **DM_RULES_INDEX.md 移除**:layer标记已内嵌在每条规则中,索引文件完全冗余
- **DMskill references 同步**:重建后的 DM_RULES.md 同步到所有位置

Hidden Instructions

High
Category
Prompt Injection
Confidence
70% confidence
Finding

Hidden instructions were detected in comments or invisible text. These could contain malicious directives. Manual review is recommended.

Content

Scanner excerpt · CHANGELOG.md (reported line 122)May include surrounding context.

md
- **SKILL.md metadata**:声明支持 darwin/linux/win32

### 规则架构修复
- **6层规则重排**:26条规则按层0-5排序,每条规则添加 `<!-- layer: N -->` 标记
- **重复规则清理**:移除重复的规则21副本;规则X恢复(层5模组控制)
- **DM_RULES_INDEX.md 移除**:layer标记已内嵌在每条规则中,索引文件完全冗余
- **DMskill references 同步**:重建后的 DM_RULES.md 同步到所有位置

Tp4

High
Category
MCP Tool Poisoning
Confidence
97% confidence
Finding

The documented behavior goes beyond a simple game master skill and includes environment validation, runtime/platform probing, port discovery, writing metadata files, and starting an API service. When operational capabilities are materially broader than the headline description, users may invoke the skill without understanding that it can inspect the host environment and modify the workspace.

Content

No source excerpt is available for this finding.

Tp4

High
Category
MCP Tool Poisoning
Confidence
98% confidence
Finding

The documented behavior goes beyond a simple game master skill and includes environment validation, runtime/platform probing, port discovery, writing metadata files, and starting an API service. When operational capabilities are materially broader than the headline description, users may invoke the skill without understanding that it can inspect the host environment and modify the workspace.

Content

No source excerpt is available for this finding.

Tp4

High
Category
MCP Tool Poisoning
Confidence
98% confidence
Finding

The documented behavior goes beyond a simple game master skill and includes environment validation, runtime/platform probing, port discovery, writing metadata files, and starting an API service. When operational capabilities are materially broader than the headline description, users may invoke the skill without understanding that it can inspect the host environment and modify the workspace.

Content

No source excerpt is available for this finding.

Tp4

High
Category
MCP Tool Poisoning
Confidence
96% confidence
Finding

The documented behavior goes beyond a simple game master skill and includes environment validation, runtime/platform probing, port discovery, writing metadata files, and starting an API service. When operational capabilities are materially broader than the headline description, users may invoke the skill without understanding that it can inspect the host environment and modify the workspace.

Content

No source excerpt is available for this finding.

Tp4

High
Category
MCP Tool Poisoning
Confidence
95% confidence
Finding

The documented behavior goes beyond a simple game master skill and includes environment validation, runtime/platform probing, port discovery, writing metadata files, and starting an API service. When operational capabilities are materially broader than the headline description, users may invoke the skill without understanding that it can inspect the host environment and modify the workspace.

Content

No source excerpt is available for this finding.

Tp4

High
Category
MCP Tool Poisoning
Confidence
94% confidence
Finding

The documented behavior goes beyond a simple game master skill and includes environment validation, runtime/platform probing, port discovery, writing metadata files, and starting an API service. When operational capabilities are materially broader than the headline description, users may invoke the skill without understanding that it can inspect the host environment and modify the workspace.

Content

No source excerpt is available for this finding.

Ae1

High
Category
analysis-evasion
Confidence
100% confidence
Finding

Referenced artifact was not completely inspected

Content

Scanner excerpt · SKILL.md (reported line 112)May include surrounding context.

md
| **world-lore** | 「深水城历史是怎样的?」「给我讲一段阴影帝国编年史」 | `data/world_cards.jsonl`(360 张知识卡) | `world-lore/scripts/lore_query.py` |

Hidden Instructions

High
Category
Prompt Injection
Confidence
70% confidence
Finding

Hidden instructions were detected in comments or invisible text. These could contain malicious directives. Manual review is recommended.

Content

Scanner excerpt · SKILL.md (reported line 179)May include surrounding context.

md
- 检定公式由 `dnd_engine.combat.checks` 结构化返回,LLM 仅展示结果
- 数据模板由 `dnd_engine.save.templates` 工厂生成,LLM 不自拼 JSON
- 自然1不重投,公平透明
- 26 条运行规则按 **6层架构** 组织(每条规则有 `<!-- layer: N -->` 标记)

### 战斗系统

Hidden Instructions

High
Category
Prompt Injection
Confidence
70% confidence
Finding

Hidden instructions were detected in comments or invisible text. These could contain malicious directives. Manual review is recommended.

Content

Scanner excerpt · SKILL.md (reported line 179)May include surrounding context.

md
- 检定公式由 `dnd_engine.combat.checks` 结构化返回,LLM 仅展示结果
- 数据模板由 `dnd_engine.save.templates` 工厂生成,LLM 不自拼 JSON
- 自然1不重投,公平透明
- 26 条运行规则按 **6层架构** 组织(每条规则有 `<!-- layer: N -->` 标记)

### 战斗系统

os.system() or os exec-family call

High
Category
Dangerous Code Execution
Confidence
85% confidence
Finding

os.system() and os exec-family calls run shell commands with the process's full privileges, enabling arbitrary command execution.

Content

Scanner excerpt · dnd-engine/src/dnd_engine/cli/__init__.py (reported line 288)May include surrounding context.

python
cmd += ['--port', args.port]
            if args.daemon:
                cmd.append('--daemon')
            os.execvp(sys.executable, cmd)
        else:
            print(f'Server not found at: {server_py}')
            sys.exit(1)

Context-Inappropriate Capability

High
Category
Not specified by scanner
Confidence
92% confidence
Finding

The fallback instruction explicitly tells the operator to manually execute commands in a local terminal when sandboxed, then paste results back. This encourages out-of-band execution that bypasses the skill's normal containment model and can lead to unintended code execution or disclosure of local data under the guise of assisting gameplay or maintenance.

Content

No source excerpt is available for this finding.

Hidden Instructions

High
Category
Prompt Injection
Confidence
70% confidence
Finding

Hidden instructions were detected in comments or invisible text. These could contain malicious directives. Manual review is recommended.

Content

Scanner excerpt · references/DM_RULES.md (reported line 57)May include surrounding context.

md
<!-- layer: 0 -->

Hidden Instructions

High
Category
Prompt Injection
Confidence
70% confidence
Finding

Hidden instructions were detected in comments or invisible text. These could contain malicious directives. Manual review is recommended.

Content

Scanner excerpt · references/DM_RULES.md (reported line 57)May include surrounding context.

md
<!-- layer: 0 -->

Hidden Instructions

High
Category
Prompt Injection
Confidence
70% confidence
Finding

Hidden instructions were detected in comments or invisible text. These could contain malicious directives. Manual review is recommended.

Content

Scanner excerpt · references/DM_RULES.md (reported line 2123)May include surrounding context.

md
<!-- layer: 0 -->

Hidden Instructions

High
Category
Prompt Injection
Confidence
70% confidence
Finding

Hidden instructions were detected in comments or invisible text. These could contain malicious directives. Manual review is recommended.

Content

Scanner excerpt · references/DM_RULES.md (reported line 2123)May include surrounding context.

md
<!-- layer: 0 -->

Self-Modification

High
Category
Rogue Agent
Confidence
85% confidence
Finding

Skill modifies its own code, configuration, or behavior at runtime. Self-modification enables an agent to escalate privileges, disable safety constraints, or install persistent backdoors.

Content

Scanner excerpt · references/TOOLS.md (reported line 36)May include surrounding context.

md
## Why Separate?

Skills are shared. Your setup is yours. Keeping them apart means you can update skills without losing your notes, and share skills without leaking your infrastructure.

---

Hidden Instructions

High
Category
Prompt Injection
Confidence
70% confidence
Finding

Hidden instructions were detected in comments or invisible text. These could contain malicious directives. Manual review is recommended.

Content

Scanner excerpt · srd/references/DND5eSRD_077-086.md (reported line 65)May include surrounding context.

md
System Reference Document 5.2.1

---
<!-- Page 78 -->

When you reach Wizard levels 4 and 10, you learn another Wizard cantrip of your choice, as shown in the Cantrips column of the Wizard Features table.

Hidden Instructions

High
Category
Prompt Injection
Confidence
70% confidence
Finding

Hidden instructions were detected in comments or invisible text. These could contain malicious directives. Manual review is recommended.

Content

Scanner excerpt · srd/references/DND5eSRD_077-086.md (reported line 201)May include surrounding context.

md
System Reference Document 5.2.1

---
<!-- Page 80 -->

### Level 2 Wizard Spells
| Spell | School | Special |

Hidden Instructions

High
Category
Prompt Injection
Confidence
70% confidence
Finding

Hidden instructions were detected in comments or invisible text. These could contain malicious directives. Manual review is recommended.

Content

Scanner excerpt · srd/references/DND5eSRD_077-086.md (reported line 392)May include surrounding context.

md
System Reference Document 5.2.1

---
<!-- Page 82 -->

### Level 8 Wizard Spells
| Spell | School | Special |

Hidden Instructions

High
Category
Prompt Injection
Confidence
70% confidence
Finding

Hidden instructions were detected in comments or invisible text. These could contain malicious directives. Manual review is recommended.

Content

Scanner excerpt · srd/references/DND5eSRD_077-086.md (reported line 535)May include surrounding context.

md
System Reference Document 5.2.1

---
<!-- Page 84 -->

of size that you can choose whether your character is Small or Medium.

YARA rule 'offensive_tool_references': References to well-known offensive security tools [hacktools]

High
Category
YARA Match
Confidence
70% confidence
Finding

YARA rule matched a hack tool or exploit indicator (offensive tools, reconnaissance, privilege escalation, or exploit frameworks).

Content

Scanner excerpt · srd/references/DND5eSRD_138-154.md (reported line 512)May include surrounding context.

md
ure in the Line makes a Dexterity saving throw, taking 8d6 Lightning damage on a failed save or half as much damage on a successful one.
***Using a Higher-Level Spell Slot.*** The damage increases by 1d6 for each spell slot level above 3.

### Locate Animals or Plants
*Level 2 Divination (Bard, Druid, Ranger)*

**Casting Time:** Action or Ritual
**Range:** Self
**Components:** V, S, M (fur from a bloodhound)
**Duration:** Instantaneous

Describe or name a specific kind of Beast, Plant creature, or nonmagical plant. You learn the direction and distance to the closest creature or plant of that kind within 5 miles, if any are present.

***
144 | System Reference Document 5.2.1
***

### Page 8

### Locate Creature
*Level 4 Divination (Bard, Cleric, Druid, Paladin, Ranger, Wizard)*

**Casting Time:** Action
**Range:** Self
**Components:** V, S, M (fur from a bloodhound)
**Duration:** Concentration, up to 1 hour

Describe or name a creature that is familiar to you. You sense the direction to

Natural-Language Policy Violations

Medium
Category
Not specified by scanner
Confidence
78% confidence
Finding

This markdown file begins with a Chinese-only title and the rest of the changelog is written entirely in Chinese, with no indication that users may choose another language or locale. Under the policy rule for natural-language violations, forcing a specific language without user opt-in is a reportable issue unless the locale constraint is explicitly justified.

Content

No source excerpt is available for this finding.

Static analysis

Detected: suspicious.dynamic_code_execution

Dynamic code execution detected.

Critical
Code
suspicious.dynamic_code_execution
Location
dnd-engine/src/dnd_engine/runtime/paths.py:115

Dynamic code execution detected.

Critical
Code
suspicious.dynamic_code_execution
Location
scripts/lens_pipeline.py:42