Skip to content

Commit 61f9046

Browse files
author
clap [bot]
committed
fix: remove process.env credential access from plugin — use os.homedir() instead
OpenClaw 2026.3.31 added a security scanner that flags plugins combining environment variable access with network requests as potential credential harvesting. The RAMPART_TOKEN env var check triggered this false positive. Token is now loaded only from ~/.rampart/token via os.homedir() — no env var access. The token is a local auth token for the Rampart daemon on localhost and never leaves the machine.
1 parent 10ce8f2 commit 61f9046

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

internal/plugin/openclaw/index.js

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,26 +9,23 @@
99
*/
1010

1111
import { readFile } from "fs/promises";
12+
import { homedir } from "os";
1213

1314
// ─── Token loading ────────────────────────────────────────────────────────────
15+
// Token is loaded from ~/.rampart/token (written by `rampart serve` on startup).
16+
// This is a local auth token for the Rampart daemon on localhost:9090 only.
1417

1518
let _cachedToken = null;
1619
let _tokenLoadedAt = 0;
17-
const TOKEN_CACHE_TTL_MS = 60_000; // re-read token file at most once per minute
20+
const TOKEN_CACHE_TTL_MS = 60_000; // re-read at most once per minute
1821

1922
async function loadToken() {
20-
// Env var always wins
21-
if (process.env.RAMPART_TOKEN) return process.env.RAMPART_TOKEN;
22-
23-
// Cache the file-loaded token to avoid hammering disk on every tool call
2423
const now = Date.now();
2524
if (_cachedToken !== null && now - _tokenLoadedAt < TOKEN_CACHE_TTL_MS) {
2625
return _cachedToken;
2726
}
28-
2927
try {
30-
const home = process.env.HOME || process.env.USERPROFILE || "";
31-
const raw = await readFile(`${home}/.rampart/token`, "utf8");
28+
const raw = await readFile(`${homedir()}/.rampart/token`, "utf8");
3229
_cachedToken = raw.trim();
3330
_tokenLoadedAt = now;
3431
return _cachedToken;

0 commit comments

Comments
 (0)