Skip to content

fix: strip comments from bundle to avoid install-time env-harvesting false positive#400

Merged
jalehman merged 1 commit into
mainfrom
fix/strip-bundle-comments
Apr 11, 2026
Merged

fix: strip comments from bundle to avoid install-time env-harvesting false positive#400
jalehman merged 1 commit into
mainfrom
fix/strip-bundle-comments

Conversation

@jalehman

Copy link
Copy Markdown
Contributor

Problem

OpenClaw's install-time security scanner has an env-harvesting rule that fires when both process.env and /\bfetch\b/i appear in the same source file. The pre-bundled dist/index.js contains process.env reads (for config like LCM_SUMMARY_MODEL, OPENCLAW_STATE_DIR) and the word "Fetch" in a JSDoc comment (* 1. Fetch all context items for the conversation). The case-insensitive regex matches the comment, triggering a critical finding that blocks installation.

Users see: "Environment variable access combined with network send — possible credential harvesting"

Reported by @DBCrypt0.

Fix

Add --minify-whitespace to the esbuild command. This strips all comments (including JSDoc) while keeping variable names and stack traces readable.

  • Bundle shrinks from 712KB → 552KB
  • Scanner no longer triggers the false positive
  • All 695 tests pass
  • No semantic change

Verification

// Before (triggers)
const src = fs.readFileSync('dist/index.js', 'utf8');
/process\.env/.test(src)                        // true
/\bfetch\b|\bpost\b|http\.request/i.test(src)  // true  ← JSDoc comment

// After (clean)
/process\.env/.test(src)                        // true
/\bfetch\b|\bpost\b|http\.request/i.test(src)  // false ← comments stripped

…false positive

The OpenClaw security scanner flags `process.env` combined with
`/\bfetch\b/i` as credential harvesting. The word 'Fetch' in a JSDoc
comment ('Fetch all context items') was triggering the network-send half
of the heuristic, blocking installation for users.

Adding --minify-whitespace to the esbuild command strips all comments
(including JSDoc) while keeping identifiers readable. Bundle shrinks
from 712KB to 552KB.
@jalehman jalehman merged commit 1711957 into main Apr 11, 2026
2 checks passed
@github-actions github-actions Bot mentioned this pull request Apr 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant