opyeb samlview

samlview · Validation

NotBefore, NotOnOrAfter and clock skew

NotBefore, NotOnOrAfter, SubjectConfirmationData, SessionNotOnOrAfter, clock skew

A SAML assertion carries validity in several layers. A log may only say 'login failed' while the real cause is a NotOnOrAfter one minute past, or a server clock thirty seconds ahead. Knowing the order in which to read the time conditions speeds up the diagnosis.

Four time conditions

ElementMeaningHow it is judged
Conditions/@NotBeforenot valid before this instantreference + skew < NotBefore means fail
Conditions/@NotOnOrAfterexpired from this instantreference - skew ≥ NotOnOrAfter means fail
SubjectConfirmationData/@NotOnOrAfterexpiry of the confirmation datausually a window of a few minutes
AuthnStatement/@SessionNotOnOrAftersession expirypast it means re-authentication (warning)

The same name, NotOnOrAfter, means different things by position. Conditions bounds the whole assertion; SubjectConfirmationData bounds the bearer confirmation.

Boundary comparison

SAML 2.0 Core treats an assertion as valid at or after NotBefore and valid before NotOnOrAfter. So the instant equal to NotOnOrAfter is already expired. Swapping > for >= in code flips a verdict on a one-second difference.

Where clock skew comes from

The IdP, the SP, proxies and containers each carry their own clock. NTP drift produces tens of seconds, and a virtual machine waking from sleep can lag minutes. SP implementations therefore allow a skew of one to five minutes. A judging tool set to zero skew will call a response failed that the real SP would accept.

Example: NotOnOrAfter = 12:00:00Z, skew = 3 min → treated as valid until 12:03:00Z

Replaying a log

  1. Set the reference time to the moment of failure.
  2. Set the skew the production service uses (for example three minutes).
  3. Read the Conditions and SubjectConfirmationData results separately.
  4. If session expiry is the cause, look at SessionNotOnOrAfter on its own.

samlview uses the current time when the reference field is empty, and recalculates every time judgement when you enter one. Each result shows the instant it was compared against.

Frequently asked questions

Is the instant equal to NotOnOrAfter valid?

No. In SAML 2.0 Core the assertion is no longer valid at NotOnOrAfter, so the comparison must be 'less than'.

How much skew is reasonable?

It depends on policy, but one to five minutes is common. Too large a value risks accepting an expired assertion.

How is session expiry different from assertion expiry?

Assertion expiry means the response can no longer be trusted; session expiry says when to end the login session. The first is a validation failure, the second a re-authentication trigger.

Load the expired sample and move the reference time to watch the verdict flip.

Open the tool

This article follows OASIS SAML 2.0 Core (2005), SAML 2.0 Bindings, SAML 2.0 Profiles, XML Signature 1.1 and RFC 1951 (DEFLATE). Every example is synthetic data.