Is preventing open redirects attack in nodejs secure?
I'm trying to prevent open redirect attack. Please look at the code below and check for security: var = require('url'); // http://example.com/login?redirect=http://example.com/dashboard app.route('/login', function (req, res, next) { var redirect = req.query.redirect, paths = url.parse(redirect); if (paths.host !== req.headers.host) { return next(new Error('Open redirect attack detected')); } return res.redirect(redirect); }); Is it enough for preventing open redirect attack or should I add anything else? CWE-601: URL Redirection to Untrusted Site ('Open Redirect') Description of Open Redirect