Why SAML assertions expire
A SAML assertion is a signed statement that a user signed in. Anyone who holds it while it is valid could try to use it. Short validity windows limit that risk: a copied assertion is worthless a few minutes later.
So every assertion carries time limits, and every app must check them. When the clocks of the identity provider and the app disagree, those checks fail for valid assertions, which is one of the most common SAML errors in production.
The time fields in a response
A response can carry several times. They mean different things, and only some of them are limits.
<samlp:Response IssueInstant="2026-11-25T10:00:00Z" …>
<saml:Assertion IssueInstant="2026-11-25T10:00:00Z" …>
<saml:Subject>
<saml:SubjectConfirmation Method="urn:oasis:names:tc:SAML:2.0:cm:bearer">
<saml:SubjectConfirmationData NotOnOrAfter="2026-11-25T10:05:00Z" …/>
</saml:SubjectConfirmation>
</saml:Subject>
<saml:Conditions NotBefore="2026-11-25T10:00:00Z"
NotOnOrAfter="2026-11-25T10:05:00Z">…</saml:Conditions>
<saml:AuthnStatement AuthnInstant="2026-11-25T10:00:00Z"
SessionNotOnOrAfter="2026-11-25T20:00:00Z">…</saml:AuthnStatement>
</saml:Assertion>
</samlp:Response>| Field | Where | What it limits |
|---|---|---|
IssueInstant | Response and assertion | Nothing directly; when it was made. Apps may refuse very old or future ones. |
NotBefore | Conditions | The assertion is not valid before this time. |
NotOnOrAfter | Conditions | The assertion is not valid at or after this time. |
NotOnOrAfter | SubjectConfirmationData | The time by which the assertion must be delivered to the app. |
AuthnInstant | AuthnStatement | Nothing; when the user actually authenticated. |
SessionNotOnOrAfter | AuthnStatement | How long the app’s own session may last. Not a limit on the assertion. |
Inclusive and exclusive limits
SAML 2.0 core defines the window exactly. NotBefore is inclusive: the assertion is valid from that instant. NotOnOrAfter is exclusive: the assertion is valid only strictly before that instant, as the name says.
All SAML times are xs:dateTime values in UTC, written with a Z and no offset. A time without a zone is ambiguous, and different libraries read it differently. The tool flags such values.
Clock skew
No two servers have exactly the same time. Clock skew is a margin the app adds when it checks the window: it accepts an assertion a little before NotBefore and a little after NotOnOrAfter. A few seconds to a couple of minutes is typical.
Skew is a tolerance, not a fix. If the clocks are minutes apart, a large skew hides the problem and makes stolen assertions usable for longer. Sync both servers with NTP first, then keep the skew small.
Clock skew in Keycloak
When Keycloak is the service provider, brokering sign-in through another SAML identity provider, the identity provider’s settings include Allowed clock skew, in seconds. It applies when Keycloak checks the assertions it receives from that provider.
When Keycloak is the identity provider, the app checks the times, so the skew is the app’s setting. Keycloak stamps its assertions with its host’s clock, so that host needs time sync too.
What this tool does
Paste a response or a bare assertion, as Base64 or XML. The tool reads every time field, compares each limit with the time you choose, and shows which ones pass and which fail, by how much, with the clock skew you set. It works with several assertions in one response.
You can check against now, which updates every second, or against another time, such as the moment an error was logged. A button loads a fresh sample so you can see a passing case.
What it does not do
It does not check the signature, audience or recipient. A valid time window is only one of the checks an app must make. It cannot read the times of an encrypted assertion.
How to use it
- Capture the response: in developer tools, copy the
SAMLResponsevalue from the POST to the app’s ACS URL. - Paste it into the tool.
- Enter the clock skew the app allows, in seconds.
- Pick Now, or pick Another time and enter when the error happened, in your local time.
- Read the verdict and the row that fails.
Diagnosing time errors
Not yet valid right after sign-in
If the app says the assertion is not yet valid, the app’s clock is behind the identity provider’s: from the app’s point of view, NotBefore is still in the future. Check the app server’s time sync.
Expired right after sign-in
If the app says the assertion has expired a moment after the user signed in, the app’s clock is probably ahead. Compare NotOnOrAfter with the time the response arrived. If the window itself is very short, the identity provider’s assertion lifetime may be set too low.
Expired after a delay
If the error appears only sometimes, look for late delivery. The window starts when the identity provider issues the response, after the user has finished signing in. A browser that stays on the auto-submit page, or that resubmits an old form from its history, delivers the assertion late.
Replay errors
Apps store the IDs of assertions they have accepted until NotOnOrAfter passes, and refuse to accept one twice. Pressing back and resubmitting the form, or a proxy retrying the POST, triggers this. It is the app protecting itself, not a time problem.
Best practices
- Sync every server with NTP, including the identity provider, the app and any proxy that checks assertions.
- Keep assertion lifetimes short, a few minutes at most. The app’s own session handles the rest.
- Use a small clock skew, and raise it only after you have fixed the clocks.
- Log the times from the assertion and the server time together when a check fails.
- Use
SessionNotOnOrAfterfor the app session length when the identity provider sends it. - Containers use the host’s clock. Fix time sync on the host or cluster node, not inside the container.
- Virtual machines paused or restored from a snapshot can resume with an old time. Resync the clock after resume.
Security notes
A bearer assertion works for whoever presents it. Time limits, audience checks, recipient checks and one-time use together keep a copied assertion from being useful. Raising the clock skew or the lifetime weakens the first of these, so do it only with a reason.
How an app checks the window
Every SAML library does roughly the same thing when an assertion arrives. Written out, with now as the app’s clock and skew as its allowance:
if Conditions.NotBefore exists and now + skew < NotBefore: reject "not yet valid"
if Conditions.NotOnOrAfter exists and now - skew >= NotOnOrAfter: reject "expired"
for the bearer SubjectConfirmationData:
if now - skew >= NotOnOrAfter: reject "confirmation expired"
if Recipient != this ACS URL: reject
if assertion ID was seen before: reject "replay"The order and wording differ between libraries, and some also refuse assertions whose IssueInstant is far in the past or future. The tool applies the same window checks so you can see which one an app would hit.
What to log when a time check fails
Time errors are hard to debug after the fact unless the logs have the right values. When you control the app, log these together on every rejected assertion:
- The server time at the moment of the check, in UTC.
- The
NotBeforeandNotOnOrAftervalues that were compared. - The clock skew in use.
- The assertion
IDandIssueInstant.
With these, a glance shows whether the server clock was off, the assertion arrived late, or the identity provider issued a very short window. Paste the logged response into this tool with Another time set to the logged server time to reproduce the decision exactly.