The function below parses three numeric form fields using eval().
The bug: eval() runs its argument as JavaScript with full access to the current scope. Any user who can control the input string can run arbitrary code on the server — this is the exact bug found in OWASP's NodeGoat (a deliberately-vulnerable Node.js app used for security training), in the endpoint that handles retirement contribution updates:
const preTax = eval(req.body.preTax);
const afterTax = eval(req.body.afterTax);
const roth = eval(req.body.roth);Your task: fix solve(preTaxInput, afterTaxInput, rothInput) so it returns { preTax, afterTax, roth } with each field safely parsed as a number — using null for any input that isn't a valid, finite number.
solve('500', '1200', '0') // → { preTax: 500, afterTax: 1200, roth: 0 }
solve('1 + 1', '0', '0') // → { preTax: null, afterTax: 0, roth: 0 } (never executed as code)Sample tests