Files
codeql/javascript/ql/test/query-tests/Security/CWE-807/example_bypass.js
Asger F c79d355d26 JS: Update alerts in example_bypass.js
We happen to flag the condition with different-kinds-comparison-bypass.
The ConditionalBypass query was originally intended to flag this I think, but doesn't anymore.
2025-02-28 13:28:57 +01:00

24 lines
664 B
JavaScript

var express = require('express');
var app = express();
// ...
app.get('/full-profile/:userId', function(req, res) {
if (req.cookies.loggedInUserId !== req.params.userId) { // $ Alert[js/different-kinds-comparison-bypass]
requireLogin(); // $ MISSING: Alert - login decision made based on user controlled data
} else {
// ... show private information
}
});
app.get('/full-profile/:userId', function(req, res) {
if (req.signedCookies.loggedInUserId !== req.params.userId) {
// OK - login decision made based on server controlled data
requireLogin();
} else {
// ... show private information
}
});