fix: keep tenant identity out of public write payloads - #2088
Open
richardfogaca wants to merge 2 commits into
Open
fix: keep tenant identity out of public write payloads#2088richardfogaca wants to merge 2 commits into
richardfogaca wants to merge 2 commits into
Conversation
richardfogaca
marked this pull request as ready for review
July 29, 2026 20:04
Member
|
Wondering why Ideally we don't need things like stripTenantIdFromMutation across the codebase. Wondering why tenant_id leaked into the caller (?) |
Contributor
Author
|
@mistercrunch Removed New write boundary
Validated against PostgreSQL
|
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.
Linked issue
Related: #2076
Summary
tenant_idat one provider-aware boundary for external create, update, and patch operations across every tenant-owned service.stripTenantIdFromMutation; keep database-wrapper ownership materialization and PostgreSQL RLS behavior unchanged.Why / context
Tenant identity is ambient, not a public write field. The root tenant hook previously mixed those responsibilities by adding
tenant_idto create DTOs and silently stripping it from update/patch DTOs. Stamping caused strict public-field validation to reject valid schedule creates, while stripping hid invalid ownership input instead of rejecting it.The corrected boundary is:
external write → reject tenant_id → validate unchanged DTO → service write → database wrapper materializes/preserves ownership → RLS enforces visibilityImplementation notes
tenant_idrejection for create, update, and patch on all tenant-owned services in both SQLite and PostgreSQL modes. Internal provider-less calls remain outside this external boundary.Validation / test plan
Automated and review evidence
PostgreSQL boundary proof
Using the non-bypass application role with forced RLS:
tenant_id = default.tenant_idreturned400, with no write.tenant_idreturned400, while a control request reached update.tenant_idreturned400.1 → 0 → 1when tenant context changeddefault → attacker-tenant → default.Fixtures were removed after validation.
Screenshots / demos
Not applicable; this is a backend write-boundary change.
Risks / rollout / rollback
The change is centralized across tenant-owned writes, so the main risk is rejecting a caller that incorrectly sends
tenant_id. That rejection is intentional and returns400. Coverage spans both database modes, representative services and methods, valid controls, stored ownership, and forced-RLS visibility. Rollback is a normal revert of the commit.Out of scope / follow-ups
DrizzleService.stripTenantMutationis outside this compatibility audit.