Skip to content

Commit aac0652

Browse files
committed
docs: sync from clawdbot main (Mar 9 sync 6+7, issue/PR updates, link fixes)
1 parent f2e2a32 commit aac0652

15 files changed

Lines changed: 297 additions & 41 deletions

02-technical/architecture.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ Docs: https://docs.openclaw.ai/gateway/configuration
9191

9292
### Input sanitization
9393

94-
`src/gateway/chat-sanitize.ts` strips platform envelope metadata (WhatsApp headers, message IDs, control characters) from user messages before processing. `sanitizeChatSendMessageInput()` (`src/gateway/server-methods/chat.ts:218`) rejects null bytes and strips disallowed control characters, allowing only tabs, newlines, carriage returns, and printable characters through.
94+
`src/gateway/chat-sanitize.ts` strips platform envelope metadata (WhatsApp headers, message IDs, control characters) from user messages before processing. `sanitizeChatSendMessageInput()` (`src/gateway/server-methods/chat.ts:228`) rejects null bytes and strips disallowed control characters, allowing only tabs, newlines, carriage returns, and printable characters through.
9595

9696
### Config merge-patch
9797

@@ -172,7 +172,7 @@ Below is a conceptual pipeline. Exact details vary by channel.
172172

173173
1.5) **Input sanitization**
174174
- Strip platform envelope metadata from user messages (`src/gateway/chat-sanitize.ts`)
175-
- Reject null bytes and strip unsafe control characters (`src/gateway/server-methods/chat.ts:218`)
175+
- Reject null bytes and strip unsafe control characters (`src/gateway/server-methods/chat.ts:228`)
176176

177177
2) **Identity + authorization**
178178
- Resolve sender identity.

