Incident response
How ulex behaves during an incident and what you should do about it: severity definitions, the first five minutes, credential compromise, a leaked signing key, a stuck webhook, a broken directory, replay detection, and post-incident evidence.
#What ulex does during an incident
| Behaviour | Rationale |
|---|---|
| Never loses an audit event silently. The hash chain is append-only, and a write that fails to claim the head is not recorded as though it succeeded. | The log is evidence. A gap that nothing reports is indistinguishable from tampering — and a gap that is reported must not be misread as tampering either, which is why verification names which kind of failure it found. |
Never silently drops a webhook. Failed deliveries are retried 8 times and then retained as dead_lettered for 30 days. | A dropped event is a user who exists in your IdP and not in your app. |
| Never falls back to a weaker algorithm or a shorter token life. | A degraded posture is worse than a failed request. |
| Refuses rather than guesses. An unverifiable SAML assertion is rejected, not accepted "to keep the user moving". | |
| Degrades directory sync before inbound SCIM. | Inbound SCIM is customer-initiated and visible; scheduled polls are not. |
| Keeps serving reads during a degraded state. | You need the audit log most when things are broken. |
#Severity
| Level | Definition | Response |
|---|---|---|
| SEV-1 | prod unavailable, or a credential or signing key is suspected compromised | page immediately, 24/7 |
| SEV-2 | a customer's directory or SSO is broken; authentication failure rate > 5% for one tenant; webhook endpoint auto-disabled | page during business hours |
| SEV-3 | a single non-critical function is degraded; a deployment is stuck; sync is partial | ticket, same business day |
| SEV-4 | a certificate expires within 30 days | ticket, this week |
#The first five minutes
curl -sS https://ulexid.com/api/v1/status | jq '{status, degradations}'# Is it everyone, or one tenant, or one connection?
curl -sS -G "$BASE/audit-events" -H "$AUTH" \
--data-urlencode 'action_prefix=authentication.' \
--data-urlencode 'outcome=failure' \
--data-urlencode 'since='"$(date -u -d '5 minutes ago' +%Y-%m-%dT%H:%M:%S.000Z)" \
--data-urlencode 'limit=200' | jq -r '.data | group_by(.connection_id) | map({connection: .[0].connection_id, n: length}) | sort_by(-.n)'{"connection":"con_01M3PSVY108K5TEHHQ82WN30YK","n":187}
{"connection":"con_01M3PSVAG0QFJG99R0M5DXSR5A","n":3}One connection with 187 failures and another with 3: this is one customer's IdP, not ulex. Scope the page accordingly.
{ "name": "ulex_explain_error", "arguments": { "code": "saml_signature_invalid" } }{
"code": "saml_signature_invalid",
"type": "invalid_request_error",
"http_status": 400,
"retryable": false,
"causes": [
"The IdP is signing with a different certificate than the one on the connection.",
"The certificate was rotated upstream and ulex still has the old one.",
"The assertion is signed with a weak algorithm the connection does not allow."
],
"fixes": [
"Download the current signing certificate from the IdP and PATCH /connections/{id} with config.saml.x509_certificate.",
"Call POST /connections/{id}/verify to re-validate before retrying.",
"Confirm signature_validation is 'strict' and signature_algorithm matches the IdP."
],
"docs_url": "https://docs.ulexid.com/troubleshooting/saml-issues"
}curl -sS "$BASE/environments/prod/health" -H "$AUTH" | jq '.checks[] | select(.status != "pass")'A restart costs you the in-memory auth_attempt correlation and the webhook retry schedule. If the answer is a configuration change, a restart makes it worse and slower.
#Credential compromise
#An API key leaked
Revoke first, investigate second. A leaked key is live until it is not, and revocation is immediate and total.
# 1. List, find the key
curl -sS "$BASE/tenants/current/api-keys" -H "$ADMIN" | jq '.data[] | {id, name, prefix, last_used_at, last_used_ip_hash, created_at}'
# 2. Revoke it. There is no grace period, by design.
curl -sS -X DELETE "$BASE/tenants/current/api-keys/key_01M3PSVJA0YP2WDPM2RDR15MGH" -H "$ADMIN"
# 3. See what it did, from the audit log, while it was live
curl -sS -G "$BASE/audit-events" -H "$ADMIN" \
--data-urlencode 'actor_type=api_key' \
--data-urlencode 'since='"$(date -u -d '30 days ago' +%Y-%m-%dT%H:%M:%S.000Z)" \
--data-urlencode 'limit=200' | jq -r '.data[] | select(.actor_id=="key_01M3PSVJA0YP2WDPM2RDR15MGH") | "\(.timestamp) \(.action) \(.outcome) \(.target.id) \(.ip_hash)"'
# 4. Mint a replacement with the narrowest scope
curl -sS -X POST "$BASE/tenants/current/api-keys" -H "$ADMIN" -H "$JSON" \
-d '{"name":"agent-bootstrap-2","scope":["mcp:tools","read:organizations","write:organizations","read:users","write:users"],"expires_in_days":90}'last_used_ip_hash is a salted SHA-256 and cannot be reversed, but you can compare hashes: if every last_used_at on your log lines matches that hash, the key was used only from your infrastructure.
What to look for in the audit log for a leaked key:
| Action | Means |
|---|---|
api_key.created, api_key.revoked | someone managing keys. Treat as escalation |
mcp.tool_invoked | an agent using it. Normal if you have agents |
impersonation.started | SEV-1. The key was used to log in as a user |
connection.updated, application.updated | configuration tampering |
deployment.started | not a data breach, but why |
audit_events read with a wide window | reconnaissance |
impersonation.started on a key you did not use to test means someone is authenticating as your users. Revoke the key, then revoke every session on the affected tenants with ulex_reset_simulation, then read GET /audit-events?action_prefix=impersonation. for the full list of who was impersonated.
#A client secret leaked
curl -sS -X POST "$BASE/applications/$APP_ID/rotate-secret" -H "$ADMIN" -H "$JSON" -d '{"grace_period_seconds":3600}'{
"client_id": "client_01M3PSV7J8TBSPHG95CYSEX32B",
"client_secret": "cs_Tn4Wv8Kp2LmQ6Rb9Yc3Xd7Fs1Hg0Ja5E",
"previous_secret_expires_at": "2026-09-29T16:30:00.000Z",
"grace_period_seconds": 3600
}One hour is the shortest sensible grace during an incident. Long enough to redeploy, short enough that the exposure window is bounded. Roll back to a longer window later if you need a zero-downtime rotation.
#A signing key compromised
curl -sS -X POST "$BASE/tenants/current/rotate-signing-keys" -H "$ADMIN" -H "$JSON" \
-d '{"purpose":"access_token","grace_period_seconds":900}'With a 15-minute grace, every consumer re-fetches the JWKS at least once inside the window. With 0, every request signed by the old key fails immediately. If the key is compromised, use a short grace and accept the churn. 900 seconds is the minimum that still lets a 15-minute JWKS cache refresh.
Then check whether it was used:
curl -sS -G "$BASE/audit-events" -H "$ADMIN" \
--data-urlencode 'category=authentication' \
--data-urlencode 'since='"$(date -u -d '7 days ago' +%Y-%m-%dT%H:%M:%S.000Z)" \
--data-urlencode 'limit=200' | jq '[.data[] | select(.outcome=="success")] | length'Any token you did not issue is a token you must assume was accepted by someone else's resource server. Your rotation stops ulex from issuing more; it cannot un-issue the ones already out there.
#A SCIM token leaked
curl -sS -X PATCH "$BASE/directories/$DIR_ID" -H "$ADMIN" -H "$JSON" \
-d "{\"scim_token\": \"env:ULEX_SCIM_TOKEN_$(date +%s)\"}"
curl -sS -X PATCH "$BASE/directories/$DIR_ID" -H "$ADMIN" -H "$JSON" \
-d '{"inbound_scim_enabled": true}'Reissue, then update the customer's IdP. The old token dies immediately; the customer's next poll fails until they update.
#A webhook endpoint went dark
curl -sS "$BASE/webhooks/$WHK_ID" -H "$AUTH" | jq '{status, failure_count, disabled_at, disabled_reason, last_delivery_status}'
curl -sS -G "$BASE/webhooks/$WHK_ID/deliveries?status=dead_lettered" -H "$AUTH" | jq '.data | length'{ "status": "disabled", "failure_count": 8, "disabled_at": "2026-09-29T16:30:00.000Z", "disabled_reason": "8 consecutive delivery failures" }Fix the receiver, test it, then re-enable:
curl -sS -X POST "$BASE/webhooks/$WHK_ID/test" -H "$AUTH" -H "$JSON" -d '{"event":"user.created"}'
# confirm the delivery says "delivered", then:
curl -sS -X POST "$BASE/webhooks/$WHK_ID/enable" -H "$AUTH"Then reconcile. Events raised while disabled are not replayed:
# Which event_ids were lost?
curl -sS -G "$BASE/webhooks/$WHK_ID/deliveries?status=dead_lettered" -H "$AUTH" | jq -r '.data[].event_id' > lost.txt
# Which users were affected? Query the audit log for the window.
curl -sS -G "$BASE/audit-events" -H "$AUTH" \
--data-urlencode 'action_prefix=user.' \
--data-urlencode 'since=2026-09-29T16:30:00.000Z' \
--data-urlencode 'until='"$(date -u -d '2026-09-29 18:30' +%Y-%m-%dT%H:%M:%S.000Z)" \
| jq -r '.data[] | select(.target.type=="user") | .target.id' | sort -u > affected.txt
# Re-fetch current state for each. Do not try to replay the payloads.
while read -r uid; do
curl -sS "$BASE/users/$uid" -H "$AUTH" | jq -c '{id, email, status}'
done < affected.txt#A directory went stale
curl -sS -G "$BASE/directories/$DIR_ID/syncs?limit=5" -H "$AUTH" | jq '.data[] | {state, trigger, error, stats, finished_at}'error | Cause | Action |
|---|---|---|
401 from upstream | the SCIM token expired or was rotated | reissue with PATCH /directories/{id} and update the customer |
403 | the token lost a scope | reissue with scim:provision |
400 invalidFilter | user_filter is not valid SCIM filtering | test it against {scim_base_url}/Users?filter=… yourself |
429 from upstream | polling too fast | raise scim_poll_interval_seconds |
timeout | the upstream is slow or large | narrow user_filter |
null with state: partial | individual records failed | stats.users_failed is non-zero; the users exist upstream and not here |
curl -sS -X POST "$BASE/directories/$DIR_ID/sync" -H "$AUTH"Then poll. And tell the customer: a directory that is silently stale is worse than one that is visibly failing.
#Replay detection
ulex rejects a replayed authorization code, a replayed refresh token, and a replayed SAML assertion. Each produces a distinct signal.
| Signal | error_code | outcome | What it means |
|---|---|---|---|
| Authorization code replay | invalid_grant | failure | probably a client bug: a double submit, or a retried exchange |
| Refresh token reuse | invalid_grant, family_revoked | denied | the token was stolen. The whole family is already revoked |
| SAML assertion replay | saml_replay_detected | failure | the IdP retried after a lost response, or someone replayed a captured assertion |
curl -sS -G "$BASE/audit-events" -H "$ADMIN" \
--data-urlencode 'action=authentication.session_revoked' \
--data-urlencode 'since='"$(date -u -d '1 hour ago' +%Y-%m-%dT%H:%M:%S.000Z)" \
| jq '.data | length'A family_revoked event is a security event, not a bug. The user is logged out and must re-authenticate. If they did not, someone else has the refresh token.
#Mass revocation
# One user, everywhere
curl -sS -X POST "$BASE/users/$UID/suspend" -H "$ADMIN" -H "$JSON" -d '{"reason":"incident 2026-09-29"}'
# One organization's sessions only
curl -sS "$BASE/organizations/$ORG_ID/members?limit=200" -H "$ADMIN" | jq -r '.data[].user_id' \
| while read -r uid; do
curl -sS -X POST "$BASE/users/$uid/suspend" -H "$ADMIN" -H "$JSON" -d '{"reason":"incident"}' >/dev/null
done
# A whole tenant
ulex_reset_tenant --confirm --keep-api-keysA suspended user's access tokens remain cryptographically valid until exp (up to 3,600 s). Suspension revokes sessions and refresh-token families, and makes introspection return active: false. If you need immediate expiry, revoke the tokens explicitly.
#Post-incident
# 1. The window
SINCE="2026-09-29T15:00:00.000Z"; UNTIL="2026-09-29T17:00:00.000Z"
# 2. Everything that happened, in order
curl -sS -G "$BASE/audit-events/export" -H "$ADMIN" -H "Accept: application/x-ndjson" \
--data-urlencode 'format=ndjson' --data-urlencode "since=$SINCE" --data-urlencode "until=$UNTIL" \
-o evidence.ndjson
# 3. Verify the chain is intact
node -e '
const fs = require("fs");
const rows = fs.readFileSync("evidence.ndjson", "utf8").trim().split("\n").map(JSON.parse);
// Order by the links: the export order is the store sort order, which for two
// entries in the same second is not the order they were committed in.
const byHash = new Map(rows.map((r) => [r.entry_hash, r]));
const linkedTo = new Set(rows.map((r) => r.previous_hash).filter(Boolean));
const reachable = new Set();
for (const tip of rows.filter((r) => !linkedTo.has(r.entry_hash))) {
let cur = tip;
while (cur && !reachable.has(cur.entry_hash)) {
reachable.add(cur.entry_hash);
cur = cur.previous_hash ? byHash.get(cur.previous_hash) : undefined;
}
}
const orphan = rows.find((r) => !reachable.has(r.entry_hash));
let backwards = null;
for (const r of rows) {
const prev = r.previous_hash ? byHash.get(r.previous_hash) : null;
if (prev && prev.timestamp > r.timestamp) { backwards = r.id; break; }
}
console.log(`${rows.length} events, chain ${orphan || backwards ? "BROKEN at " + (orphan ?? backwards).id : "INTACT"}`);
'8471 events, chain INTACTA broken chain is a SEV-1 only if it broke because an entry's contents no longer hash to the value recorded on it. That is hash_mismatch, and it means somebody altered the log, so everything else in your post-mortem becomes unreliable.
An entry nothing links to, or a chain running backwards against the clock, is a different finding: ulex wrote the log wrong — a lost write, two appenders racing for the same predecessor, or a clock behind. Neither is evidence of tampering and neither should page a security team. Take them to ulex support with the entry id and the window. See Runbook 14.
#Write-up
Every ulex incident gets:
- the
request_idof the first bad request, and thecorrelation_idof the job - the exact error code, from
ulex_explain_error - a chain verification result over the incident window
- the list of revoked credentials, with ids
- the list of affected users, with ids
- what you would have detected earlier, and the alert that would have done it