Repository navigation
fix(registry,integrations): instance-owned API base, owner-only webhook URL, admin-only moltbot routes - #2187
Merged
Merged
Conversation
…ok URL, admin-only moltbot routes Three writes that decide where the backend sends requests, or who can act as an agent, now require the right authority. - X / Instagram `config.apiBase` is server-owned. It joins SERVER_OWNED_CONFIG_KEYS, so POST/PATCH /api/integrations strip it, and the providers read only X_API_BASE_URL / INSTAGRAM_GRAPH_API_BASE or the official default. The two server-side writers (the admin global-integrations route and setup-global-social-feeds) stop storing a copy nothing reads. - `config.runtime.webhookUrl` takes the sole-installer rule from #2165, admins exempt. A webhook's replies are posted as the agent identity. - PATCH /pods/:podId/agents/:name applies ownsRuntimeIdentity when the body sets or changes the URL. Resending the stored value or clearing it does not. - POST /install applies the rule's negative clause, which is all that can be checked before the caller's installation exists. It does this through a new willSolelyInstallRuntimeIdentity in the same module, sharing the query with ownsRuntimeIdentity. - /api/providers/moltbot is admin-only. Every route on it acts through the instance's single provider, which the first /connect configures. Tests: registry.webhookUrl-ownership (10), providers.moltbot.adminOnly (9), socialProviderApiBase (3), and a server-owned apiBase arm. Each covers owner/admin allowed, other caller refused, nothing written on refusal. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01UPw8eqDcnT3Q6yPxVqpAC1
adminAuth reads the caller's User row on every request, so the router-level gate now runs a limiter first: platformIpRateLimit, 60 calls per 15 minutes per IP, the same budget as the admin global-integrations writes. The seven moltbot rows leave routeRateLimitGuard.baseline.json, which only shrinks. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01UPw8eqDcnT3Q6yPxVqpAC1
Picks up #2185. The only conflict was routeRateLimitGuard.baseline.json: main's version is kept, minus the seven moltbot rows this branch retires. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01UPw8eqDcnT3Q6yPxVqpAC1
lilyshen0722
commented
Oct 14, 2026
lilyshen0722
left a comment
Contributor
Author
There was a problem hiding this comment.
Review at 4f8d2ec (eng lead, code and security gate).
Checked:
- apiBase is server-owned:
apiBaseis inSERVER_OWNED_CONFIG_KEYS. The X and Instagram providers read onlyX_API_BASE_URL/INSTAGRAM_GRAPH_API_BASEor the official default, never the row. The admin global-integrations route andsetup-global-social-feeds.jsno longer write it. - webhookUrl on PATCH (
registry/agent-config.ts): setting or changingconfig.runtime.webhookUrlrequiresownsRuntimeIdentity(the #2165 sole-installer rule), admins exempt. Clearing it or resending the stored value is unaffected. - webhookUrl on install (
registry/install.ts):willSolelyInstallRuntimeIdentitychecks the negative clause only, since the caller's installation doesn't exist yet. It runs before any write, admins exempt. Both use the sharedotherInstallerFailure, so the ownership rule keeps one source. - No other writer: I searched every backend route, controller and service for writers of
webhookUrl.provision.tsandreprovision.tskeep the stored runtime config and add server values, never a request-supplied URL.App.webhookUrldelivery is #2188's scope. - Moltbot router: the whole
/api/providers/moltbotrouter isplatformIpRateLimit → auth → adminAuth, so/context,/searchand/writeno longer take an arbitrary podId from any user. Nothing in frontend, CLI, MCP or the gateway source calls this router. - CI: all checks are green (the cancelled version-guard run was superseded by a passing one), and no CodeQL alerts are open on the PR's merge ref.
- Tests at this head: 40 backend suites touching ownership, install, agent-config, the providers, server-owned keys, global integrations and the rate-limit guard pass (405 tests), including the PR's 4 new suites. Lint shows 0 errors on the 8 changed source files.
GATE: PASS
This was referenced Oct 15, 2026
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.
What this changes
Three writes now require the authority they imply. Each one decides where the backend sends requests or who can act as an agent.
1. X / Instagram
config.apiBaseis instance-ownedapiBasejoinsSERVER_OWNED_CONFIG_KEYS(backend/utils/serverOwnedConfigKeys.ts), soPOST/PATCH /api/integrationsstrip it from the body. This is the same mechanism and comment style assigningSecret/secretToken, which are also instance-owned.xProviderandinstagramProviderread onlyX_API_BASE_URL/INSTAGRAM_GRAPH_API_BASE, or the official default (https://api.x.com/2,https://graph.facebook.com/v19.0). A value already stored on a row is no longer read.Legitimate setters, checked: only two code paths ever wrote
apiBase, and both are server-side.routes/admin/globalIntegrations.ts, admin-only).scripts/setup-global-social-feeds.js.Both wrote exactly the env-or-default value the providers now compute themselves, so they stop storing a copy nothing reads. No test, frontend code or manifest sets it. Self-hosters keep the env vars. The schema field stays, as it did for the other instance-owned keys.
2. Setting
config.runtime.webhookUrltakes the #2165 sole-installer ruleA push webhook's replies (
outcome: 'posted') are posted as the agent identity, so the URL is a credential for that identity. This reusesservices/runtimeIdentityOwnership.tsand does not re-derive the rule. Admins are exempt.PATCH /api/registry/pods/:podId/agents/:name: this route already refused non-installer members (fix(registry): changing an installed agent requires its installer or an instance admin (TASK-055) #1746). Now, when the body sets or changes the webhook URL, the caller must also passownsRuntimeIdentity. Resending the stored value or clearing it is not gated.POST /api/registry/install: supplying a webhook URL requires that no other user holds an active installation of the identity. That is the rule's negative clause, the only part that can be checked before the caller's installation exists. It goes through a newwillSolelyInstallRuntimeIdentity, which shares one query withownsRuntimeIdentity;ownsRuntimeIdentity's behaviour is unchanged. The check runs before any write. Installing without a webhook URL is unaffected.403with the rule's failure code (another_installer,owner_installation_missing,unknown_installer) and a webhook-specific message.I enumerated the other writers of an installation's
config: reprovision and provision writeruntimeserver-side, and the native-routing sibling inheritance inagentEventServiceis in-memory only. None takes a body's webhook URL.3.
/api/providers/moltbotis admin-onlyEvery route on this router acts through the instance's single moltbot provider. The first
/connectfixes that provider's gateway, and the API token it uses to call Commonly. Operating it is now admin-only:router.use(moltbotProviderLimit, auth, adminAuth)replaces the per-routeauth. Nothing in the frontend, CLI, MCP package or gateway extension calls these routes.The limiter runs first because
adminAuthreads the caller's User row on every request. It usesplatformIpRateLimitwith 60 calls per 15 minutes per IP, the same budget as the admin global-integrations writes. CodeQL flagged the router-level gate without it (js/missing-rate-limiting). The seven moltbot rows leaverouteRateLimitGuard.baseline.json, which only shrinks. Removing the limiter turns the guard's "new route carries a limiter" test red.The branch merges
origin/mainto pick up #2185. Its only conflict was that same baseline file:main's version is kept, minus the seven moltbot rows.Tests
Run on Node 22.
registry.webhookUrl-ownership.test.js, new, 10 tests. The real ownership rule runs against an in-memory installation set.installer_only); admin allowed; resending the stored URL not gated.providers.moltbot.adminOnly.test.js, new, 9 tests. Uses the realadminAuth.socialProviderApiBase.test.js, new, 3 tests. A row carryingapiBasestill requests the official API; the env var still applies.integrations.serverOwnedConfig.test.jsgains anapiBasearm, with a non-server-owned control key in the same write.Mutation check. Ten arms, each landing once at a named line. All go red, and the suite count (6) and test total (44) stay constant in every arm:
apiBasedropped from the server-owned listapiBaseapiBaseLint: 0 errors on the 8 changed
.tsfiles. Every warning is on an unchanged line.tsc --noEmit -p tsconfig.build.jsonis clean.🤖 Generated with Claude Code
https://claude.ai/code/session_01UPw8eqDcnT3Q6yPxVqpAC1