Skip to content

fix(saml): nil-deref panic on assertion build (req.HTTPRequest)#72

Merged
BK1031 merged 1 commit into
mainfrom
bk1031/fix-saml-assertion-nil-deref
Jun 4, 2026
Merged

fix(saml): nil-deref panic on assertion build (req.HTTPRequest)#72
BK1031 merged 1 commit into
mainfrom
bk1031/fix-saml-assertion-nil-deref

Conversation

@BK1031
Copy link
Copy Markdown
Contributor

@BK1031 BK1031 commented Jun 4, 2026

The consent POST /saml/authorize 500'd with a nil pointer dereference and the stash was consumed before the failure, so retries returned 400 invalid sso request.

Root cause: crewjam's assertion maker reads req.HTTPRequest.RemoteAddr (identity_provider.go:810 and :832) to stamp the assertion's SubjectConfirmationData/SubjectLocality Address. On the consent POST we rebuild the IdpAuthnRequest from the stashed AuthnRequest buffer (the original GET /saml/sso request is long gone), so HTTPRequest was nil → panic.

  • GenerateResponse now takes the client IP and sets a non-nil HTTPRequest{RemoteAddr: ...} (also populates the assertion Address correctly)
  • consume the stash only after the assertion is issued: peek with GetSSORequest, then DeleteSSORequest on success — a failed attempt now stays retryable instead of stranding the user

Confirmed against the live pod logs: identity_provider.go:810 → service/response.go:61 (PostBinding) → api/authorize.go. Needs release + redeploy.

…stash only on success

crewjam's assertion maker dereferences req.HTTPRequest.RemoteAddr to stamp the
SubjectConfirmationData/SubjectLocality Address. On the consent POST we rebuild
the IdpAuthnRequest from the stashed buffer (the original GET is gone), so
HTTPRequest was nil and MakeAssertion panicked (500) — after the stash had
already been consumed, so retries failed with "invalid sso request".

- pass the client IP into GenerateResponse and set a non-nil HTTPRequest
- peek the stash with GetSSORequest and only DeleteSSORequest after the
  assertion is issued, so a failed attempt stays retryable
@BK1031 BK1031 merged commit f410541 into main Jun 4, 2026
15 checks passed
@BK1031 BK1031 deleted the bk1031/fix-saml-assertion-nil-deref branch June 4, 2026 22:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant