Skip to content

[Autofic] Security Patch 2025-07-21 #343

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions app/routes/contributions.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ function ContributionsHandler(db) {

/*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);
const preTax = parseFloat(req.body.preTax);
const afterTax = parseFloat(req.body.afterTax);
const roth = parseFloat(req.body.roth);

/*
//Fix for A1 -1 SSJS Injection attacks - uses alternate method to eval
Expand Down
10 changes: 8 additions & 2 deletions app/routes/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,14 @@ 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);
// Securely handle redirects by using an allow-list of trusted URLs
const allowedUrls = ["https://trustedsite.com/resource1", "https://trustedsite.com/resource2"];
const redirectUrl = req.query.url;
if (allowedUrls.includes(redirectUrl)) {
return res.redirect(redirectUrl);
} else {
return res.status(400).send("Invalid redirect URL");
}
});

// Research Page
Expand Down
14 changes: 6 additions & 8 deletions server.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,22 +82,20 @@ MongoClient.connect(db, (err, db) => {
secret: cookieSecret,
// Both mandatory in Express v4
saveUninitialized: true,
resave: true
/*
resave: true,
// Fix for A5 - Security MisConfig
// Use generic cookie name
key: "sessionId",
*/

/*
// Fix for A3 - XSS
// TODO: Add "maxAge"
cookie: {
httpOnly: true
// Remember to start an HTTPS server to get this working
// secure: true
httpOnly: true,
secure: true, // Remember to start an HTTPS server to get this working
domain: 'example.com', // Set your domain
path: '/',
expires: new Date(Date.now() + 60 * 60 * 1000) // 1 hour
}
*/

}));

Expand Down