04-privacy-safety/detecting-openclaw-requests.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ headers: {
169169
- **SSRF guard behavior:** The internal SSRF guard may produce distinctive redirect-following or timing patterns.
170170
- **Static version:** The hardcoded Chrome 122 version string will become increasingly stale over time, making it detectable via version-age analysis.
171171

172-
**Configurable:** Yes — `tools.web.fetch.userAgent` in the config (`src/config/types.tools.ts:502`).
172+
**Configurable:** Yes — `tools.web.fetch.userAgent` in the config (`src/config/types.tools.ts:508`).
173173

174174
---
175175

04-privacy-safety/hardening-checklist.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,7 @@ for line in sys.stdin:
340340
"
341341
```
342342

343-
Source: `src/config/io.ts:495-538` (audit helpers), `src/config/io.ts:1187-1237` (audit record builder)
343+
Source: `src/config/io.ts:511-538` (audit helpers), `src/config/io.ts:1187-1237` (audit record builder)
344344

345345
See: [AI Self-Misconfiguration Guide](../05-worst-case-security/ai-self-misconfiguration.md), [Attack #28](../05-worst-case-security/prompt-injection-attacks.md#-attack-28-config-self-modification-via-gateway-tool)
346346

05-worst-case-security/ai-self-misconfiguration.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ The system prompt example above is one instance of a broader pattern: **OpenClaw
123123
| System prompt | `src/agents/system-prompt.ts:484` | Soft — model can ignore |
124124
| SKILL.md instructions | Skill directories | Soft — model can ignore |
125125
| CLAUDE.md project rules | Project root | Soft — model can ignore |
126-
| Tool allowlist (`tools.exec.security: "allowlist"`) | Config (`src/config/types.tools.ts:184`) | **Hard — code enforced** |
126+
| Tool allowlist (`tools.exec.security: "allowlist"`) | Config (`src/config/types.tools.ts:232`) | **Hard — code enforced** |
127127
| Tool profiles (`"coding"`) | `src/agents/tool-policy.ts:63-80` | **Hard — code enforced** |
128128
| `set -euo pipefail` in scripts | Shell | **Hard — shell enforced** |
129129
| PreToolUse hooks | `.claude/hooks/` | **Hard — hook enforced** |
@@ -1048,12 +1048,12 @@ OpenClaw has several built-in protections. Understanding them helps you build on
10481048
| **Dangerous env var blocklist** | Blocks `LD_PRELOAD`, `NODE_OPTIONS`, etc. from being set via exec tools | `src/agents/bash-tools.exec-runtime.ts:40-54` |
10491049
| **Small model risk audit** | Warns when small/older models have tool access | `src/security/audit-extra.sync.ts:1088-1177` |
10501050
| **ALLOWED_FILE_NAMES** | Restricts which agent bootstrap files can be modified via `agents.files.set` | `src/gateway/server-methods/agents.ts:66` |
1051-
| **File permissions** | Config files created with `0o600`, directories with `0o700` | `src/config/io.ts:1121,1247` |
1051+
| **File permissions** | Config files created with `0o600`, directories with `0o700` | `src/config/io.ts:1137,1263` |
10521052
| **Tool profiles** | `"coding"` profile excludes the gateway tool entirely | `src/agents/tool-policy.ts:63-80` |
10531053
| **System prompt warning** | Soft instruction to not run `config.apply` without user request | `src/agents/system-prompt.ts:480` |
10541054
| **Restart sentinel** | Logs timestamp, session key, message, and stats on config-triggered restarts | `src/infra/restart-sentinel.ts:30-48` |
10551055
| **Strict schema validation** | Zod `.strict()` rejects unknown top-level keys and type errors | `src/config/zod-schema.ts:879` |
1056-
| **Forensic config write audit** | Every config write logged to `config-audit.jsonl` with PID, PPID, CWD, argv, content hashes, byte sizes, gateway-mode changes, and anomaly flags (size drops >50%, missing meta, gateway-mode removal) | `src/config/io.ts:495-538` (audit helpers), `:1177-1227` (audit record builder + append) |
1056+
| **Forensic config write audit** | Every config write logged to `config-audit.jsonl` with PID, PPID, CWD, argv, content hashes, byte sizes, gateway-mode changes, and anomaly flags (size drops >50%, missing meta, gateway-mode removal) | `src/config/io.ts:511-538` (audit helpers), `:1177-1227` (audit record builder + append) |
10571057

10581058
---
10591059

05-worst-case-security/operational-gotchas.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -589,7 +589,7 @@ set -euo pipefail
589589

590590
# 3. Use tool security modes
591591
# tools.exec.security: "allowlist" restricts which commands models can run
592-
# Source: src/config/types.tools.ts:231
592+
# Source: src/config/types.tools.ts:232
593593
openclaw config set tools.exec.security allowlist
594594

595595
# 4. Test model instruction-following before trusting with destructive ops

05-worst-case-security/prompt-injection-attacks.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -957,8 +957,8 @@ Alice
957957

958958
**OpenClaw's Defense:**
959959
OpenClaw wraps external hook content (including emails) with security boundaries:
960-
- `buildSafeExternalPrompt()` at `src/cron/isolated-agent/run.ts:386-394`
961-
- Suspicious pattern detection and logging at `src/cron/isolated-agent/run.ts:374-381`
960+
- `buildSafeExternalPrompt()` at `src/cron/isolated-agent/run.ts:453-462`
961+
- Suspicious pattern detection and logging at `src/cron/isolated-agent/run.ts:444-450`
962962
- External content wrapped with `<<<EXTERNAL_UNTRUSTED_CONTENT>>>` markers and security warnings (`src/security/external-content.ts:47-64`)
963963

964964
**Additional Defense:**

06-optimizations/resource-usage.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ Users report OpenClaw can be resource-intensive. This guide documents every reso
3737
| 11 | **Memory sync** — file hashing + markdown chunking + embedding + SQLite FTS5/vec indexing | `src/memory/manager.ts:380+` | Medium (periodic) | Like re-indexing a library catalog — scanning, categorizing, and filing every document |
3838
| 12 | **TTS generation** — ElevenLabs/OpenAI/Edge TTS API calls + audio buffer handling | `src/tts/tts.ts:557-724` | Medium | API calls are remote but audio buffer conversion is local CPU work |
3939
| 13 | **Agent execution loop** — continuous model response processing | `src/auto-reply/reply/agent-runner-execution.ts:74` | Medium (continuous) | The main "brain" loop — always running while the bot is responding |
40-
| 14 | **Cron timer loop** — re-arming `setTimeout` for scheduled job processing | `src/cron/service/timer.ts:533` | Low (idle) | Like a clock ticking in the background — minimal CPU unless jobs are firing |
40+
| 14 | **Cron timer loop** — re-arming `setTimeout` for scheduled job processing | `src/cron/service/timer.ts:547` | Low (idle) | Like a clock ticking in the background — minimal CPU unless jobs are firing |
4141

4242
### Other CPU consumers
4343

@@ -58,7 +58,7 @@ Users report OpenClaw can be resource-intensive. This guide documents every reso
5858
- `src/memory/qmd-manager.ts` — QMD process output is now unbounded (the previous `appendOutputWithCap()` output cap was removed; `MAX_QMD_OUTPUT_CHARS` no longer exists). The `resolveSpawnInvocation()` helper at `:72` handles Windows-compatible spawn routing.
5959

6060
**Media fetch buffering:**
61-
- `src/media/fetch.ts:132-148` — media fetch is now **bounded** when `maxBytes` is specified: `readResponseWithLimit()` (`src/media/read-response-with-limit.ts`) streams chunk-by-chunk and aborts early on overflow, preventing unbounded memory consumption. Falls back to unbounded `arrayBuffer()` only when no limit is specified (e.g., document fetches without size constraints).
61+
- `src/media/fetch.ts:137-159` — media fetch is now **bounded** when `maxBytes` is specified: `readResponseWithLimit()` (`src/media/read-response-with-limit.ts`) streams chunk-by-chunk and aborts early on overflow, preventing unbounded memory consumption. Falls back to unbounded `arrayBuffer()` only when no limit is specified (e.g., document fetches without size constraints).
6262

6363
---
6464

@@ -74,9 +74,9 @@ Users report OpenClaw can be resource-intensive. This guide documents every reso
7474
| Discord presence cache | `src/discord/monitor/presence-cache.ts:9` | 5000/account LRU | Low |
7575
| Telegram sent message cache | `src/telegram/sent-message-cache.ts:12` | 24h TTL, 100/chat | Low-Medium |
7676
| History map | `src/auto-reply/reply/history.ts:7` | 1000 keys LRU | Well bounded |
77-
| Inbound dedupe | `src/auto-reply/reply/inbound-dedupe.ts:8` | 5000 max, 20min TTL | Well bounded |
77+
| Inbound dedupe | `src/auto-reply/reply/inbound-dedupe.ts:9` | 5000 max, 20min TTL | Well bounded |
7878
| Gateway dedupe | `src/gateway/server-constants.ts:33-34` | 1000 max, 5min TTL | Well bounded |
79-
| Browser roleRefs | `src/browser/pw-session.ts:109-110` | 50 max LRU | Well bounded |
79+
| Browser roleRefs | `src/browser/pw-session.ts:112-113` | 50 max LRU | Well bounded |
8080
| Followup queues | `src/auto-reply/reply/queue/state.ts:18` | 20/queue, no queue count cap; `clearFollowupQueue()` (`queue/cleanup.ts:24`) clears individual queues during session cleanup | **Partially mitigated** — individual queues can be cleared but total queue-map still uncapped |
8181
| Agent event seqByRun | `src/infra/agent-events.ts:23` | **No cleanup** (`seqByRun` never pruned; `runContextById` now cleaned via `clearAgentRunContext()` at `:49`) | **Partial leak**`runContextById` fixed, `seqByRun` still leaks |
8282
| Agent run sequence | `src/gateway/server-runtime-state.ts:198` | **No pruning** (maintenance timer skips it) | **Leak risk** |
@@ -93,10 +93,10 @@ Users report OpenClaw can be resource-intensive. This guide documents every reso
9393
9494
### Browser memory
9595

96-
- **Chromium instance** (Playwright CDP): `src/browser/pw-session.ts:116` — singleton, but Chromium itself can consume **200MB to 2GB+**
96+
- **Chromium instance** (Playwright CDP): `src/browser/pw-session.ts:119` — singleton, but Chromium itself can consume **200MB to 2GB+**
9797
> *Like having a full web browser running invisibly in the background — it alone can use more memory than everything else combined.*
98-
- Per-page state caps: console (500), errors (200), network requests (500) — `src/browser/pw-session.ts:112-114`
99-
- WeakMaps used for page/context state (GC-friendly): `src/browser/pw-session.ts:102-105`
98+
- Per-page state caps: console (500), errors (200), network requests (500) — `src/browser/pw-session.ts:115-117`
99+
- WeakMaps used for page/context state (GC-friendly): `src/browser/pw-session.ts:105-108`
100100

101101
### Model context accumulation
102102

08-security-analysis/hudson-rock-infostealer-analysis.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747

4848
| # | Article Claim | Verdict | Codebase Evidence |
4949
|---|---------------|---------|-------------------|
50-
| 1 | `openclaw.json` contains gateway token | **CONFIRMED** | `gateway.auth.token` field; stored as plaintext JSON5 with `0o600` perms (`src/config/io.ts:1239`) |
50+
| 1 | `openclaw.json` contains gateway token | **CONFIRMED** | `gateway.auth.token` field; stored as plaintext JSON5 with `0o600` perms (`src/config/io.ts:1263`) |
5151
| 2 | `openclaw.json` contains email address | **LIKELY** | `auth.profiles.*.email` optional string field exists (`src/config/types.auth.ts:10`); OAuth profiles commonly include email |
5252
| 3 | `openclaw.json` contains workspace path | **CONFIRMED** | `agents[].dir` field configures workspace directories |
5353
| 4 | `device.json` contains crypto keys | **CONFIRMED** | ED25519 private + public key pair, device ID (SHA256 fingerprint) (`src/infra/device-identity.ts:57-63`); stored at `~/.openclaw/identity/device.json` (`src/infra/device-identity.ts:20-21`) with `0o600` perms (`src/infra/device-identity.ts:84,116-118`) |

08-security-analysis/issue-1796-argus-audit.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ All four AI-generated summaries in this project covered the report. The followin
1616
| [Gemini 3.0 Pro](../explain-clawdbot-gemini-3.0-pro/README.md) | Brief index entry only; lists "race conditions" as a key risk | **Inaccurate on race conditions** -- code uses `withFileLock()` from `src/infra/file-lock.ts` with PID-based stale detection; no race exists |
1717
| [Kimi K2.5](../explain-clawdbot-kilocode-kimi-k2.5/security-analysis.md#github-issue-1796-argus-security-audit) | Detailed 8-claim breakdown with code snippets, scanner statistics, remediation advice | **Inaccurate** -- accepts all 8 CRITICAL claims at face value; does not verify against source code; presents "plaintext storage" and "hardcoded secrets" as vulnerabilities rather than standard CLI practice per RFC 8252 |
1818

19-
**Key disagreement resolved:** Gemini 3.0 Pro accepted the race condition claim at face value. Code review (`src/agents/auth-profiles/oauth.ts:158` for `refreshOAuthTokenWithLock()`, config in `constants.ts:12`) confirms locking is correctly implemented. The other three models correctly identified this as a false positive.
19+
**Key disagreement resolved:** Gemini 3.0 Pro accepted the race condition claim at face value. Code review (`src/agents/auth-profiles/oauth.ts:154` for `refreshOAuthTokenWithLock()`, config in `constants.ts:12`) confirms locking is correctly implemented. The other three models correctly identified this as a false positive.
2020

2121
**Additional disagreement (Kimi K2.5):** Kimi K2.5 presents all 8 CRITICAL findings as actual vulnerabilities requiring remediation, including recommending keychain integration for token storage and disabling `config.patch` entirely. Code review confirms: (1) token storage with `0o600` permissions is standard CLI practice per RFC 8252, (2) `config.patch` executes inside Docker containers with `no-new-privileges`, (3) DNS pinning (`src/infra/net/ssrf.ts:276-363`) prevents the SSRF chain Kimi K2.5 describes, and (4) RBAC (`src/gateway/server-methods.ts:98-155`) prevents agent self-approval. The remediation advice in Kimi K2.5 is well-intentioned but addresses non-existent vulnerabilities.
2222

@@ -27,11 +27,11 @@ All four AI-generated summaries in this project covered the report. The followin
2727
| 1 | Plaintext OAuth token storage | **True, by design** | `src/infra/json-file.ts:22` sets `0o600` on every write. Standard for CLI tools (`gh`, `gcloud`). |
2828
| 2 | Missing CSRF in OAuth state | **False** | `extensions/google-gemini-cli-auth/oauth.ts:690` performs strict `state !== verifier` check. |
2929
| 3 | Hardcoded OAuth client secret | **True, standard practice** | [RFC 8252 Sections 8.4-8.5](https://datatracker.ietf.org/doc/html/rfc8252#section-8.4): CLI apps are "public clients." |
30-
| 4 | Token refresh race condition | **False** | `withFileLock()` from `src/infra/file-lock.ts` with PID-based stale detection, lock held throughout refresh+save (`src/agents/auth-profiles/oauth.ts:158`). |
30+
| 4 | Token refresh race condition | **False** | `withFileLock()` from `src/infra/file-lock.ts` with PID-based stale detection, lock held throughout refresh+save (`src/agents/auth-profiles/oauth.ts:154`). |
3131
| 5 | Insufficient file permission checks | **True, by design** | `0o600` on every write + `openclaw security audit`/`fix` tooling. |
3232
| 6 | Path traversal in agent dirs | **False** | Paths go through `resolveUserPath()` (`src/agents/agent-paths.ts:10,13`) which calls `path.resolve()` (`src/utils.ts:306,308`), normalizing traversal. IDs from env/config, not user input. |
3333
| 7 | Webhook signature bypass | **True, properly gated** | `skipVerification` in `extensions/voice-call/src/webhook-security.ts` requires explicit param; dev-only, off by default. |
34-
| 8 | Insufficient token expiry validation | **False** | `Date.now() < cred.expires` checked on every token use via inline checks (`src/agents/auth-profiles/oauth.ts:172,236`) and `tryResolveOAuthProfile()` (`src/agents/auth-profiles/oauth.ts:217-258`). |
34+
| 8 | Insufficient token expiry validation | **False** | `Date.now() < cred.expires` checked on every token use via inline checks (`src/agents/auth-profiles/oauth.ts:168,232`) and `tryResolveOAuthProfile()` (`src/agents/auth-profiles/oauth.ts:213-252`). |
3535

3636
**Result: 0 of 8 CRITICAL claims are actual security vulnerabilities.**
3737

0 commit comments

Comments
 (0)