fix: require state parameter in OAuth GET callback#120
Merged
asdek merged 1 commit intovxcontrol:feature/project_improvementsfrom Feb 22, 2026
Merged
Conversation
The AuthLoginGetCallback handler accepted requests with an empty state query parameter, bypassing CSRF validation. When state was empty, the condition `queryState != "" && queryState != state.Value` short-circuited to false, skipping the state mismatch check entirely. Split the validation into two explicit checks: first reject missing state parameter, then verify it matches the stored cookie value. This aligns the GET callback with the POST callback handler which already validates strictly via `data.State != state.Value`. Ref: vxcontrol#101
There was a problem hiding this comment.
Pull request overview
This pull request fixes a critical CSRF vulnerability in the OAuth GET callback handler where the state parameter validation could be bypassed by omitting or providing an empty state value. The fix splits the compound boolean condition into two explicit checks that first reject empty state parameters and then validate the state value matches the stored cookie, bringing it into alignment with the POST callback handler's validation logic.
Changes:
- Split OAuth state validation in
AuthLoginGetCallbackfrom a single compound condition to two explicit checks - First check rejects missing/empty state parameter with appropriate error logging and response
- Second check validates state parameter matches stored cookie value
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
4be6784
into
vxcontrol:feature/project_improvements
9 of 12 checks passed
Contributor
|
thanks for the PR! I'll check it on side, for now let it be in a temporary branch, I gonna to merge it with other changes after testing. |
33 tasks
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.
Description of the Change
Problem
The
AuthLoginGetCallbackhandler inbackend/pkg/server/services/auth.goaccepts requests with an emptystatequery parameter, bypassing CSRF validation. The original condition:When
stateis absent or empty,queryState != ""evaluates tofalse, short-circuiting the entire condition. The handler proceeds to exchange the authorization code without verifying the OAuth state.The
AuthLoginPostCallbackhandler correctly validates withif data.State != state.Value {which rejects empty values.Solution
Split the compound condition into two explicit checks:
This aligns the GET callback with the POST callback's strict validation.
Ref: #101
Type of Change
Areas Affected
Testing and Verification
Test Configuration
Test Steps
AuthLoginGetCallback(auth.go:331) -- compound condition allows empty state bypassAuthLoginPostCallback(auth.go:386) -- strictdata.State != state.ValuecheckTest Results
ErrAuthInvalidAuthorizationStateSecurity Considerations
CSRF vulnerability fix. Without state validation, an attacker could craft a callback URL with a valid authorization code but no state parameter, associating the attacker's OAuth identity with the victim's session.
No new dependencies. No permission changes.
Performance Impact
Negligible -- one additional string comparison on the OAuth callback path.
Deployment Notes
Backward-compatible. Legitimate OAuth flows already include the state parameter.
Checklist
Code Quality
go fmtandgo vet(for Go code)Security
Compatibility
Documentation
Additional Notes
Addresses the CSRF state validation bypass from the security audit (issue #101, item 5).