> For the complete documentation index, see [llms.txt](https://www.openclawbook.xyz/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://www.openclawbook.xyz/en/ch32-security-model/32.5-soul-security.md). Agents can also search and read this documentation through its [MCP server](https://www.openclawbook.xyz/~gitbook/mcp).

# 32.5 SOUL Security: The Trust Position of Bootstrap Files

> **Generated by**: Claude Opus 5 (claude-opus-5\[1m]) **Token usage**: Input \~350,000 tokens, Output \~8,000 tokens (this section) **Source baseline**: `v2026.3.9` (`v2026.3.8-170-g665f67726`)

***

`SOUL.md` defines the agent's personality, boundaries, and tone. Together with `AGENTS.md`, `IDENTITY.md`, and `USER.md` it forms the workspace's **bootstrap files**, injected wholesale into context on a session's first turn.

This section addresses one specific question: **where do these files sit in the trust model?**

Along the way, a real case study — OpenClaw once shipped a hook that could replace `SOUL.md`, and later deleted it as a security problem.

## 32.5.1 Where Bootstrap Files Sit in the Trust Model

First, positioning. `SOUL.md`'s implementation is extremely plain — a constant in `src/agents/workspace.ts` plus a file read:

```ts
// src/agents/workspace.ts:26
export const DEFAULT_SOUL_FILENAME = "SOUL.md";
```

**There is no dedicated "SOUL security module," because none is needed.** `SECURITY.md` places it inside the trust boundary:

> If someone can edit workspace memory files, they already crossed the trusted operator boundary.

That precedent (§44.4.2) applies equally to bootstrap files. The reasoning chain:

```
someone who can modify SOUL.md
  = someone who can write ~/.openclaw and the workspace
  = someone who can change openclaw.json, read credentials, install plugins
  = a trusted operator
```

So "an attacker tampers with SOUL.md to make the agent misbehave" **is not a vulnerability report** — by that point they can already change your config and run arbitrary commands. Editing a personality file is the long way around.

**The real defense is filesystem permissions.** `openclaw security audit`'s `fs.*` checks (§32.6.4) inspect the permission bits on the state directory and workspace; a world-writable state dir is rated **critical**.

> This is also why this book has no "SOUL encryption" or "SOUL signing" content — those solve a threat that doesn't exist here. **Under a trusted-operator model, protecting files inside the trusted zone is a meaningless ritual.**

## 32.5.2 A Deleted Feature: soul-evil

OpenClaw historically bundled a hook called `soul-evil`. On a **random probability** or within a **daily fixed time window**, it would swap the `SOUL.md` content injected into context for a different file (`SOUL_EVIL.md`) — a "personality switch" novelty feature.

It no longer exists. The record in `CHANGELOG.md` is a single line:

```
## 2026.2.12
- Security: remove bundled soul-evil hook. (#14757) Thanks @Imccccc.
```

**Note the `Security:` prefix.** It wasn't cleaned up as an unused feature; it was removed as a **security problem**.

In the current version (`v2026.3.9`), `src/hooks/bundled/` contains only four hooks (§30.3.2):

```
boot-md
bootstrap-extra-files
command-logger
session-memory
```

### Why a "novelty feature" became a security problem

This is worth several paragraphs, because the mistake is easy to repeat in your own project.

Looked at in isolation, `soul-evil` is harmless: a local config option that gives your own agent a different personality during some window. You configured it, you bear the consequences — entirely consistent with the trusted-operator model.

The problem is that **it created a new path**:

```
The system contains a mechanism that can, at runtime, replace the
bootstrap file injected into the system prompt with the contents of
another file — and the trigger requires no confirmation at that moment.
```

Once that path exists, the attack surface isn't just "modify SOUL.md" anymore:

| Attack surface                      | Detail                                                                                                                                      |
| ----------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------- |
| **One more writable target**        | Writing `SOUL_EVIL.md` — a file the user may not be watching at all — is enough to change personality                                       |
| **One more config injection point** | Any path that can change hook config (a plugin, say — §21.5.6) can flip this switch                                                         |
| **Extremely high stealth**          | Probabilistic triggering means **the misbehavior is intermittent** — the user assumes the model is being flaky, not that it's been hijacked |

The last one is the killer. A personality hijack that fires 100% of the time gets noticed quickly. One that fires 5% of the time can be attributed to "AI is just like that sometimes" for months.

### The transferable judgment

The value of this case is a usable review heuristic:

> **Any mechanism that replaces a security-relevant input at runtime is an attack surface, no matter how harmless the intent.**

It's clearer against §44.4's stance: OpenClaw accepts that prompt injection can't be solved and spends its entire budget on the **permission boundary**. `soul-evil` drilled a hole on the *inside* of that boundary — it gave "influence the agent's behavior" a path that crosses no boundary at all.

In a system that has already given up on *preventing the model from being fooled*, **the one thing still defensible is not making hijacking convenient for the attacker**. Deleting it was correct.

> Another angle: the removal also shows that §44.4's "case-law trust model" is **alive** — `SECURITY.md`'s stance isn't only for closing external vulnerability reports; it's also used to audit the project's own features.

## 32.5.3 So How Should Bootstrap Files Be Protected?

Back to practice. Since there's no dedicated SOUL security mechanism, protection lands on three existing systems:

**1. Filesystem permissions.** The workspace directory and `~/.openclaw` should be `0o700`. `openclaw security audit` checks this (the `fs.*` checks) and `--fix` can repair permission issues automatically.

**2. The workspace as a git repository.** §44.3 covers a side benefit of "files first": **bootstrap file changes have diffs and history.**

```bash
cd ~/.openclaw/workspace && git init
```

After that, any change to `SOUL.md` shows up in `git status`. That's more practical than any encryption scheme — **it doesn't prevent changes, it makes changes impossible to hide.**

**3. Pay attention to who can write these files.** Per §21.5.6's inventory, **plugins can read and write arbitrary config and files.** So "bootstrap file security" is in practice equivalent to "the security of whichever plugins you installed."

§45.2 lists "one plugin means total compromise" as an architecture-level risk — this is one concrete manifestation.

### One exception: the flush prompt's safety suffix

There is one place OpenClaw does actively protect bootstrap files, worth comparing (§28.5.6):

The memory-flush turn before compaction has a default prompt explicitly instructing the model to **treat `MEMORY.md` / `SOUL.md` and other bootstrap files as read-only**, appending only to `memory/YYYY-MM-DD.md`.

And `ensureMemoryFlushSafetyHints` (`src/auto-reply/reply/memory-flush.ts:151-159`) guarantees: **even if the user customizes the flush prompt, these safety constraints are forcibly re-appended.**

> **Users can change the tone; they cannot change the safety boundary.**
>
> Note this protection targets the **model** (which can be injected — §44.4 places it in the untrusted zone), not the operator. That corroborates §32.5.1's division exactly: defenses go where untrusted principals can reach, not inside the trusted zone.

***

## Section Summary

1. **`SOUL.md` has no dedicated security module because it doesn't need one** — it sits inside the trust boundary. Anyone who can modify it can already change config, read credentials, and install plugins; tampering with a personality file is the long way around.
2. **The real defense is filesystem permissions**: `security audit`'s `fs.*` checks rate a world-writable state dir as critical.
3. **The `soul-evil` hook was removed as a security problem in `v2026.2.12`** (#14757); `src/hooks/bundled/` now contains only boot-md, bootstrap-extra-files, command-logger, and session-memory.
4. **Why it went from novelty to security problem**: it created a "replace the system-prompt input at runtime" path, adding a writable target and a config injection point — and **probabilistic triggering made hijacking extremely stealthy**, since intermittent misbehavior gets blamed on model flakiness.
5. **The transferable review heuristic**: **any mechanism that replaces a security-relevant input at runtime is an attack surface, regardless of intent.** In a system that has given up on preventing model deception, the one thing still defensible is not making hijacking convenient.
6. **Three practical protections**: permissions at `0o700`, **`git init` the workspace** (doesn't prevent changes, makes them impossible to hide), and knowing which plugins you installed (plugins can read/write anything).
7. **One active-protection exception**: the memory-flush safety hints can't be overridden by users — but they target the **model** (an untrusted principal), not the operator, consistent with this section's boundary division.

***

> ### 🔬 Going Deeper: 32.6 Source Deep Dive
>
> That's the end of the chapter's main text. If you're going to **modify this code**, or reproduce it in your own project, read on: [**32.6 Source Deep Dive: Admission, Secrets, and Audit**](https://www.openclawbook.xyz/en/ch32-security-model/32.6-source-deep-dive-admission-secrets-and-audit.md) traces the real implementation line by line along with the issues behind it, at a noticeably higher information density.
>
> **The main text is for understanding structure; the deep dive is for understanding trade-offs.**
