Security

Threat model

ulex's threat model: assets, trust boundaries, adversaries, abuse cases, and what is deliberately not defended — with the mitigations and the accepted risks stated plainly.

Scope: the ulex control plane, its MCP endpoint, its OIDC/SAML/SCIM protocol surfaces, and the webhooks it delivers. Not in scope: the security of the underlying cloud infrastructure beyond the controls described in Architecture and Compliance matrix, and the security of your application once it holds a valid token.

#Assets

#AssetIf lostWhy it matters
A1Signing keysanyone can mint a valid access token for any usertotal compromise
A2KMS CMKevery stored secret is decryptabletotal compromise
A3Tenant API keyscontrol-plane access as the tenanttenant-wide
A4User identity recordsan attacker can authenticate as real peopleaccount takeover
A5The audit logaccountability is gone; SOC 2 and HIPAA evidence is invalidregulatory
A6Sessions and refresh tokensan attacker is logged in as a useraccount takeover
A7SAML assertion signing certificatesforged assertionsaccount takeover
A8Webhook secretsforged events into your pipeline, or blind spotsintegrity
A9SCIM tokensan attacker can provision or deprovision your usersintegrity
A10PHI minimisationa breach becomes a HIPAA notificationregulatory

A1, A2 and A5 are the ones that are not recoverable by rotation. The rest are.

#Trust boundaries

text
┌──────────────────────────────────────────────────────────────────┐
│  TB1  Internet                                                     │
│  ┌────────────┐  ┌────────────┐  ┌──────────────┐                 │
│  │ your app   │  │ customer   │  │ agent / CLI  │   untrusted    │
│  │ (RP)       │  │ IdP        │  │              │                 │
│  └─────┬──────┘  └─────┬──────┘  └──────┬───────┘                 │
├────────┼────────────────┼────────────────┼─────────────────────────┤
│  TB2   CloudFront → API Gateway → Lambda            authenticated  │
│        ┌──────────────────────────────────────────────┐           │
│        │  api · protocol · mcp · worker                │           │
│        └───────────────────┬──────────────────────────┘           │
├────────────────────────────┼───────────────────────────────────────┤
│  TB3  VPC (no inbound, no NAT)    data plane                        │
│        ┌───────────────────┬──────────────────────────┐            │
│        │ DynamoDB          │ KMS · SQS                │  internal  │
│        └───────────────────┴──────────────────────────┘            │
└─────────────────────────────────────────────────────────────────────┘

  ┌──────────────────────────────────────────────────────────────────┐
  │  TB4  Outbound to a customer's IdP — ulex is the untrusted party │
  │        (an IdP is a third party; its certificate is the boundary)│
  └──────────────────────────────────────────────────────────────────┘
BoundaryTrust assumption
TB1 → TB2Nothing is trusted. Every field is validated, every secret is a bearer token, every SAML document is parsed with DTDs and external entities disabled
TB2 → TB3Lambda code is trusted. It holds the CMK's Decrypt and GenerateDataKey. A code-execution bug here is a CMK compromise
TB3 → internetThere is no path. No inbound route, no NAT gateway on the data plane, IMDS hop limit 1
TB2 → TB4The customer's IdP is not trusted. A compromised IdP can authenticate as anyone in that customer. ulex's job is to verify the assertion, not to vouch for the IdP
The webhook receiverNot trusted. A signed event means "ulex sent this", not "this is correct". ulex never sends a command to your endpoint

#Adversaries

#AdversaryCapabilityPrimary assets
T1External, unauthenticatedthe internetA5, A8, A9
T2Credential holder — a leaked API key or refresh tokenone key or tokenA3, A4, A6
T3Malicious tenant — a customer acting as themselvesfull control of their own orgA4 (their users only)
T4Malicious IdP — a customer's Okta is compromisedsigns assertions for their orgA4 (their users)
T5Supply chain — a dependency, an image, a CI actioncode execution in the buildA1, A2
T6Insider — an employee with production accessread or change the data planeA1, A2, A4, A5
T7SSRF against the webhook — a config that points at the metadata servicemakes ulex fetch an internal URLA1, A2
T8Agent-driven automation — a well-meaning agent with ulex:admineverything an agent can reachall

T8 is the one that is new. An agent is not an adversary, but it is an amplifier: it can make 600 mistakes a minute, it holds long-lived credentials, and it operates without a human in the loop. The controls are scoped keys, retryable-driven backoff, idempotency keys, and the audit log's actor_type: "agent".

#Abuse cases and mitigations

#AC1 — Brute force on the token endpoint

AttackerT1
Actionsubmit 10^6 authorization codes or refresh tokens
AssetsA4, A6
Mitigation30 requests/minute/client on /oauth2/token; authorization codes expire in 60 s and are single-use; refresh-token families die on reuse; scrypt on API keys; no password grant exists, so there is no password to brute-force
Residuala distributed attacker can still make 30/minute/client across many clients. Bounded by failOnErrors-style alerting on authentication.failed

#AC2 — Stolen refresh token

AttackerT2
Actionreplay a stolen refresh token
AssetsA6
Mitigationrefresh tokens rotate on every use; a replay revokes the whole family, so both the attacker and the victim are logged out; the reuse is outcome: denied in the audit log
Detectionauthentication.session_revoked with metadata.family_revoked: true
Residualthe attacker wins the first race if they use the token before the legitimate client. Window is the refresh interval

#AC3 — Forged SAML assertion

AttackerT4, or T1 replaying a captured assertion
AssetsA4
Mitigationsignature verified against the connection's certificate with an enforced algorithm and digest; Destination must equal the ACS URL; InResponseTo must match an outstanding request; Issuer must match; Conditions window against allowed_clock_skew_seconds; Assertion/@ID is consumed once; acs_allowed_urls limits which endpoints may be posted to; DTDs and external entities disabled
Residuala genuinely compromised customer IdP can sign assertions for its own org. ulex verifies the IdP is who it says it is; it cannot verify the IdP is honest

#AC4 — Assertion replay

AttackerT1 with a captured response
ActionPOST the same SAMLResponse twice
MitigationAssertion/@ID is registered on consumption; a second post is 400 saml_replay_detected
Residuala legitimate IdP retry after a lost response also gets rejected. The session from the first attempt exists; the retry is redundant

#AC5 — XML external entity

AttackerT1
AssetsA1, A2, A4
MitigationDTD processing disabled, external entity resolution disabled, entity-expansion limits. ulex is not vulnerable to XXE and does not parse untrusted XML anywhere else
Residualnone known

#AC6 — SSRF via a webhook URL

AttackerT1, or T8
AssetsA1, A2
Mitigationhttps:// only (loopback http:// permitted for development); DNS-resolved at create time and at every delivery, so a record that changes to 169.254.169.254 is rejected at send time; loopback, link-local, RFC 1918 and cloud-metadata ranges blocked; redirects are not followed; the data plane Lambda has no route to the internet; IMDS hop limit 1
Residuala public host that ulex can reach and the attacker controls can proxy inward. That is a host you chose

#AC7 — Open redirect through the authorization endpoint

AttackerT1
Actioncraft an authorize URL with an unregistered redirect_uri and a code
AssetsA6
Mitigationredirect_uri must be an exact member of the application's redirect_uris; when it does not validate, the error is rendered, not redirected; state is required for an error redirect; the iss parameter is returned so the client can detect a mix-up
Residualnone known

#AC8 — Cross-tenant access

AttackerT2, T3
AssetsA4, A5
Mitigationevery read is filtered by tenant_id in the query, not in application code; another tenant's resource returns 404, not 403, so ids are not enumerable; there is no API surface that crosses tenants without ulex:admin, and that path is audited as category: authorization
Residualan ulex:admin key can cross tenants by design

#AC9 — Escalation through the scope model

AttackerT2 with a scoped key
Actioncall an operation outside the key's scopes
AssetsA3, A4
Mitigationscope is checked before the handler; insufficient_scope names the missing scope; admin-only scopes cannot be minted without admin; application_id on a key binds it to one client
Residuala key with ulex:admin is total. There is no partial-admin tier. That is a deliberate simplicity

#AC10 — Key rotation breaks consumers

Attackernobody; this is availability
AssetsA1 (usability)
Mitigationoverlapping rotation with a configurable grace; the JWKS carries both keys for the whole window; ulex never rotates a CMK without a maintenance window; a kid-keyed JWKS cache is documented and required
Residuala consumer with a 24-hour JWKS cache and a 1-hour grace will break. The grace must exceed twice the longest cache, and the API will not let you set a grace shorter than 300 seconds

#AC11 — Signing key compromise

AttackerT5, T6
AssetsA1
Mitigationprivate material is envelope-encrypted with the tenant data key; KMS is the only holder; ScheduleKeyDeletion is break-glass with a 30-day waiting period; a compromise is detected by authentication.succeeded volume anomalies and by CI key detection
Residualrotation stops future issuance; tokens already signed stay valid until exp

#AC12 — Audit log tampering

AttackerT5, T6, T1 with a bug
AssetsA5
Mitigationno update or delete path exists for an audit event, by any scope; appends are conditional on the current head, so two writers cannot both take it; entry_hash = sha256(previous_hash : id : action : timestamp : canonical_json(metadata)), so altering any field breaks every link after it; the chain's order is derived from its own links rather than from a sequence number, which cannot order two entries written in the same second; archives go to S3 with object-lock governance; GET /audit-events/export lets a third party verify the chain independently
Residualan attacker with the KMS CMK and write access to the table could rewrite history. That is T6 with two of three controls defeated

#AC13 — ulex modifies the audit log to cover its tracks

AttackerT5, T6
AssetsA5
Mitigationthe log is append-only at the application layer and CloudTrail-logged at the infrastructure layer; the DynamoDB table policy for the API role grants PutItem on audit items and not UpdateItem or DeleteItem; the guardrail is a policy, not a code path
Residualan actor with dynamodb:UpdateItem on the table, which is a separate, alerted grant

#AC14 — Agent runs away

AttackerT8, or an agent with a bad prompt
AssetsA3, A4
Mitigationscoped keys, never ulex:admin for a working agent; per-IP rate buckets and API Gateway throttling; idempotency keys make a retried create safe rather than duplicating; actor_type: "agent" on every action; the audit log's mcp.tool_invoked sampling shows the shape
Residualan agent with mcp:admin can delete a tenant. That is why mcp:admin is a separate scope from mcp:tools

#AC15 — Webhook receiver spoofing

AttackerT1
Assetsyour pipeline's integrity
MitigationHMAC-SHA256 over <timestamp>.<rawBody>; timestamp freshness of 300 seconds; the docs show timingSafeEqual, not ===
Residualthe consumer's implementation. ulex signs; it cannot force the consumer to verify

#AC16 — Password guessing through SCIM

AttackerT1
AssetsA4
MitigationSCIM rate limit is 3,000/minute on a token an attacker must already hold; POST /scim/v2/Users does not accept a password; SCIM is not an authentication path at all
Residualwith a valid SCIM token, an attacker can enumerate users with filter=userName eq "…"

#AC17 — Domain verification spoofing

AttackerT1, or a tenant with allow_profiles_outside_organization: true
AssetsA4
Mitigationa TXT record at _ulex-challenge.<domain> with a 128-bit token; by default on https://ulexid.com the check performs a real DNS lookup; the local in-memory server or a non-HIPAA tenant that explicitly sets allow_mocks: true resolves immediately for synthetic testing
ResidualDNS hijacking of the TXT record. That is a 30-day TTL problem you own

#AC18 — Customer impersonates another customer

AttackerT3
AssetsA4 (another tenant's users)
Mitigationallowed_domains restricts which emails a connection will authenticate; a JWT's org_id is set by the authorization, not by the request. sso_only: true confines authentication to the organization's enterprise connections (refusing direct password sign-in), and allow_profiles_outside_organization: false prevents emails outside verified domains from joining the organization
Residualan org with allow_profiles_outside_organization: true and no allowed_domains on its connection accepts any valid identity in the tenant

#AC19 — Replay or spoofing of PAR requests, client assertions, and IdP-initiated SAML

AttackerT1, T2
AssetsA1, A2, A4
MitigationPAR request_uri values from POST /oauth2/par are single-use and strictly bound to the registering client_id (invalid_request_uri on mismatch or replay). private_key_jwt assertions are verified against inline jwks or an SSRF-checked jwks_uri (urlSafety.assertSafe), and jti uniqueness is claimed atomically via claimAssertionJti. IdP-initiated SAML (GET /saml/idp/init/{appId}) returns 403 by default unless an administrator opts in via saml_allow_idp_initiated: true
Residualwhen an admin enables saml_allow_idp_initiated: true for legacy SP compatibility, unsolicited logins carry classic IdP-initiated SAML CSRF risk unless the SP validates relay state

#AC20 — Stolen access or refresh token replay

AttackerT1, T2
AssetsA4, A6
MitigationApplications enabling dpop_bound_access_tokens require RFC 9449 asymmetric DPoP proofs across /oauth2/token (all grants including refresh rotation) and /oauth2/userinfo (Authorization: DPoP with ath binding, htm/htu validation, and atomic single-use jti enforcement; Bearer is rejected). Applications enabling tls_client_certificate_bound_access_tokens (and tls_client_auth / self_signed_tls_client_auth clients) bind access tokens to cnf["x5t#S256"] per RFC 8705. Certificate-based x509_client_cert logins verify full CA chains and client-auth EKU at /connections/{id}/x509/authenticate
Residualbearer tokens for clients that do not opt into dpop_bound_access_tokens or tls_client_certificate_bound_access_tokens remain usable until exp

#What is deliberately not defended

Being explicit about this is more useful than implying coverage.

Not defendedWhyWhat to do instead
Your application's authorizationulex authenticates and issues claims (org_id, acr, roles, permissions). It does not know your resourcesenforce on your side, using org_id, acr, roles, permissions, and the membership role
A compromised customer's IdPulex verifies the signature, not the IdP's honestytreat a customer's IdP as a trust boundary; alert on sudden authentication.succeeded volume from one connection
Your webhook receiver's logiculex signs the event; it cannot force you to verify itimplement verification, and treat a signature as "from ulex", not "correct"
Endpoints on your own infrastructureulex will not reach 127.0.0.1, link-local, or RFC 1918expose your receiver publicly with TLS, or terminate in a VPC endpoint
Physical access to the KMSAWS's problem, and a documented onerely on the HSM, and on the policy that nobody can ScheduleKeyDeletion
A supply-chain compromise of a transitive dependencypartially: SBOM, Trivy, signed imagespin with a lockfile, scan, and review the SBOM
Denial of service at volumeIn-app per-IP token buckets (600/min general, 60/min token endpoint) + API Gateway stage throttling + Shield Standard absorb abuse with no fixed-cost WAFback off on 429 with Retry-After; contact support for a higher limit
Metadata leaks about your tenantulex tells you your own tenant's configuration, including existencethat is the product
A JWT decoded instead of verifieda client-library mistake, not ulex'sjose, openid-client; see claim reference

#Residual risk, accepted

RiskWhy acceptedMitigation
Refresh-token theft wins the first race30-day lifetimes are a product decisionrotate on suspicion; bind_to_user_agent; short access-token lifetimes
A suspended user's access token is valid until expstateless JWTs cannot be revoked individuallyintrospect for high-risk operations; keep expires_in short; POST /oauth2/revoke per token
metadata is free-formflexibility beats a rigid schemascrubbed on write; CI greps for PII in test fixtures; reviewed on every PR
allow_mocks: true and local in-memory mode verify domains instantlyan agent running synthetic tests must not need DNSdisabled by default on https://ulexid.com, forbidden when hipaa_enabled: true, and audited whenever enabled
The hosted UI supports tenant brandingCSS / URL injection on customization fieldsapplication.branding (logo_url, primary_color, favicon_url) is validated (CSS color syntax and https://-safe URLs, rejecting javascript:/data: schemes) and escaped when rendered in the hosted portal

#How this document is kept honest

  1. Every mitigation above maps to a test in packages/core or a control in the compliance matrix.
  2. Every accepted residual risk was accepted by a named owner, with a review date.
  3. A change that removes a mitigation is a change to this document, reviewed like code.
  4. The threat model is revisited on every SOC 2 evidence cycle and after every SEV-1.

#Reference