Skip to content

Node.js based forum software built for the modern web

fix: reject SSO auth via callback handler, if state parameter isn't passed in by client (unless checkState is false)

Julian Lamc408d1dc599c
diff --git a/src/routes/authentication.js b/src/routes/authentication.js
index ab523d08e6..bfb01a124e 100644
--- a/src/routes/authentication.js
+++ b/src/routes/authentication.js
@@ -113,7 +113,7 @@ Auth.reloadRoutes = async function (params) {
return next();
}
- next(req.query.state !== req.session.ssoState ? new Error('[[error:csrf-invalid]]') : null);
+ next((!req.session.ssoState || req.query.state !== req.session.ssoState) ? new Error('[[error:csrf-invalid]]') : null);
}, (req, res, next) => {
// Trigger registration interstitial checks
req.session.registration = req.session.registration || {};