SimpleAuthentication icon indicating copy to clipboard operation
SimpleAuthentication copied to clipboard

State value in callback query doesn't compared with session stored value

Open AlexanderSysoev opened this issue 8 years ago • 6 comments

At BaseOAuth20Provider.cs:

        // Start with the Cross Site Request Forgery check.
        var callbackState = queryStringParameters[StateKey];
        if (string.IsNullOrEmpty(callbackState))
        {
            var errorMessage =
                "The callback querystring doesn't include a state key/value parameter. We need one of these so we can to a CSRF check. Please check why the request url from the provider is missing the parameter: " +
                StateKey + ". eg. &state=something...";
            TraceSource.TraceError(errorMessage);
            throw new AuthenticationException(errorMessage);
        }

May be this line of code needed: callbackState.Equals(state, StringComparison.OrdinalIgnoreCase)

AlexanderSysoev avatar Jul 21 '17 08:07 AlexanderSysoev

Hi @AlexanderSysoev - thanks for filing this issue.

can you please give some sample data where this fails the check, so I can understand the problem more.

plz?

PureKrome avatar Jul 21 '17 12:07 PureKrome

@PureKrome I've not tested yet, but I didn't find any comparison inside this region: Cross Site Request Forgery checks -> state == state?

AlexanderSysoev avatar Jul 21 '17 12:07 AlexanderSysoev

OK - so what you're saying is that I'm missing the state check in this part of the code?

(still trying to grok the problem)

PureKrome avatar Jul 21 '17 12:07 PureKrome

OK - so what you're saying is that I'm missing the state check in this part of the code?

Exactly

AlexanderSysoev avatar Jul 21 '17 13:07 AlexanderSysoev

Ok - ta. gotcha! Phew :)

BTW - how did you figure this out?

PureKrome avatar Jul 21 '17 13:07 PureKrome

@PureKrome sorry for my bad communication skills)

how did you figure this out?

Just viewing the code)

AlexanderSysoev avatar Jul 21 '17 13:07 AlexanderSysoev