diff --git a/app/routes/contributions.js b/app/routes/contributions.js index 7f68170b94..be952a5fed 100644 --- a/app/routes/contributions.js +++ b/app/routes/contributions.js @@ -27,11 +27,10 @@ function ContributionsHandler(db) { this.handleContributionsUpdate = (req, res, next) => { - /*jslint evil: true */ - // Insecure use of eval() to parse inputs - const preTax = eval(req.body.preTax); - const afterTax = eval(req.body.afterTax); - const roth = eval(req.body.roth); + // Secure parsing of numeric inputs + const preTax = parseFloat(req.body.preTax) || 0; + const afterTax = parseFloat(req.body.afterTax) || 0; + const roth = parseFloat(req.body.roth) || 0; /* //Fix for A1 -1 SSJS Injection attacks - uses alternate method to eval diff --git a/app/routes/index.js b/app/routes/index.js index a9e55426bf..a74b3ae538 100644 --- a/app/routes/index.js +++ b/app/routes/index.js @@ -68,8 +68,21 @@ const index = (app, db) => { // Handle redirect for learning resources link app.get("/learn", isLoggedIn, (req, res) => { - // Insecure way to handle redirects by taking redirect url from query string - return res.redirect(req.query.url); + // Secure way to handle redirects with URL validation + const allowedUrls = [ + '/dashboard', + '/profile', + '/courses', + '/tutorials' + ]; + + const redirectUrl = req.query.url; + + if (!redirectUrl || !allowedUrls.includes(redirectUrl)) { + return res.redirect('/dashboard'); // Default safe redirect + } + + return res.redirect(redirectUrl); }); // Research Page diff --git a/app/views/benefits.html b/app/views/benefits.html index 40e9b45bee..35808d34d4 100644 --- a/app/views/benefits.html +++ b/app/views/benefits.html @@ -52,6 +52,7 @@