Commit ce4f44b
fix(security): scope invite token verification to tenant
getVerificationByKey looked up email verification tokens by key + kind
only, never checking the tenant. In a multi-tenant deployment an invite
token issued for tenant A could be redeemed on tenant B, granting the
attacker Member-level access to B (cross-tenant IDOR).
Anchor the lookup to the request's tenant by adding `tenant_id` to the
WHERE clause, mirroring the sibling getVerificationByEmailAndCode which
already does this. A mismatched tenant now yields ErrNotFound and the
redemption is rejected.
Adds a regression test asserting a key saved on one tenant is not
retrievable from another.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>1 parent 279e9a9 commit ce4f44b
2 files changed
Lines changed: 30 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
130 | 130 | | |
131 | 131 | | |
132 | 132 | | |
133 | | - | |
134 | | - | |
| 133 | + | |
| 134 | + | |
135 | 135 | | |
136 | 136 | | |
137 | 137 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
316 | 316 | | |
317 | 317 | | |
318 | 318 | | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
319 | 347 | | |
320 | 348 | | |
321 | 349 | | |
| |||
0 commit comments