Repository navigation
fix(organization): fail closed on unresolved org in ORGANIZATION_SETTINGS_UPDATE - #5104
Merged
Merged
Conversation
…INGS_UPDATE The cross-org guard `if (ctx.organization && ctx.organization.id !== input.organizationId)` only fired when ctx.organization was resolved. When it wasn't (e.g. a membership/header mismatch upstream leaves ctx.organization undefined), the whole condition was false and the client-supplied input.organizationId was used to write settings with no validation at all. Every sibling tool (member-add.ts, settings-get.ts) either checks unconditionally or derives the org id itself instead of trusting client input. Fix: use requireOrganization(ctx), which throws when the context has no resolved org, then compare unconditionally against input.organizationId.
pedrofrxncx
enabled auto-merge (squash)
July 23, 2026 16:24
decocms Bot
pushed a commit
that referenced
this pull request
Jul 23, 2026
PR: #5104 fix(organization): fail closed on unresolved org in ORGANIZATION_SETTINGS_UPDATE Bump type: patch - decocms (apps/mesh/package.json): 4.108.1 -> 4.108.2 Deploy-Scope: server
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.
Source: bug found while auditing
apps/mesh/src/tools/organizationfor auth-scoping issues (core services / tier-resolution focus area).Why a maintainer wants this: the cross-org guard in
ORGANIZATION_SETTINGS_UPDATEwasif (ctx.organization && ctx.organization.id !== input.organizationId) throw. That only rejects a mismatch whenctx.organizationis already resolved. Every sibling org-scoped write tool (e.g.member-add.ts'sif (organizationId !== ctx.organization?.id),settings-get.tsderiving the id itself) either checks unconditionally or never trusts client input for the org id — this tool was the one outlier.Failure scenario: if
ctx.organizationends up unresolved on a request that still passesctx.access.check()(e.g. an org-id/slug hint mismatch upstream incontext-factory.ts, which explicitly leavesctx.organizationundefined to "fail closed" for other tools), the guard here is skipped entirely and the handler upserts organization settings straight into whateverinput.organizationIdthe client supplied, with zero validation that the caller belongs to that org.Fix: replaced the conditional guard with
requireOrganization(ctx)(throws "requires organization scope" when unresolved) followed by an unconditional equality check againstinput.organizationId— matching the pattern already used elsewhere in this file's sibling tools.Regression test:
settings-update.test.ts(new file) — asserts (1) a mismatchedorganizationIdis rejected, (2) whenctx.organizationisundefinedthe handler throws "organization scope" and never callsstorage.organizationSettings.upsert, and (3) a matching id still succeeds.To verify:
bun test apps/mesh/src/tools/organization/settings-update.test.tsChecks run locally:
bun run fmt,cd apps/mesh && bunx tsc --noEmit(clean), and the targeted test file above (3 pass). Full CI validates the rest.Summary by cubic
Fixes an auth-scoping bug in
ORGANIZATION_SETTINGS_UPDATEby requiring a resolved organization and rejecting mismatchedorganizationId. This blocks unscoped updates whenctx.organizationis undefined and adds tests to prevent regressions.requireOrganization(ctx)and compareorganization.idtoinput.organizationId.settings-update.test.tscovering mismatch, unresolved context (no write), and success.Written for commit 958ec0a. Summary will update on new commits.