Skip to content

fix(gateway): suppress ambient channel auto-enable from env credentials - #123174

Merged
steipete merged 1 commit into
mainfrom
steipete/upbeat-mahavira-c3cce3
Aug 13, 2026
Merged

steipete merged 1 commit into
mainfrom
steipete/upbeat-mahavira-c3cce3

Conversation

@steipete

Copy link
Copy Markdown
Contributor

What Problem This Solves

A gateway with no channel configuration could auto-enable channels purely from ambient host environment credentials inherited from the launching shell, and then mutate remote service state owned by the operator's real deployment. Observed on a scratch-profile gateway (plugins: {}, no channels.* config) started from a shell carrying the operator's env: Discord and SMS auto-enabled from DISCORD_BOT_TOKEN / TWILIO_*, and the Discord channel's native slash-command reconciliation deleted remote slash-command registrations belonging to the operator's production bot (extensions/discord/src/internal/command-deploy.ts deletes every remote global command not in its desired set; Telegram similarly runs deleteWebhook/setWebhook and a full command-menu clear at startup).

Why This Change Was Made

PR #112011 already built the suppression machinery (ambientEnvTriggers: "allow" | "suppress" across presence detection, activation planning, autostart, startup logging) but scoped it to --dev gateways only; production gateways defaulted to "allow" (src/gateway/server-startup-bootstrap.ts). The incident gateway ran a scratch profile, not --dev, so it got the production default.

Zero-config env-only activation is not the documented contract: every documented flow (openclaw channels add --use-env, onboarding, Docker, Fly) writes channels.<id>.enabled: true and uses env only as the default-account secret source ("Each channel starts automatically when its config section exists" — docs/gateway/config-channels.md). So the fix flips the default: ambient env-only channel presence no longer activates channels on any gateway. Explicit channels.<id> config still activates exactly as documented, and env vars still supply the default-account token for configured channels.

The opt-in is generalized: openclaw gateway run --ambient-channels restores ambient auto-configuration in any mode; --dev-ambient-channels remains as a deprecated alias. Startup logs the suppressed channel ids once and names the enablement path (openclaw channels add <id> / channels.<id>.enabled: true / --ambient-channels).

User Impact

  • A gateway whose config has no channels no longer adopts shell/env credentials, connects to live services, or mutates remote state (slash commands, webhooks, command menus). This closes the silent cross-deployment destruction path.
  • Operators using the documented flows are unaffected: channels.<id> config sections keep working, including env-var token fallback for the default account.
  • The undocumented "env var alone starts the channel" behavior now requires --ambient-channels (or a one-line channels.<id>.enabled: true). The startup warning states this when ambient-only credentials are detected.
  • Sibling channels are covered by the same generic seam: Discord/Telegram/Slack via channel env prefixes, SMS via manifest configuredState.env triggers — both are AMBIENT_ENV_SOURCES in the presence policy; no per-channel code changed.

Evidence

  • Production LOC delta: -4 (+15/-19); tests +53; docs +3. The fix generalizes and deletes the dev-only gating rather than adding a new path.
  • New regression test (src/gateway/server-startup-minimal-boot.test.ts): prepareGatewayServerBootstrap with the ambient option omitted resolves ambientEnvTriggers: "suppress" — fails on pre-fix code (default was "allow").
  • CLI seam tests (src/cli/gateway-cli/run.option-collisions.test.ts): default suppress with and without --dev; --ambient-channels (subcommand + inherited parent form) and the deprecated --dev-ambient-channels alias both resolve to "allow"; removed the obsolete dev-only-rejection test.
  • Focused suites green: channel-plugin-ids (170), run.option-collisions (74), server-startup-minimal-boot (2), server-startup-plugins (26), server-startup-log (14), server-channels (95), channel-plugin-blockers (34) via node scripts/run-vitest.mjs.
  • node scripts/check-changed.mjs: delegated to Blacksmith Testbox, exit 0 (lease stopped cleanly).
  • Source-blind CLI validation: --help shows both flags; default launch suppresses Discord (excluded from loaded plugins, suppression warning logged); --ambient-channels loads Discord without the warning.
  • Autoreview (Codex): clean, no accepted/actionable findings.
  • Known cosmetic follow-up: an earlier pre-suppression planning log line ("Discord configured, enabled automatically") still prints before the suppressed-channel warning; the channel is not loaded or started. Left as-is (outside the enablement seam).

@clawsweeper

clawsweeper Bot commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@steipete
steipete marked this pull request as ready for review August 13, 2026 12:05
@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation channel: discord Channel integration: discord channel: slack Channel integration: slack gateway Gateway runtime cli CLI command changes commands Command implementations size: S maintainer Maintainer-authored PR labels Aug 13, 2026
@steipete steipete self-assigned this Aug 13, 2026
@steipete
steipete force-pushed the steipete/upbeat-mahavira-c3cce3 branch from 54deb6f to ccf873f Compare August 13, 2026 17:32
@steipete
steipete merged commit 8e0f464 into main Aug 13, 2026
192 of 194 checks passed
@steipete
steipete deleted the steipete/upbeat-mahavira-c3cce3 branch August 13, 2026 18:20
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 14, 2026
steipete added a commit that referenced this pull request Sep 25, 2026
Carry the selected Gateway ambient policy into initial config auto-enable,
matching reload preparation. Require that policy at the startup config
boundary and classify explicit channel presence from authored source rather
than generated runtime enablement. Remove duplicate detector defaults.

Preserve explicit channel configuration and both ambient opt-in flags.
Document that the policy also applies to reloads and managed services.

Release-note context: env-only channel activation bypassed the documented
opt-in in stable releases through v2026.9.6. Affected operators must add
channels.<id> configuration or use --ambient-channels. Existing suppression
warnings explain the enablement path; no config migration should infer
operator consent from environment credentials. Completes the policy work
from #112011 and #123174 across the loader extracted in #110779.

Validation: 440 focused tests passed. Before the fix, the new suite had two
expected failures (suppression bypass and generated consent) and three
passes; after the fix all five pass. The authored-config/prior-release
corpus run had 24 passes and five 120-second timeouts, all in the first
Doctor checkpoint before Gateway config loading. No causal connection to
this fix was found; migration/worker timing remains a separate follow-up.
A standalone replay was stopped while waiting for the legitimate artifact
lock held by check-changed, before it reached Vitest.

The changed-check aggregate passed production typing, all 25 test-type
graphs, formatting, config docs, plugin boundaries and earlier guards, but
failed on the full-tree Knip export scan's 600-second timeout. The same
scan timed out when run alone with its unchanged limit; production/script
export scans passed. Changed-file lint passed with zero warnings/errors.
The native-state schema guard passed. The supplemental database-first
scan was stopped after over 16 minutes under host load around 179; later
media, sidecar, import-cycle, webhook and pairing guards were not run.
Full changed-check validation is not claimed green.
steipete added a commit that referenced this pull request Sep 25, 2026
…7387)

Carry the selected Gateway ambient policy into initial config auto-enable,
matching reload preparation. Require that policy at the startup config
boundary and classify explicit channel presence from authored source rather
than generated runtime enablement. Remove duplicate detector defaults.

Preserve explicit channel configuration and both ambient opt-in flags.
Document that the policy also applies to reloads and managed services.

Release-note context: env-only channel activation bypassed the documented
opt-in in stable releases through v2026.9.6. Affected operators must add
channels.<id> configuration or use --ambient-channels. Existing suppression
warnings explain the enablement path; no config migration should infer
operator consent from environment credentials. Completes the policy work
from #112011 and #123174 across the loader extracted in #110779.

Validation: 440 focused tests passed. Before the fix, the new suite had two
expected failures (suppression bypass and generated consent) and three
passes; after the fix all five pass. The authored-config/prior-release
corpus run had 24 passes and five 120-second timeouts, all in the first
Doctor checkpoint before Gateway config loading. No causal connection to
this fix was found; migration/worker timing remains a separate follow-up.
A standalone replay was stopped while waiting for the legitimate artifact
lock held by check-changed, before it reached Vitest.

The changed-check aggregate passed production typing, all 25 test-type
graphs, formatting, config docs, plugin boundaries and earlier guards, but
failed on the full-tree Knip export scan's 600-second timeout. The same
scan timed out when run alone with its unchanged limit; production/script
export scans passed. Changed-file lint passed with zero warnings/errors.
The native-state schema guard passed. The supplemental database-first
scan was stopped after over 16 minutes under host load around 179; later
media, sidecar, import-cycle, webhook and pairing guards were not run.
Full changed-check validation is not claimed green.

Co-authored-by: Peter Steinberger <[email protected]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 26, 2026
…nclaw#157387)

Carry the selected Gateway ambient policy into initial config auto-enable,
matching reload preparation. Require that policy at the startup config
boundary and classify explicit channel presence from authored source rather
than generated runtime enablement. Remove duplicate detector defaults.

Preserve explicit channel configuration and both ambient opt-in flags.
Document that the policy also applies to reloads and managed services.

Release-note context: env-only channel activation bypassed the documented
opt-in in stable releases through v2026.9.6. Affected operators must add
channels.<id> configuration or use --ambient-channels. Existing suppression
warnings explain the enablement path; no config migration should infer
operator consent from environment credentials. Completes the policy work
from openclaw#112011 and openclaw#123174 across the loader extracted in openclaw#110779.

Validation: 440 focused tests passed. Before the fix, the new suite had two
expected failures (suppression bypass and generated consent) and three
passes; after the fix all five pass. The authored-config/prior-release
corpus run had 24 passes and five 120-second timeouts, all in the first
Doctor checkpoint before Gateway config loading. No causal connection to
this fix was found; migration/worker timing remains a separate follow-up.
A standalone replay was stopped while waiting for the legitimate artifact
lock held by check-changed, before it reached Vitest.

The changed-check aggregate passed production typing, all 25 test-type
graphs, formatting, config docs, plugin boundaries and earlier guards, but
failed on the full-tree Knip export scan's 600-second timeout. The same
scan timed out when run alone with its unchanged limit; production/script
export scans passed. Changed-file lint passed with zero warnings/errors.
The native-state schema guard passed. The supplemental database-first
scan was stopped after over 16 minutes under host load around 179; later
media, sidecar, import-cycle, webhook and pairing guards were not run.
Full changed-check validation is not claimed green.

Co-authored-by: Peter Steinberger <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: discord Channel integration: discord channel: slack Channel integration: slack cli CLI command changes commands Command implementations docs Improvements or additions to documentation gateway Gateway runtime maintainer Maintainer-authored PR size: S

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant