fix(cas-auth): return 400 instead of 500 for SLO POST with empty body#13471
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR fixes a nil-body handling bug in the cas-auth plugin’s single-logout (SLO) POST callback path so malformed logout requests with an empty body return a clean 400 instead of triggering a Lua runtime error and returning 500.
Changes:
- Guard the SLO POST body before calling
:matchto avoid indexing a nil value. - Add a regression test that POSTs to the CAS callback endpoint with no body and asserts a 400 response.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
apisix/plugins/cas-auth.lua |
Prevents nil:match(...) in SLO POST handling so empty-body requests return 400. |
t/plugin/cas-auth.t |
Adds a regression test ensuring empty-body SLO POST requests return 400 (not 500). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
An empty <samlp:SessionIndex></samlp:SessionIndex> matched the empty string under (.*), passing an empty ticket through instead of returning 400. Require a non-empty SessionIndex with (.+).
shreemaan-abhishek
approved these changes
Jun 4, 2026
AlinsRan
approved these changes
Jun 4, 2026
membphis
approved these changes
Jun 4, 2026
wistefan
pushed a commit
to wistefan/apisix
that referenced
this pull request
Jun 16, 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.
A
POSTto the CAS callback path with an empty request body returns a 500 instead of a clean 400.The single-logout branch in
cas-auth'saccessreads the body and immediately calls:matchon it:core.request.get_body()returnsnilwhen there's no body, sodata:matchraisesattempt to index local 'data' (a nil value)and the request 500s — even though the very next line already handles the "no ticket" case with a 400, it's never reached.Fix is a one-liner: guard the body before matching so a missing/empty body falls through to the existing 400 branch. A normal CAS ticket callback (a GET with
?ticket=) is unaffected.Added a test that POSTs to the callback with no body and asserts a 400 — it fails with 500 before the fix.