fix: enforce tenant data isolation and prevent silent cross-tenant leaks#12
Merged
fix: enforce tenant data isolation and prevent silent cross-tenant leaks#12
Conversation
…set) resolveCongregationFromRequest() was only called inside authenticated code paths. Unauthenticated pages (login, password forgot, password reset) on unknown subdomains rendered normally instead of redirecting to /congregation-not-found.
The Prisma 7 pg adapter breaks AsyncLocalStorage context propagation after awaited queries. The scoped db extension silently fell through to unscoped queries when context was missing, returning data from all congregations instead of just the current tenant. - Make db extension throw on missing congregation context (fail-safe) - Re-enter ALS context after each scoped query in the db extension - Re-enter ALS context in verifyRole() after its unscopedDb queries
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.
Summary
resolveCongregationFromRequest()and redirect to/congregation-not-foundfor unknown subdomains.AsyncLocalStoragecontext after awaited queries. The scopeddbextension silently fell through to unscoped queries, returning data from all congregations. Now it throws on missing context (fail-safe) and re-enters context after each query.verifyRole()re-enters ALS context before returning, so subsequentdbqueries in loaders have the correct tenant scope.Lyon Confluence) with generic placeholder in seed and register UI.Builds on #11 which handled session/login tenant validation.
Test plan
MULTI_TENANTunset) → no behavioral changepnpm test:unit— 316 tests passpnpm test:typecheck— cleanpnpm test:lint— clean