Skip to content

Commit f858b5d

Browse files
authored
fix(security): keep plain audit off plugin runtimes
Keep routine security audit on config/filesystem checks by default, reserving plugin runtime collectors for deep audit paths.\n\nThanks @vincentkoc
1 parent bbc3384 commit f858b5d

5 files changed

Lines changed: 32 additions & 4 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ Docs: https://docs.openclaw.ai
4242
- Discord/voice: lengthen the default voice join Ready wait, add configurable `voice.connectTimeoutMs`/`voice.reconnectGraceMs`, and warn before destroying unrecovered disconnected sessions so slow Discord voice handshakes and reconnects no longer fail silently. Fixes #63098; refs #39825 and #65039. Thanks @darealgege, @kzicherman, and @ayochim.
4343
- Gateway/health: refresh cached health RPC snapshots when channel runtime state diverges, so Discord and other channel status reads no longer report stale running or connected values until the cache TTL expires. (#75423) Thanks @clawsweeper.
4444
- Gateway/sessions: keep session-store reads from running stale prune and entry-count cap maintenance during startup, so oversized stores no longer block chat history readiness after updates while writes and `sessions cleanup --enforce` still preserve the cleanup safeguards. Fixes #70050. Thanks @tangda18.
45+
- Security/audit: keep plain `security audit` on the cold config/filesystem path and reserve plugin runtime security collectors for `--deep`, so large plugin installs cannot execute every plugin runtime during routine audits. Thanks @vincentkoc.
4546
- Discord/voice: merge configured media-understanding providers such as Deepgram into partial active provider registries, so follow-up voice turns keep transcribing after another media plugin is already active. Fixes #65687. Thanks @OneMintJulep.
4647
- WhatsApp: stage `qrcode` through root mirrored runtime dependencies so packaged QR pairing can render from staged plugin-runtime-deps installs. Fixes #75394. Thanks @FelipeX2001.
4748
- Discord/voice: apply per-channel Discord `systemPrompt` overrides to voice transcript turns by forwarding the trusted channel prompt through the voice agent run. Fixes #47095. Thanks @qearlyao.

‎docs/cli/security.md‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ openclaw security audit --fix
2525
openclaw security audit --json
2626
```
2727

28+
Plain `security audit` stays on the cold config/filesystem/read-only path. It does not discover plugin runtime security collectors by default, so routine audits do not load every installed plugin runtime. Use `--deep` to include best-effort live Gateway probes and plugin-owned security audit collectors; explicit internal callers may also opt into those plugin-owned collectors when they already have an appropriate runtime scope.
29+
2830
The audit warns when multiple DM senders share the main session and recommends **secure DM mode**: `session.dmScope="per-channel-peer"` (or `per-account-channel-peer` for multi-account channels) for shared inboxes.
2931
This is for cooperative/shared inbox hardening. A single Gateway shared by mutually untrusted/adversarial operators is not a recommended setup; split trust boundaries with separate gateways (or separate OS users/hosts).
3032
It also emits `security.trust_model.multi_user_heuristic` when config suggests likely shared-user ingress (for example open DM/group policy, configured group targets, or wildcard sender rules), and reminds you that OpenClaw is a personal-assistant trust model by default.

‎src/cli/security-cli.ts‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,10 @@ export function registerSecurityCli(program: Command) {
4141
() =>
4242
`\n${theme.heading("Examples:")}\n${formatHelpExamples([
4343
["openclaw security audit", "Run a local security audit."],
44-
["openclaw security audit --deep", "Include best-effort live Gateway probe checks."],
44+
[
45+
"openclaw security audit --deep",
46+
"Include best-effort live Gateway probes and plugin-owned security audit collectors.",
47+
],
4548
["openclaw security audit --deep --token <token>", "Use explicit token for deep probe."],
4649
[
4750
"openclaw security audit --deep --password <password>",
@@ -55,7 +58,7 @@ export function registerSecurityCli(program: Command) {
5558
security
5659
.command("audit")
5760
.description("Audit config + local state for common security foot-guns")
58-
.option("--deep", "Attempt live Gateway probe (best-effort)", false)
61+
.option("--deep", "Attempt live Gateway probes and plugin-owned collector checks", false)
5962
.option("--token <token>", "Use explicit gateway token for deep probe auth")
6063
.option("--password <password>", "Use explicit gateway password for deep probe auth")
6164
.option("--fix", "Apply safe fixes (tighten defaults + chmod state/config)", false)

‎src/security/audit-plugin-readonly-scope.test.ts‎

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ vi.mock("../plugins/runtime/metadata-registry-loader.js", () => ({
2323
loadPluginMetadataRegistrySnapshotMock(...args),
2424
}));
2525

26-
const { collectPluginSecurityAuditFindings } = await import("./audit.js");
26+
const { collectPluginSecurityAuditFindings, runSecurityAudit } = await import("./audit.js");
2727

2828
function createAuditContext(params: {
2929
sourceConfig: Parameters<typeof collectPluginSecurityAuditFindings>[0]["sourceConfig"];
@@ -152,4 +152,26 @@ describe("security audit read-only plugin scope", () => {
152152
expect(applyPluginAutoEnableMock).not.toHaveBeenCalled();
153153
expect(loadPluginMetadataRegistrySnapshotMock).not.toHaveBeenCalled();
154154
});
155+
156+
it("keeps plain security audit off plugin collector runtime discovery by default", async () => {
157+
const sourceConfig = {
158+
plugins: {
159+
allow: ["audit-plugin"],
160+
},
161+
};
162+
163+
await runSecurityAudit({
164+
config: sourceConfig,
165+
sourceConfig,
166+
env: {},
167+
includeFilesystem: false,
168+
includeChannelSecurity: false,
169+
stateDir: "/tmp/openclaw-test-state",
170+
configPath: "/tmp/openclaw-test-config.json",
171+
});
172+
173+
expect(getActivePluginRegistryMock).not.toHaveBeenCalled();
174+
expect(applyPluginAutoEnableMock).not.toHaveBeenCalled();
175+
expect(loadPluginMetadataRegistrySnapshotMock).not.toHaveBeenCalled();
176+
});
155177
});

‎src/security/audit.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -946,7 +946,7 @@ async function createAuditExecutionContext(
946946
execDockerRawFn: opts.execDockerRawFn,
947947
probeGatewayFn: opts.probeGatewayFn,
948948
plugins: opts.plugins,
949-
loadPluginSecurityCollectors: opts.loadPluginSecurityCollectors !== false,
949+
loadPluginSecurityCollectors: opts.loadPluginSecurityCollectors ?? deep,
950950
workspaceDir,
951951
configSnapshot,
952952
codeSafetySummaryCache: opts.codeSafetySummaryCache ?? new Map<string, Promise<unknown>>(),

0 commit comments

Comments
 (0)