mirror of
https://github.com/github/codeql.git
synced 2026-04-30 11:15:13 +02:00
Merge branch 'main' into js/shared-dataflow-merge-main
This commit is contained in:
@@ -25,7 +25,7 @@ app.get('/check-with-axios', req => {
|
||||
} else {
|
||||
axios.get(baseURL + req.params.tainted); // OK
|
||||
}
|
||||
|
||||
|
||||
// Blacklists are not safe
|
||||
if (!req.query.tainted.match(/^[/\.%]+$/)) {
|
||||
axios.get("test.com/" + req.query.tainted); // SSRF
|
||||
@@ -39,8 +39,29 @@ app.get('/check-with-axios', req => {
|
||||
}
|
||||
|
||||
axios.get("test.com/" + req.query.tainted); // OK - False Positive
|
||||
|
||||
if (req.query.tainted.matchAll(/^[0-9a-z]+$/g)) { // letters and numbers
|
||||
axios.get("test.com/" + req.query.tainted); // OK
|
||||
}
|
||||
if (req.query.tainted.matchAll(/^[0-9a-z\-_]+$/g)) { // letters, numbers, - and _
|
||||
axios.get("test.com/" + req.query.tainted); // OK
|
||||
}
|
||||
});
|
||||
|
||||
const isValidPath = path => path.match(/^[0-9a-z]+$/);
|
||||
|
||||
const isInBlackList = path => path.match(/^[/\.%]+$/);
|
||||
|
||||
app.get('/check-with-axios', req => {
|
||||
const baseURL = "test.com/"
|
||||
if (isValidPathMatchAll(req.params.tainted) ) {
|
||||
axios.get(baseURL + req.params.tainted); // OK
|
||||
}
|
||||
if (!isValidPathMatchAll(req.params.tainted) ) {
|
||||
axios.get(baseURL + req.params.tainted); // NOT OK - SSRF
|
||||
} else {
|
||||
axios.get(baseURL + req.params.tainted); // OK
|
||||
}
|
||||
});
|
||||
|
||||
const isValidPathMatchAll = path => path.matchAll(/^[0-9a-z]+$/g);
|
||||
|
||||
Reference in New Issue
Block a user