Skip to content

fix(platforms): strip secrets from bridge subprocess env - #56245

Open
necoweb3 wants to merge 1 commit into
NousResearch:mainfrom
necoweb3:fix/platform-bridge-env-strip
Open

fix(platforms): strip secrets from bridge subprocess env#56245
necoweb3 wants to merge 1 commit into
NousResearch:mainfrom
necoweb3:fix/platform-bridge-env-strip

Conversation

@necoweb3

@necoweb3 necoweb3 commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Summary

Strip Hermes secrets from platform bridge subprocess environments.

Raft and WhatsApp both spawn local bridge subprocesses from the gateway process. Those subprocesses previously inherited the full gateway os.environ:

  • plugins/platforms/raft/adapter.py used {**os.environ, "RAFT_CHANNEL_TOKEN": ...}.
  • plugins/platforms/whatsapp/adapter.py called with_hermes_node_path() with no base env, which copies os.environ.

That leaks unrelated Hermes credentials and gateway-internal secrets into platform bridge child processes, including provider API keys, AUXILIARY_* side-LLM credentials, and GATEWAY_RELAY_* material.

Changes

  • Build the Raft bridge env from hermes_subprocess_env(inherit_credentials=False).
  • Re-add only the Raft bridge values the child actually needs: RAFT_PROFILE and RAFT_CHANNEL_TOKEN.
  • Build the WhatsApp bridge env from the same sanitized helper before adding Hermes-managed Node paths.
  • Re-add the WhatsApp bridge values the child actually needs: WHATSAPP_MODE, cache directory paths, and optional reply prefix.
  • Add regression coverage proving provider/internal secrets are not passed to either bridge subprocess.

Why

Platform bridges do not need LLM provider credentials or gateway relay credentials. They only need their own narrow bridge configuration. This mirrors the subprocess secret-stripping policy now used by the terminal/codex/docker child-process paths.

Tests

python -m pytest tests/gateway/test_raft_adapter.py -q --timeout-method=thread
17 passed

python -m pytest tests/gateway/test_whatsapp_stale_bridge.py tests/gateway/test_whatsapp_reply_prefix.py -q --timeout-method=thread
19 passed

@alt-glitch alt-glitch added type/security Security vulnerability or hardening comp/plugins Plugin system and bundled plugins platform/whatsapp WhatsApp Business adapter area/auth Authentication, OAuth, credential pools P2 Medium — degraded but workaround exists sweeper:risk-security-boundary Sweeper risk: may affect sandboxing, auth, credentials, or sensitive data labels Jul 1, 2026
@teknium1

Copy link
Copy Markdown
Contributor

Thanks for addressing the verified Raft and WhatsApp bridge leaks. The two proposed bridge substitutions correctly use the existing sanitizer in tools/environments/local.py:471-522 and preserve the bridge-specific values.

Problems

  • plugins/platforms/whatsapp/adapter.py:546-552 still launches npm install with with_hermes_node_path() and no base environment. hermes_constants.py:521-523 shows that this copies os.environ, so gateway/provider secrets remain exposed to npm and lifecycle subprocesses.
  • A sibling platform sidecar remains unsanitized: plugins/platforms/photon/adapter.py:936-974 copies os.environ and passes it to its Node Popen child.

Suggested changes

  • Sanitize the WhatsApp npm-install environment and add an assertion on subprocess.run(..., env=...).
  • Apply the same explicit allowlist pattern to the Photon sidecar, restoring only its documented required values and covering it with regression tests.

Automated hermes-sweeper review.

@teknium1 teknium1 added sweeper:risk-compatibility Sweeper risk: may break existing users, config, migrations, defaults, or upgrades sweeper:blast-moderate Sweeper blast radius: moderate — a subsystem or single platform labels Jul 15, 2026
@andrexibiza

Copy link
Copy Markdown
Contributor

Bound to the child-process credential-inheritance class under #83565 (#83565) — same bug class, different surface. platform bridge subprocess env strip; Wave E — sibling to #38080 on plugins/platforms/whatsapp/adapter.py; adjudicate the pair before merging. The EPIC carries the live class table, dedup adjudication, and the dependency-driven merge order.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/auth Authentication, OAuth, credential pools comp/plugins Plugin system and bundled plugins P2 Medium — degraded but workaround exists platform/whatsapp WhatsApp Business adapter sweeper:blast-moderate Sweeper blast radius: moderate — a subsystem or single platform sweeper:risk-compatibility Sweeper risk: may break existing users, config, migrations, defaults, or upgrades sweeper:risk-security-boundary Sweeper risk: may affect sandboxing, auth, credentials, or sensitive data type/security Security vulnerability or hardening

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants