Description
Triggering incident
A person signed up to AAO twice — once with a work email (paid for Professional, subscription active on org A), once with [email protected] (personal workspace, no subscription). The two WorkOS users were never linked. When they tried to start the S2 Creative Specialist exam logged in as gmail, the system blocked them with "membership required." Resolved manually via admin org-merge.
This is not a one-off. The system has no path from "this WorkOS user" to "any org this person paid through." Same gap will fire again the next time someone has work + personal emails.
Why this is the right place to fix it
Expert review (adtech-product-expert) was unambiguous: do not solve entitlements with a person-level identity primitive. Adtech precedent (TTD, DV360, GAM) runs entitlements as seats granted to login identities, scoped to an account. WorkOS already models this — we just aren't using it. A person-as-entitlement primitive breaks B2B (consultants in two member orgs inherit both, seat counts become uncountable, leavers keep entitlements).
The relationship/Addie identity work is a separate track (see companion issue, to be filed).
Scope
Three independent changes, shippable separately:
1. Stripe checkout binds to workos_user_id (security fix)
Today handle-subscription-created resolves customer email → org, which is buyer-controllable (security review flagged this as HIGH severity — attacker can redirect a victim's subscription via crafted checkout email).
- Set
client_reference_id(ormetadata.workos_user_id) server-side at checkout-session creation - Webhook attaches subscription to the org of that WorkOS user, not to a fuzzy-resolved customer email
- Email-based resolution becomes advisory only — surfaced for admin review, never moves money or entitlements automatically
Files: server/src/billing/handle-subscription-created.ts, server/src/billing/stripe-client.ts (checkout-session creation)
2. Signup detects existing paying org for the email's domain
When a new WorkOS user signs up and there's an active-subscription org with a matching email_domain, prompt: "We found a paid membership for [domain]. Request to join, or continue with a personal workspace?"
This is a static auth-flow screen, not an Addie conversation (identity is a security boundary; LLMs don't belong in security boundaries — agentic-product-architect was firm on this).
Files: signup flow, WorkOS organization invite API
3. Surface user-initiated email link at access-block time
When entitlement check fails on a personal workspace, the response includes "Have another email associated with a paid membership?" link → existing email-link-token flow (substrate exists at server/src/db/migrations/334_email_link_tokens.sql).
User authenticates session A, requests link, system sends signed challenge to email B; user confirms while authenticated as B → both WorkOS users joined to the paying org via WorkOS invite. Proof-of-control on both sides; no fuzzy auto-merge anywhere in the path.
Files: server/src/addie/mcp/certification-tools.ts:35 (membershipRequiredMessage), server/src/middleware/auth.ts (link-token verification)
Out of scope
- Building a
personstable — that's the relationship-model track, separate issue - Auto-merge of any kind — security review identified multiple HIGH-severity attack paths in fuzzy auto-merge; all merges are user-initiated with proof of control on both identities
- Consolidating credentials across WorkOS users — credentials stay bound to the originating
workos_user_id
Done state
- Stripe webhook test: subscription with attacker-controlled customer email cannot redirect to victim's org
- Signup test: user with email at
domain.commatching an active-subscription org sees the join-existing-org prompt - Access-block test: user blocked at
start_certification_examon personal workspace can initiate link-to-other-email and complete it without admin involvement - Tom-class incidents drop to zero in escalations
References
- Triggering escalation: Addie escalation Add docker network prune to workspace setup #296 (
[email protected]/ "Lina Georg" / S2 block, 2026-04-29) - Related: Direct-link join flow with payment chooser (replace per-invite tokens) #3173 (direct-link join flow with payment chooser) — overlaps with §2
- Memory:
feedback_account_invariant.md(everyone is an account; magic-link provisioning preferred over email-only pools)
Activity
bokelley commentedon Apr 30, 2026
Triage
Classification: Bug (security) + Feature request
Bucket(s): security-sensitive, admin / ops tools, addie
Status: ready-for-human
What the experts said:
workos_user_idinto subscription metadata server-side; concern:createAndSendInvoice(admin-invoice path) stampsworkos_organization_idbut notworkos_user_id, so invoice-billed orgs still fall through to email fallback after §1 ships. §3 confirm handler must implement an explicittarget_emailcheck against the authenticated session-B identity and an atomicUPDATE WHERE status='pending'to prevent TOCTOU and replay.membershipRequiredMessageis an LLM prompt string, not a UI affordance; the merge flow needs scaffolding (Addie tool/deep-link, entitlement re-evaluation) that isn't in the spec. Minimum safe §3: plain "sign in with a different email" redirect rather than inline merge.alias_of_workos_user_idFK onorganization_memberships, §3 builds the person-as-entitlement primitive the issue explicitly rules out, just spelled differently.My take: §1 is the load-bearing change and is safe to execute once the invoice-path gap is resolved; §3 cannot ship as specified without a seat-alias primitive, and experts flagged this as a blocker on the current spec.
@bokelley, your calls:
createAndSendInvoice(still falls to email lookup), or is the invoice path a separate follow-up?alias_of_workos_user_idcolumn onorganization_membershipsin scope here, or does it move to the persons-table track?Triaged by Claude Code. Session: https://claude.ai/code/cse_01KKJebzZ2JMxWgWqRyeEcfg
Generated by Claude Code
bokelley commentedon Aug 13, 2026
Split entitlement reconciliation into:
These have different trust boundaries and should not ship as one change.
bokelley commentedon Sep 21, 2026
Closing this decomposed identity/billing umbrella. Attribution, verified organization join, and safe account recovery are tracked in #6492–#6494.