← Back to Pull requests

fix(plc): require a verified, claimed org identity for building-group auto-roster #4584

Open
unknown opened this pull request with 231 lines diff across 2 files
View on GitHub
unknown unknown commented on Oct 23, 2026 01:52 UTC
Author

What was vulnerable


Building-group auto-roster (onUserProfileBuildingsChangedV1 trigger and the rosterBuildingGroup backfill run by createBuildingGroupV1/syncBuildingGroupV1) took auth.getUser(uid).email as the user's org identity without checking emailVerified. It also accepted any organizations/{org}/members/{email} doc not marked inactive/removed, including an unclaimed invited doc. Since email/password sign-in is enabled, anyone could register an invitee's address, set selectedBuildings, and be added as an active viewer to every auto-roster group for that building, gaining member read access to its PLC data. The lead/co-lead getUserByEmail fallback had the same gap.

What changed


  • BuildingGroupDeps.getUser/getUserByEmail now return emailVerified. Auto-roster and the lead/co-lead fallback in resolveAccount accept an account only when it is true.

  • isActiveOrgMember now requires status === 'active' and, when the member doc has a uid, that it matches the account being rostered.
  • No rules, client or data changes. Behaviour change: a teacher whose member doc is still invited (never claimed the invite) is not auto-rostered until they claim it; an admin can still add them by hand.

    How I checked


  • New tests in plcBuildingGroups.test.ts: an unverified account, an unclaimed invite and a member doc linked to another uid are not added by the trigger, the backfill, createBuildingGroup or syncBuildingGroup, and an unverified account cannot be resolved as a lead. They fail on the old code and pass now (37/37).

  • Existing tests unchanged apart from marking fake Auth users verified.

  • Accounts already rostered by the old check are not removed by this change and need a separate data sweep.
  • ---
    _Generated by Claude Code_

    Diff: 231 lines (+173 / -58) across 2 files Reviewer: claude[bot] Review duration: 16m
    All Vouch review confidence checks passed
    Residual risk 0.21 = Change Risk (0.37) × (1 − Review Confidence (0.43)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.37 · 231 lines diff across 2 files
    0.37
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    42%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Shallow Review Depth shallow_review_depth
    0.344
    Diff Size diff_size
    0.326
    Real PR Conversation Timeline
    1 comments
    "Review active on #4584"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 43.0% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 37% (MEDIUM) · Higher = larger blast radius
    37%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 43.0% · Lower = rushed or shallow review
    43.0%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 21.1% · Safe to merge
    21.1%