question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

IdentityServer4: combo of response_mode=form_post and state protection not working

See original GitHub issue

I am using latest 3.14.0 release and have trouble setting up following provider:

Providers.IdentityServer4({
      id: 'identity-server4',
      name: 'IdentityServer4',
      scope: 'openid profile email offline_access',
      domain: XXX,
      clientId: XXX,
      clientSecret: XXX,
      authorizationParams: {
        prompt: 'login',
        response_mode: 'form_post'
      }
    })

When setting response_mode to 'form_post' (which enforces the IdP to send the data back via POST instead of GET https://identityserver4.readthedocs.io/en/latest/endpoints/authorize.html) I run into several issues. GET method works fine, but pen-test team insists to use POST.

First is the fact, that state-handler accepts only state passed in query https://github.com/nextauthjs/next-auth/blob/main/src/server/lib/oauth/state-handler.js#L19

Whenever I change it to:

const state = req.query.state || req.body.state;

I am able to get a step further, to next issue. It appears that the existing and expected state calculation is somehow wrong:

[next-auth][debug][oauth_callback_protection] Comparing received and expected state {
  state: 'c064b8b9ff3df38f8b3a8ce260cc5e9fc1c7dfcfe855c19da38863e207b63a55',
  expectedState: '226418f7beb8a5a755f6fb0b42dfad47c75b84130b6bbeec0d3474af6c03f5f0'
}

Does anyone have a similar setup and experience similar issues?

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:9 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
wjkaweckicommented, Apr 27, 2021

@balazsorban44 another round of penetration tests is through and the feedback is positive 🥳 High five!

1reaction
wjkaweckicommented, Apr 12, 2021

Thank you @balazsorban44, I’ve bumped the package version to latest. Pentest team is planning a retest round later this week - I’ll get back to you once I have some feedback from their end.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Correlation failed at signin-oidc redirect · Issue #720
I am hitting this with the following combination: Browser incognito mode; Application is behind Azure gateway. I am not even using IdentityServer; it...
Read more >
Message "Unable to unprotect message.State" when ...
When running a single instance of IdentityServer4, we can login with another identity provider succesfully. As soon as we create several ...
Read more >
IdentityServer4 Authorization and Working with Claims
We can use claims to show identity-related information in our application but, we can use it for the authorization process as well.
Read more >
IdentityServer4 Documentation
We believe that the combination of OpenID Connect and OAuth 2.0 is the ... the typical security problems of today's mobile, native and...
Read more >
IdentityServer4 Documentation
We believe that the combination of OpenID Connect and OAuth 2.0 is the ... the typical security problems of today's mobile, native and...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found