Skip to content

saml: Avoid NPE when LogoutRequest has no Issuer - #6908

Open
Gautam-aman wants to merge 2 commits into
line:mainfrom
Gautam-aman:fix/saml-slo-null-issuer
Open

saml: Avoid NPE when LogoutRequest has no Issuer#6908
Gautam-aman wants to merge 2 commits into
line:mainfrom
Gautam-aman:fix/saml-slo-null-issuer

Conversation

@Gautam-aman

Copy link
Copy Markdown
Contributor

Motivation

A LogoutRequest without an Issuer currently results in an internal server error (500)
due to a NullPointerException during request processing.

According to the SAML protocol, a missing Issuer is an invalid request and should be
treated as a client error rather than causing an unexpected server failure.

Modifications

  • Handle a missing Issuer in LogoutRequest validation.
  • Reject the request with InvalidSamlRequestException instead of allowing a
    NullPointerException to propagate.
  • Add a regression test to verify that a LogoutRequest without an Issuer
    returns 400 Bad Request.

Result

Malformed logout requests are now rejected gracefully with 400 Bad Request
instead of returning 500 Internal Server Error.

@coderabbitai

coderabbitai Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: a714c53e-276a-4d81-9e98-8840bbcd05d9

📥 Commits

Reviewing files that changed from the base of the PR and between 8648355 and eae2335.

📒 Files selected for processing (1)
  • saml/src/main/java/com/linecorp/armeria/server/saml/SamlSingleLogoutFunction.java

📝 Walkthrough

Walkthrough

SAML logout validation now rejects requests with a missing issuer. A test verifies that an HTTP-POST logout request without an issuer returns 400 Bad Request.

Changes

SAML logout validation

Layer / File(s) Summary
Logout issuer validation and coverage
saml/src/main/java/com/linecorp/armeria/server/saml/SamlSingleLogoutFunction.java, saml/src/test/java/com/linecorp/armeria/server/saml/SamlServiceProviderTest.java
Validates the issuer before destination and identity-provider checks. Tests that an HTTP-POST logout request without an issuer returns 400 Bad Request.

Estimated code review effort: 2 (Simple) | ~10 minutes

Suggested reviewers: ikhoon, jrhee17, minwoox

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description check ✅ Passed The description clearly explains the issuer validation fix and the regression test for returning 400 Bad Request.
Title check ✅ Passed The title clearly identifies the main change: preventing a NullPointerException when a LogoutRequest has no Issuer.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@mergify

mergify Bot commented Aug 7, 2026

Copy link
Copy Markdown

Tick the box to add this pull request to the merge queue (same as @mergifyio queue).

  • Queue this pull request

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 1

🧹 Nitpick comments (1)
saml/src/test/java/com/linecorp/armeria/server/saml/SamlServiceProviderTest.java (1)

584-597: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Reindent the added method to match the project style.

Lines 584-597 use four spaces for the method body. Neighboring methods use eight spaces for the method body and deeper indentation for continued arguments. Reformat this block and run ./gradlew --parallel build.

As per path instructions, site/src/pages/community/developer-guide.mdx requires code formatted with the LY OSS style.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@saml/src/test/java/com/linecorp/armeria/server/saml/SamlServiceProviderTest.java`
around lines 584 - 597, Reindent the added test method in
SamlServiceProviderTest so its body uses the project’s eight-space indentation
and continued arguments align with neighboring methods. Preserve the existing
logout request, response assertion, and method behavior, then run ./gradlew
--parallel build to verify formatting and compilation.

Source: Path instructions

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In
`@saml/src/test/java/com/linecorp/armeria/server/saml/SamlServiceProviderTest.java`:
- Around line 588-596: Update validateAndGetIdPConfig() to store
logoutRequest.getIssuer() in a local variable and validate it is non-null before
accessing getValue(). Ensure a missing Issuer follows the existing
invalid-request path and returns HTTP 400 instead of throwing
NullPointerException.

---

Nitpick comments:
In
`@saml/src/test/java/com/linecorp/armeria/server/saml/SamlServiceProviderTest.java`:
- Around line 584-597: Reindent the added test method in SamlServiceProviderTest
so its body uses the project’s eight-space indentation and continued arguments
align with neighboring methods. Preserve the existing logout request, response
assertion, and method behavior, then run ./gradlew --parallel build to verify
formatting and compilation.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: e6fe748d-8eeb-43c4-8bf8-5adb1afd5a53

📥 Commits

Reviewing files that changed from the base of the PR and between a63a1a3 and 8648355.

📒 Files selected for processing (1)
  • saml/src/test/java/com/linecorp/armeria/server/saml/SamlServiceProviderTest.java

@Gautam-aman

Copy link
Copy Markdown
Contributor Author

Thanks for the suggestion! I've updated the implementation to check for a missing Issuer before dereferencing it, so malformed logout requests now follow the existing InvalidSamlRequestException path instead of throwing a NullPointerException. I also added a regression test covering this case.

@minwoox minwoox added this to the 1.42.0 milestone Aug 10, 2026
@minwoox minwoox added the defect label Aug 10, 2026

@minwoox minwoox 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.

Thanks!

@codecov

codecov Bot commented Aug 10, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 0.00%. Comparing base (8150425) to head (eae2335).
⚠️ Report is 581 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff              @@
##               main   #6908       +/-   ##
============================================
- Coverage     74.46%       0   -74.47%     
============================================
  Files          1963       0     -1963     
  Lines         82437       0    -82437     
  Branches      10764       0    -10764     
============================================
- Hits          61385       0    -61385     
+ Misses        15918       0    -15918     
+ Partials       5134       0     -5134     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@jrhee17 jrhee17 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.

👍 👍

Comment on lines +584 to +596
final LogoutRequest logoutRequest =
getLogoutRequest("http://" + spHostname + ':' + server.httpPort() + "/saml/slo/post",
"http://idp.example.com/post");

logoutRequest.setIssuer(null);

final AggregatedHttpResponse res =
sendViaHttpPostBindingProtocol("/saml/slo/post",
SAML_REQUEST,
logoutRequest,
idpCredential);

assertThat(res.status()).isEqualTo(HttpStatus.BAD_REQUEST);

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.

Indent?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants