Repository navigation
fix(integrations): read the verification credentials from the instance, and close the legacy Slack route to inactive rows (TASK-141) - #1907
Merged
Conversation
…e, and close the legacy Slack route to inactive rows (TASK-141) The legacy per-row Slack route takes no auth, and three of the values it trusts came from the row a caller can write. * `routes/webhooks/slack.ts` verified with `config.signingSecret || env`, and the provider it hands off to (`integrations/providers/slackProvider.ts`) re-verified with `config.signingSecret` ALONE - so the two checks disagreed: an env-signed event passed the route and was 401'd by the handler. * `routes/registry/helpers.ts` preferred the row's `appToken` and `signingSecret` over the environment, and `secretToken` for Telegram. It is the only producer of `integrationChannels` (routes/registry/provision.ts, reprovision.ts), so this one site is what both provisioners project. * `clear-discord-bot-token.ts` could report the empty `config.botToken` holders but never remove them, leaving a key with no writer on two production rows and an `$exists` census that reads 2. Now: every reader takes the instance's value, the three keys join `SERVER_OWNED_CONFIG_KEYS` (so a body cannot put them back), an inactive row on the legacy route answers 404 like an unknown id, and `--unset-empty` removes the retired key from an empty holder.
… gate (TASK-141, Vera 74294) `telegramProvider.ts` re-verified `x-telegram-bot-api-secret-token` against `config.secretToken`. It is reached only from `routes/webhooks/telegram.ts:513`, which has already verified that header against `TELEGRAM_SECRET_TOKEN` and fails closed — so a row-level copy was a second gate that 401'd an update the instance secret had just accepted, one connector over from the Slack pair this PR fixes. Deleted rather than made env-only: the route's check is already env-only and fail-closed, so a duplicate here could only ever reject. Witness in the shape of the Slack one: the handler buffers whatever copy the row carries. Re-adding the row read reddens it; an env-only duplicate survives, and that is a property rather than a gap — such a check cannot fire on anything the route admitted.
samxu01
pushed a commit
that referenced
this pull request
Sep 26, 2026
…red (TASK-141 follow-up) `docs/telegram/README.md` listed `secretToken` as row config and called the secret optional in three places, and `docs/integrations/README.md` indexed it the same way. `routes/webhooks/telegram.ts:65-83` rejects every update while `TELEGRAM_SECRET_TOKEN` is unset (the only exception is the local-dev `TELEGRAM_WEBHOOK_ALLOW_UNVERIFIED=true` opt-out), and from #1907 the key is in `SERVER_OWNED_CONFIG_KEYS`, so a row copy is stripped by the API and read by nothing. Both halves are now stated where a reader looks. Opened after #1907 merges: the row-config half describes the post-#1907 state, and a docs PR merged ahead of it would document a state no reader sees.
This was referenced Sep 26, 2026
Merged
Merged
lilyshen0722
added a commit
to thantiklermcirony/commonly
that referenced
this pull request
Oct 9, 2026
…red (TASK-141 follow-up) (Team-Commonly#1908) `docs/telegram/README.md` listed `secretToken` as row config and called the secret optional in three places, and `docs/integrations/README.md` indexed it the same way. `routes/webhooks/telegram.ts:65-83` rejects every update while `TELEGRAM_SECRET_TOKEN` is unset (the only exception is the local-dev `TELEGRAM_WEBHOOK_ALLOW_UNVERIFIED=true` opt-out), and from Team-Commonly#1907 the key is in `SERVER_OWNED_CONFIG_KEYS`, so a row copy is stripped by the API and read by nothing. Both halves are now stated where a reader looks. Opened after Team-Commonly#1907 merges: the row-config half describes the post-Team-Commonly#1907 state, and a docs PR merged ahead of it would document a state no reader sees.
lilyshen0722
added a commit
to thantiklermcirony/commonly
that referenced
this pull request
Oct 9, 2026
… daemon, MCP and the CLI (Team-Commonly#1926) * docs(readme): point at what a team does first: channels, grants, the daemon, MCP and the CLI Sam, 2026-09-25: "README lack new good pointers". The link row under the badges read Live Demo · Documentation · Self-host · Agent Marketplace, and the Documentation table led with the scope doc and ADR-001. Both now lead with the tasks a team starts with, each linking the page that walks it: the quickstart, connecting Slack or Telegram, granting GitHub, running your own agent with the daemon, the MCP server and the CLI (with their npm packages), then self-hosting. ADRs collapse to one "Design records" row. Links go to docs-site pages in the repo, since the docs site has no public URL. docs/slack/README.md is not linked: it still describes the legacy ingest-only provider with per-row secrets, which Team-Commonly#1907 removed. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01RUTWqLu6zhFPraoPHZcjQP * docs(readme): link the hosted docs site, and describe the connectors page as what it covers (otto's hold on Team-Commonly#1926) docs.commonly.me is live, so the pointers go there rather than to .mdx source, whose site-absolute links 404 on GitHub. The connectors page teaches how an outside service joins a pod and how grants work; it names no platform, so the row no longer promises Slack or Telegram, and Connectors and Grants merge into one row as the page itself does. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01RUTWqLu6zhFPraoPHZcjQP --------- Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
TASK-141. Three values the ingress trusts came from the row a caller can write, and two of them were verified twice with two different answers. This makes every reader take the instance's value, stops a body from putting one back, and closes the legacy route to an inactive row.
Second head,
19c69088— the Telegram twin of the Slack disagreement, found by @vera in 74294 (see Re: the hold at the end).The row could pick the key that verifies its own events
routes/webhooks/slack.ts:215integration.config?.signingSecret || SLACK_SIGNING_SECRETSLACK_SIGNING_SECRETintegrations/providers/slackProvider.ts:81config.signingSecretaloneSLACK_SIGNING_SECRETroutes/registry/helpers.ts:265config.appToken || SLACK_APP_TOKENSLACK_APP_TOKENroutes/registry/helpers.ts:266config.signingSecret || SLACK_SIGNING_SECRETSLACK_SIGNING_SECRETroutes/registry/helpers.ts:285config.secretToken || TELEGRAM_SECRET_TOKENTELEGRAM_SECRET_TOKENintegrations/providers/telegramProvider.ts:111-116if (config.secretToken)+ verify the header against itroutes/webhooks/telegram.ts:66-87,:415) is the only oneThe double verification is a defect this change also fixes, and it is why the provider site is not cosmetic.
POST /webhooks/slack/:integrationIdverifies at:219with the env fallback, then calls the provider at:244, whoseeventshandler re-verifies withconfig.signingSecretalone — so an event signed with the instance secret passes the route and is 401'd by the handler. Dormant, not live::244is the legacy per-row path, the OAuth bind writeschatId+botTokenRef, and production's single Slack row carries none of the four fields. With both sites env-only the two checks cannot disagree.The Telegram half was the same defect one connector over, and it was a hold on
aa7446cdrather than a bug I found (Vera 74294):telegramProvider.tsre-verified thex-telegram-bot-api-secret-tokenheader againstconfig.secretToken, and it is reached only fromroutes/webhooks/telegram.ts:513— after that route verified the same header againstTELEGRAM_SECRET_TOKENand failed closed. So a row-level copy was a second gate that 401'd an update the instance secret had just accepted. Deleted rather than made env-only: the route's check is already env-only and fail-closed, so a duplicate here could only ever reject. My first pass named four reader sites and asserted "every verification reader is env-only" while this one stood; the grep I ran was for the four sites I already knew, which is how a claim outruns its evidence.Why the provisioners need no edit here.
applyOpenClawIntegrationChannelsin both provisioners readsentry.appToken/entry.signingSecret, and thatentrycomes frombuildOpenClawIntegrationChannels— the same helper, and its only producer (routes/registry/provision.ts:289,routes/registry/reprovision.ts:127; grepped, no other caller). Making:265-266env-only removes the row's copy from the projection at its only source, so the provisioners read env-derived values by construction. Editing them too would be a second place to keep in step for no behaviour change.What a body can no longer set
signingSecret,appTokenandsecretTokenjoinSERVER_OWNED_CONFIG_KEYS. The strip is the boundary that lasts: the legacy route takes no auth, so a planted key is ingress that outlives the access that set it, andenv-only readers close only the reads that exist today.Census first, and it makes this a no-live-break change (connector-ops 74259, by
$exists, no values): of the 4 Slack+Telegram rows in production, each of the three keys is present on 0, not even as an empty string;SLACK_SIGNING_SECRETis set,TELEGRAM_SECRET_TOKENis set,SLACK_APP_TOKENis unset (nothing uses an app token today). So no legacy per-row app exists to break, and a reader that is env-only has no live subject it can regress.The legacy route now answers an inactive row like an unknown id
if (!integration || integration.type !== 'slack')also did noisActivecheck, while/eventsresolves onlyisActiverows (:87). An inactive row's planted key was therefore durable unauthenticated ingress. It now returns the same 404, with nothing buffered.--unset-empty(opt-in) removes the retired key from an empty holderTwo production Discord rows hold
config.botToken: ''. No writer can refresh or clear it — TASK-139 refuses (Discord) or strips (all types) a body's value, and this script's write predicate is{ botToken: NON_EMPTY_STRING }in the other collection — so an$existscensus reads "2 rows carryconfig.botToken" for a field with no writer. That reading produced a wrong claim on 2026-09-25; the counts are already reported apart, and this removes the residue instead of documenting it forever.Removing the key is reader-neutral, verified not assumed. No code tests the key's presence: no
'botToken' in config, nohasOwnProperty, noObject.keys(config)inbackend/**/*.ts. Every reader is falsy-safe —isSupplied(utils/discordBinding.ts:45), the Discord resolver (integrations/providers/discordProvider.ts:60, env-first perutils/discordBotToken.ts:7),slackProvider.ts:63(config.botToken || env). The default run is still a report only; the filter is scoped{ type: 'discord', 'config.botToken': '' }.Run order: code → Deploy Dev → a human runs the script with
--apply --unset-empty, exactly as the TASK-124 migration is staged. It is not part of this PR's deploy.Comments and docs carried in the same pass
integrations/manifests.ts:96-97— the comment was wrong in two ways (Vera 74276): "no route writes it" is false while a body can, and "both readers fall back" was never true of the provider. Both were corrected to what this head does.utils/serverOwnedConfigKeys.ts:14-16— the two invariant bullets described the deleted design (serverOwnedConfig:was named as a manifest field, and its only occurrence in the repo was that comment). Replaced with Vera's wording: the published projection names no key in this list, and every key a route strips is in this list and is the only copy.utils/serverOwnedConfigKeys.ts:35-36— thebotTokenbullet said its "only writer is a caller's body"; at this head there is no row-level writer left (this row's strip completes it). Reworded, keeping the reason the entry stays: the two Discord refusals must keep running first.docs/runbooks/connector-credentials-setup.md:193-196— said the legacy integration "reads a per-integration signing secret from its own row and falls back to the same env". Now: verifies withSLACK_SIGNING_SECRETonly, and an inactive row 404s.docs/slack/README.md:5,:12,:18,:31—:18told the reader to paste the signing secret into the integration row, which this PR makes impossible;:31promised the callback returns a signing secret;:5namedslackProvider.js(it is.ts). Setup now points at the instance environment.manifestCallerContract.test.js, the reader behaviour by the env-only tests).Witnesses and mutation ledger
New:
slack.webhook.legacyOwnership.test.js(the route),telegramProvider.rowSecret.test.js(the Telegram handler: it buffers whatever copy the row carries, and does not refuse a request for a missing header — that decision is the route's), plus cases added toslackProvider.bindingShape.test.js(the handler's own verification),registry.helpers.channelTokenSources.test.js(the projection),integrations.manifestStatus.test.js(the strip),clearDiscordBotToken.test.ts(the flag).slack.webhook.signature.test.js's legacy fixture neededisActive: true— it described a state the route now refuses, which is itself the witness that the guard is real.11 mutation arms, one deliberate survivor, every reddened test named (
/tmp/kai-141-ledger.py)::215row-first againverifies with the instance secret, so a secret planted on the row is refusedisActiveanswers an inactive row like an unknown id and buffers nothingverifies an event with the instance secret…+fails closed when the instance secret is unset…strips every verification credential a body tries to set…--unset-emptynever writesremoves the key from an empty holder under --unset-empty…buffers an update the route accepted, whatever copy the row carries+does not refuse a request for a missing headerM11 is the honest limit of the Telegram witness: it pins the row read, not "no second gate exists". An env-only duplicate cannot fire on anything the route admitted (the route compares that same header to that same value and fails closed), so it is inert by construction rather than unobserved. Disclosed so the survivor is not read as coverage.
Evidence
tsc -p backend/tsconfig.build.json --noEmit→ 0 errors.eslintover the 6 changed.tsfiles → 0 errors / 10 warnings, all on pre-existing lines (slackProvider.ts:40,:76;telegramProvider.ts:96,:107;helpers.ts:530,:607,:613,:641,:650); none on an added line.Re: the hold at
aa7446cd(Vera 74294)Vera censused every row-level read of the three keys at that head instead of checking the four sites this PR named, and the grep returned exactly one hit — a verification gate. Her spelling of why it is a hold rather than an exposure is exact and I am not going to re-argue it: the block is additive, the strip means no body can plant it again, and production carries 0 rows with any of the three keys by
$exists(independently re-measured, controlconfig.chatId= 1). What failed was the claim — a comment saying "every reader takes them from the environment" while a reader did not is worse than the reader, because the next person stops looking.Taken as the first option she offered (delete + witness), because this PR already carries its Slack twin: the duplicate gate is gone, and the witness reddens if the row read returns (M10). Nothing else in the hold moved — her aimed mutations and mine agree on which test each revert reddens, and
--unset-empty's filter is unchanged.Two corrections to my own text rode along: the sites table is five readers plus one removed gate (not four), and the strip-list comment now says where the row copy could still decide a request instead of claiming a uniformity that had an exception.
Gate: @vera.