
STIR/SHAKEN Verification: Building Caller Trust Into Your App
If your product answers phone calls (a support line, an IVR that resets passwords, a back office that confirms payouts), the caller ID your webhook receives is just a string the network passed along. STIR/SHAKEN verification is the closest thing the phone network has to a signature on that string. This deep dive covers how to use it inside an application: what the signed token contains, whether to trust your carrier's verdict or verify it yourself, how to store and score the result, and how to fail safely when it is missing, which for many international calls is the normal case.
For the business side (red flags, and the controls that stop a phone call from moving money), read our guide on how to protect your business from caller ID spoofing. This post covers the system underneath.
What STIR/SHAKEN verification gives your application
Three IETF documents do the work. RFC 8225 defines PASSporT, a signed JSON Web Token about the parties to a call. RFC 8224 defines how that token travels in the SIP Identity header. RFC 8588 adds the SHAKEN extension, with two extra claims: attest and origid. A decoded token looks like this (structure from RFC 8588; values are placeholders):
// JWT header
{ "alg": "ES256", "typ": "passport", "ppt": "shaken",
"x5u": "https://cert.example.org/passport.cer" }
// JWT payload
{ "attest": "A",
"orig": { "tn": "<calling number>" },
"dest": { "tn": ["<called number>"] },
"iat": "<unix seconds when signed>",
"origid": "<opaque UUID from the originating provider>" }
The attest claim is the one everyone looks at. Per RFC 8588, its values A, B and C mean "Full Attestation", "Partial Attestation" and "Gateway Attestation". In plain terms:
- A: the originating provider knows the customer and has verified that the customer may use that number.
- B: the provider knows the customer but has not verified the number.
- C: the call entered the provider's network from a gateway, such as an international interconnect, and the provider has no relationship with whoever placed it.
Before you design anything, keep one point from Bird's explainer in mind: attestation describes what the signing provider knew about the caller. It is not a score for the call. A fraudster calling from a number legitimately assigned to them can get an A. STIR/SHAKEN tells you the number probably wasn't forged. It does not tell you the person is honest.
Coverage is the other limit. When Twilio announced inbound verification, it noted that the United States was the only country where carriers ran a framework like this. Check the current state for your markets, but expect calls from Mexico, Colombia and much of Latin America to arrive with no token, or with C attestation after crossing an international gateway. Your design has to treat "no data" as the normal case, not an error.
Two architectures: trust the carrier or verify it yourself
Option 1: consume your carrier's verdict
Most teams on a CPaaS take this route. Twilio, for example, adds a StirVerstat parameter to the incoming-call webhook. The parameter appears only when the call carried SHAKEN PASSporT identity headers, and Twilio may also send StirPassportToken with the original token.
- Pros: no cryptography, certificates or trust lists to manage. Works today with a few lines of code.
- Cons: you inherit the carrier's implementation and its vendor-specific value strings, and you cannot re-check anything after the fact unless you also store the raw token.
Option 2: run your own verification service
If you terminate SIP yourself (Asterisk, FreeSWITCH or Kamailio behind a trunk that passes the Identity header through), you can verify the token directly:
verify(identity_header, sip_from, sip_to, now):
token = parse_identity_header(identity_header) # RFC 8224
hdr, payload, sig = jwt_split(token)
require hdr.typ == "passport" and hdr.ppt == "shaken"
require hdr.alg == "ES256" # never trust alg from input blindly
cert = fetch_cert_safely(hdr.x5u) # cached, SSRF-protected
require chain_valid(cert, sti_trust_anchors) # STI-CA roots, kept up to date
require ecdsa_verify(cert.public_key, hdr+payload, sig)
require normalize(payload.orig.tn) == normalize(sip_from)
require normalize(sip_to) in normalize_all(payload.dest.tn)
require abs(now - payload.iat) <= FRESHNESS_WINDOW # your policy, keep it short
return { status: "passed", attest: payload.attest, origid: payload.origid }
- Pros: you decide what "verified" means, you see every failure reason, and you are not tied to one carrier.
- Cons: you own certificate fetching, trust anchor updates, clock sync and a network call on the call-setup path. Each one is a new way to fail.
Option 3: hybrid
Use the carrier's verdict for the real-time decision, store the raw token, and re-verify it asynchronously for audit and fraud investigations. For most products this is the best trade-off: call setup stays fast, and you can still reconstruct exactly what the network asserted.
Data model: store evidence, not a boolean
A column like is_verified BOOLEAN throws away the information you need later. Store each identity signal as an immutable event tied to the call:
CREATE TABLE call_identity_events (
id BIGSERIAL PRIMARY KEY,
call_id TEXT NOT NULL, -- provider call SID / SIP Call-ID
received_at TIMESTAMPTZ NOT NULL DEFAULT now(),
from_number TEXT NOT NULL, -- E.164 as received
to_number TEXT NOT NULL,
source TEXT NOT NULL, -- 'carrier_verstat' | 'self_verified'
verstat_raw TEXT, -- carrier string, unparsed
attest CHAR(1), -- 'A' | 'B' | 'C' | NULL
verify_status TEXT NOT NULL, -- 'passed' | 'failed' | 'absent' | 'error'
failure_reason TEXT, -- 'bad_signature', 'cert_fetch_timeout', ...
passport_raw TEXT, -- original JWT, for re-verification
origid TEXT,
trust_tier TEXT NOT NULL, -- output of your policy at that moment
policy_version TEXT NOT NULL,
UNIQUE (call_id, source)
);
Three details matter here. verstat_raw keeps the vendor string, so a new value never gets silently mapped to the wrong thing. policy_version lets you explain months later why a call was routed the way it was. The UNIQUE constraint makes webhook retries idempotent.
Turning STIR/SHAKEN signals into a trust tier
Map signals to a small number of tiers, and keep that mapping separate from the decisions built on top of it. The value list below follows the format in Twilio's documentation (for example TN-Validation-Passed-A and No-TN-Validation). Check the current table in the docs before you ship.
type Tier = "signed_full" | "signed_partial" | "unsigned" | "failed";
export function tierFromVerstat(verstat?: string): Tier {
if (!verstat) return "unsigned"; // absent is normal, not suspicious by itself
if (verstat === "TN-Validation-Passed-A") return "signed_full";
if (verstat.startsWith("TN-Validation-Passed-")) return "signed_partial";
if (verstat.startsWith("TN-Validation-Failed")) return "failed";
if (verstat === "No-TN-Validation") return "unsigned";
log.warn("unknown_verstat", { verstat }); // new vendor value: alert, don't guess
return "unsigned";
}
The most important rule in the whole design is this: the tier routes the call, it never authorizes an action. A signed_full call can skip a robocall screen or show a softer label to the agent. A failed call can go to a stricter queue. But changing bank details, releasing a payout or resetting credentials must need an out-of-band confirmation in every tier, because an A only says the number wasn't forged.
const HIGH_RISK = new Set(["change_bank_account", "release_payout", "reset_mfa"]);
function gate(action: string, tier: Tier): "allow" | "require_out_of_band" | "deny" {
if (tier === "failed" && HIGH_RISK.has(action)) return "deny";
if (HIGH_RISK.has(action)) return "require_out_of_band"; // callback to number on file,
// in-app approval, or second approver
return "allow";
}
This matters a lot in network marketing companies, where support teams often handle distributor commission payouts and account changes by phone. That gate belongs in the same back office as the payout workflow. It is a control we think about when building a network marketing platform.
Failure handling
- Absent token. Record
verify_status = 'absent'and route normally. Blocking unsigned calls will block many legitimate international callers. - Certificate fetch timeout. Self-verification must have a hard time budget on the call-setup path. If you exceed it, record
errorwith the reason, treat the call asunsigned, and queue an async re-verification frompassport_raw. - Certificate caching. Cache certificates by
x5uURL with a TTL, and cache failures briefly too, so a slow certificate host cannot add delay to every call. - Webhook retries. Key writes on the call ID (the
UNIQUEconstraint above) so a retried webhook doesn't create duplicate evidence or fire downstream actions twice. - Forwarding. When you forward an inbound call, pass through what you received. Twilio documents using the inbound webhook's
CallTokentogether with the original caller's number asFromwhen you create the forwarded call. - Clock skew. Freshness checks on
iatare only as good as your clock. Run NTP and log the skew you see.
Securing the verifier itself
- SSRF via
x5u. The certificate URL comes from the token, so treat it as attacker-controlled. Allow HTTPS only, resolve the host and reject private or link-local addresses, disable redirects, and cap response size and time. - Algorithm pinning. Accept
ES256only. Never let the token's header choose a weaker algorithm ornone. - Webhook authenticity. Validate your provider's request signature before trusting any parameter,
StirVerstatincluded. If you skip this, anyone can send your endpoint a forged "Passed-A". - Honest UI. Don't show agents a green "Verified caller" badge. Show what is true, for example "Number signed by originating carrier (A)", and put the out-of-band step right next to it.
- Retention. Tokens contain phone numbers. Apply the same retention and access rules you use for call records.
If you are designing this into an existing contact center or back office, it is the kind of integration we build as custom software: the work is less about cryptography and more about routing, data and failure modes.
Implementation checklist
- Capture the raw carrier verdict and, where available, the raw PASSporT for every inbound call.
- Store identity signals as immutable, idempotent events with a policy version.
- Map vendor values to a small set of tiers, and alert on unknown values.
- Keep routing (tier-based) separate from authorization (always out-of-band for high-risk actions).
- Treat "absent" as normal, especially for traffic from Latin America.
- If you self-verify: pin ES256, protect
x5ufetches against SSRF, cache certificates, keep trust anchors current, and enforce a time budget. - Validate webhook signatures before reading any parameter.
- Write agent-facing labels that state exactly what was verified and nothing more.
Common mistakes
- Treating attestation A as proof of identity and letting it skip confirmation steps.
- Rejecting or flagging every unsigned call, which mostly punishes legitimate international callers.
- Saving only a boolean, then being unable to explain an incident later.
- Doing certificate fetches synchronously with no timeout, so a remote host's outage becomes your outage.
- Hard-coding vendor strings with an
elsethat defaults to "trusted".
Frequently asked questions
Does STIR/SHAKEN verification stop caller ID spoofing?
It makes spoofing detectable on signed calls that stay on participating networks. It doesn't cover unsigned or many international calls, and it says nothing about intent, so high-risk actions still need out-of-band confirmation.
Should I verify PASSporT tokens myself or trust my carrier?
If you use a CPaaS, trust the carrier's verdict in real time and store the raw token. Self-verification makes sense when you terminate SIP yourself and need full control over failure reasons and trust decisions.
What should my app do when there is no STIR/SHAKEN data?
Record it as absent, route the call normally, and rely on your authorization controls. Missing data is common outside the networks that sign calls, so it shouldn't be treated as a fraud signal by itself.
Comments
No comments yet. Be the first to share what you think.


