audit: fix onboarding payment_url XSS + forum comment tenant check + joinSpace rate limit

Diversified audit across public/API, XSS/rendering, and legacy authz
surfaces (three independent reviews). No P0. Fixes:

- Onboarding payment_url (P1 stored XSS): rendered into an href with no
  protocol check; an admin could store javascript:. Sanitize at the sink
  with sanitizeUrl (http(s) only). Same class as the dues-url fix.
- forum.addComment (P2): only forum_thread targets were space-verified;
  proposal/incident/policy entity_ids were not, so a member could attach
  a comment to another space's entity. Verify the target exists in the
  caller's space (RLS-scoped) for every entity type before insert.
- joinSpace (P2): add a per-user rate limit (10/hr) for parity with
  createSpace/signIn, bounding invite-code guessing.
This commit is contained in:
Moheeb Zara
2026-05-20 02:22:50 -07:00
parent 36afa7ea2c
commit c0d6d496f8
4 changed files with 64 additions and 17 deletions
+6
View File
@@ -111,6 +111,12 @@ export async function joinSpace(formData: {
const { data: { user }, error: userErr } = await supabase.auth.getUser()
if (userErr || !user) return { error: 'Not authenticated' }
// Throttle to bound invite-code guessing (parity with createSpace/signIn).
const rateLimit = checkRateLimit(`joinspace:${user.id}`, 10, 3600000) // 10 per hour
if (!rateLimit.allowed) {
return { error: 'Too many join attempts. Please try again later.' }
}
// Use admin client for operations
const admin = createAdminClient()