Fix crash when req.query handling
https://expressjs.com/en/5x/api.html#req.query "As req.query’s shape is based on user-controlled input, all properties and values in this object are untrusted and should be validated before trusting" In essence, req.query.xx can be an array OR an array of strings.
This commit is contained in:
@@ -134,7 +134,7 @@ async function login(req, res, next) {
|
||||
|
||||
const dashboardFqdn = (await dashboard.getLocation()).fqdn;
|
||||
|
||||
if (req.query.redirect) {
|
||||
if (typeof req.query.redirect === 'string') {
|
||||
res.cookie('cloudronProxyAuthRedirect', req.query.redirect, {
|
||||
httpOnly: true,
|
||||
maxAge: constants.DEFAULT_TOKEN_EXPIRATION_MSECS,
|
||||
@@ -146,7 +146,7 @@ async function login(req, res, next) {
|
||||
}
|
||||
|
||||
async function callback(req, res, next) {
|
||||
if (!req.query.code) return next(new HttpError(400, 'missing query argument "code"'));
|
||||
if (typeof req.query.code !== 'string') return next(new HttpError(400, 'missing query argument "code"'));
|
||||
|
||||
debug(`callback: with code ${req.query.code}`);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user