Fix SLO sending stale transient NameID when SP re-authenticates within same IdP session#984
Open
Fix SLO sending stale transient NameID when SP re-authenticates within same IdP session#984
Conversation
…tes in same IdP session Agent-Logs-Url: https://github.com/OpenIdentityPlatform/OpenAM/sessions/9cf5d8fe-55a0-436f-99d6-674c58e05b0e Co-authored-by: vharseko <6818498+vharseko@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix stale NameID issue during SLO
Fix SLO sending stale transient NameID when SP re-authenticates within same IdP session
Apr 9, 2026
maximthomas
approved these changes
Apr 9, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When an SP completes ACS more than once within the same IdP session (e.g. SP local session timeout while IdP session remains active), the
nameIDandSPpairscache inIDPSessionretained the original NameID. SLO then sent aLogoutRequestwith that stale NameID, causing a mismatch on the SP side.Change
IDPSSOUtil.getAssertion()— replace the existingNameIDandSPpairfor a given SP instead of silently skipping the update:This ensures SLO always uses the NameID that was last issued to the SP, keeping the IdP cache in sync with the SP's active session.
Original prompt
Bug Description
When the same SP completes ACS (Assertion Consumer Service) multiple times within the same IdP session (e.g., because the SP's local session timed out but the IdP session is still alive), the IdP sends a
LogoutRequestduring SLO with a stale/earlier transient NameID instead of the most recent one. This causes SLO to fail on the SP side because the NameID in theLogoutRequestdoesn't match the SP's current session.Root Cause
The bug is in
IDPSSOUtil.javain thegetAssertion()method, around lines 1025–1043. When registering the(NameID, SPEntityID)pair in the IDP session cache for later SLO use, the code checks if a pair for the SP already exists. Iffound == true, the existing pair is not updated with the new NameID — it is simply skipped:When a second ACS happens for the same SP (with a new transient NameID), the old NameID remains in the cache. Later, during SLO, the IdP retrieves this stale NameID from the
nameIDandSPpairslist and sends it in theLogoutRequest, causing a mismatch on the SP side.Required Fix
In
openam-federation/openam-federation-library/src/main/java/com/sun/identity/saml2/profile/IDPSSOUtil.java, change the logic so that when an existingNameIDandSPpairis found for the same SP entity ID, the pair is updated/replaced with the new NameID rather than being skipped.The fix should change the block around lines 1025-1043 from:
to something like:
This ensures that when a repeated ACS occurs for the same SP within the same IdP session, the NameID stored in the IDP session cache is always updated to match the latest assertion sent to the SP. This way, SLO will use the correct (most recent) NameID.
References
openam-federation/openam-federation-library/src/main/java/com/sun/identity/saml2/profile/IDPSSOUtil.javaThe following is the prior conversation context from the user's chat exploration (may be truncated):
User: проанализируй
Assistant:
I'll analyze this issue by investigating how OpenAM handles SAML SLO NameID storage when the same SP completes ACS multiple times within the same IdP session.
Assistant: Now let me look at the critical code — how NameID+SP pairs are added to the IDP session, particularly in the
sendResponseToACSflow:Assistant: Now I have a thorough understanding of the code. Let me also look at the
DefaultIDPAccountMapper.getNameID()method more closely to understand the transient NameID lookup:Assistant: Now let me look at the key method
sendResponseToACSinIDPSSOUtil.javato see how NameID is stored in thenameIDandSPpairslist:Assistant: Now I can see the critical piece. Let me get the full context of this code to see exactly what happens when the SP already exists in the list.
Assistant: ## Анализ проблемы: SLO использует устаревший transient NameID при повторном ACS к тому же SP
После анализа исходного кода OpenAM, я могу подтвердить, что описанное поведение является багом в текущей реализации. Вот детальный разбор корневой причины.
Корневая причина
Проблема находится в файле
IDPSSOUtil.java, в логике, которая регистрирует пару(NameID, SPEntityID)в кэше IDP-сессии при каждом SSO-ответе: