8000 8000 Close limited SOAP request streams in SAML endpoints by ahus1 · Pull Request #55171 · keycloak/keycloak · GitHub
[go: up one dir, main page]

Skip to content

Close limited SOAP request streams in SAML endpoints - #55171

Merged
ahus1 merged 2 commits into
keycloak:mainfrom
ahus1:is-55169-close-saml-soap-streams
Nov 13, 2026
Merged

ahus1 merged 2 commits into
keycloak:mainfrom
ahus1:is-55169-close-saml-soap-streams

Conversation

@ahus1
@ahus1 ahus1 commented Nov 13, 2026 •
Copy link
Copy Markdown
Member

Closes #55169

Decisions and assumptions:

  • The limited stream is closed with try-with-resources instead of adding Checker Framework annotations such as @MustCallAlias, to keep annotations to a minimum and to not rely on the container closing the request stream.
  • In the ECP service, only the extraction is inside the try, so a failure on close() can't turn an already built response into a SOAP fault.
  • Tentatively a backport candidate for 26.8 to keep the code aligned; 26.8 has the same limit(...) call sites but no Checker Framework setup.
  • Double-closing and limiting of the stream removed as suggested by Copilot in the review (see second commit)

Closes keycloak#55169

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Signed-off-by: Alexander Schwartz <alexander.schwartz@ibm.com>
@ahus1
ahus1 force-pushed the is-55169-close-saml-soap-streams branch from eb44a7e to da4bbf8 Compare November 13, 2026 16:38
@ahus1
ahus1 requested a balanced review from Copilot November 13, 2026 16:45
Copilot AI left a comment
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

< 8000 /div>

🟡 Changes recommended

The outer resource block in SamlService closes the same stream already closed by authenticate(InputStream), duplicating stream ownership and close-error handling around response processing.

1 open issue
What changed in this PR

This PR addresses the Checker Framework resource-leak errors reported in #55169 by explicitly closing limited SOAP request streams in Keycloak’s SAML endpoints.

Changes:

  • Adds try-with-resources and SOAP fault handling for stream-close failures.
  • Separates ECP message extraction and stream closure from document authentication.
File Description
services/​src/​main/​java/​org/​keycloak/​protocol/​saml/​SamlService.java Adds stream closure around artifact resolution parsing and ECP delegation.
services/​src/​main/​java/​org/​keycloak/​protocol/​saml/​profile/​ecp/​SamlEcpProfileService.java Closes the limited stream after extraction, before authenticating the document.

Review effort: Balanced

Simplified SOAP binding by removing input stream limitation and error handling.

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Alexander Schwartz <alexander.schwartz@gmx.net>
Copilot AI left a comment
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

There are no active review issues for the SOAP request-stream cleanup change.

No open issues 🎉

1 resolved since last review

Review effort: Balanced

@ahus1
ahus1 marked this pull request as ready for review November 13, 2026 17:20
@ahus1
ahus1 requested a review from a team as a code owner November 13, 2026 17:20
@ahus1
ahus1 enabled auto-merge (squash) November 13, 2026 17:21
@ahus1
ahus1 merged commit c2b342f into keycloak:main Nov 13, 2026
97 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SAST Check fails with required.method.not.called in SAML SOAP endpoints on main

3 participants

0