T07 · Tool Hijacking and Spoofing
Error
- Location
- src/stream-entropy-breaker.cjs:132
- Finding
- Process-Wide Hijacking of the Global Fetch API<![CDATA[ ## Vulnerability Details **File Location**: `src/stream-entropy-breaker.cjs:132-137`; activation occurs at `deploy.sh:95-99` **Vulnerability Type**: Process-wide API replacement **Risk Level**: High ### Vulnerable Code `src/stream-entropy-breaker.cjs:132-137`: ```js function install() { if (global.__streamEntropyBreakerInstalled) return; if (!global.__originalFetch) global.__originalFetch = fetch; global.fetch = patchedFetch; global.__streamEntropyBreakerInstalled = true; } ``` `deploy.sh:95-99`: ```js const breaker = require("./dist/llm_stream_guard/stream-entropy-breaker.cjs"); if (breaker && breaker.install) { breaker.install(); } ``` ### Technical Analysis The installation function replaces Node.js's process-wide `global.fetch` implementation with `patchedFetch`. Consequently, every component in the gateway that uses the global Fetch API is routed through Skill-controlled logic. The interceptor does not restrict itself to configured LLM providers or approved endpoint URLs. Instead, it examines any response whose content type includes `text/event-stream`, `application/x-ndjson`, or `application/stream+json`. Its entropy heuristics can then abort the associated request. Because these content types are also used by legitimate non-LLM streaming APIs, the replacement can affect unrelated gateway integrations. Entropy heuristics are not a reliable security boundary and may produce false positives for intentionally repetitive data. ### Attack Path 1. An administrator runs `deploy.sh`. 2. The script appends bootstrap code to `openclaw.mjs`. 3. On the next gateway start, the bootstrap imports the stream breaker and invokes `install()`. 4. `install()` saves the original function and replaces `global.fetch`. 5. Any gateway module making a Fetch API request now invokes `patchedFetch`. 6. If the response uses one of the broadly matched streaming content types, its body is intercepted. 7. A sufficiently repetitive legitimate stream can trigg ...[truncated 576 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions - Do not replace `global.fetch`. - Integrate the breaker explicitly into the approved LLM client or request path. - Restrict interception to an administrator-configured allowlist of provider origins, endpoint paths, methods, and response types. - Make the feature opt-in and document the exact process-wide effects before installation. - Add false-positive handling, observability, and a configurable fail-open mode. - Preserve and remove request-signal event listeners when requests complete. - Provide an automated rollback mechanism that restores the original application entry point and networking behavior. - Add tests covering legitimate repetitive SSE and NDJSON responses from non-LLM services. ]]>
