Datasets:
id int64 | code string | classes list | group string |
|---|---|---|---|
0 | const puppeteer = require('puppeteer');
const parseTorrent = require('parse-torrent');
(async () => {
let tainted = "dir/" + parseTorrent(torrent).name + ".torrent.data"; // $ Source
const browser = await puppeteer.launch();
const page = await browser.newPage();
await page.pdf({ path: tainted, format:... | [
"path_traversal"
] | classic |
1 | ((File) source()).setReadOnly(); // $ Alert[java/path-injection]
// "java.io;File;True;setWritable;;;Argument[this];path-injection;manual"
((File) source()).setWritable(true); // $ Alert[java/path-injection]
// "java.io;File;true;renameTo;(File);;Argument[0];create-file;ai-generated"
new... | [
"path_traversal"
] | classic |
2 | // Combined absoluteness and folder check in one startsWith call
if (path.startsWith("/home/user/www"))
fs.readFileSync(path);
if (path[0] !== "/" && path[0] !== ".")
fs.readFileSync(path);
});
app.get('/realpath', (req, res) => {
let path = fs.realpathSync(req.query.path); // $ Source
fs.readFileSyn... | [
"path_traversal"
] | classic |
3 | Files.write((Path) source(), (Iterable<CharSequence>) null); // $ Alert[java/path-injection]
Files.write((Path) source(), (Iterable<CharSequence>) null, (Charset) null); // $ Alert[java/path-injection]
// "java.nio.file;Files;false;writeString;;;Argument[0];create-file;manual"
Files.writeString(... | [
"path_traversal"
] | classic |
4 | if (!path.startsWith('..'))
fs.readFileSync(path);
else
fs.readFileSync(path); // $ Alert
});
app.get('/coerce-absolute', (req, res) => {
let path = pathModule.join('/home/user/www', req.query.path); // $ Source
if (path.startsWith('/home/user/www'))
fs.readFileSync(path);
else
fs.readFileSync... | [
"path_traversal"
] | classic |
5 | # Not reported, although vulnerable to '..'
tar = tarfile.open(unsafe_filename_tar)
for entry in tar:
if not os.path.isabs(entry.name):
tar.extract(entry, "/tmp/unpack/")
# Extraction filters
extraction_filter = "fully_trusted"
tar = tarfile.open(unsafe_filename_tar) # $ Source
tar.extractall(filter=extr... | [
"path_traversal"
] | classic |
6 | public class Test {
private HttpServletRequest request;
public Object source() {
return request.getParameter("source"); // $ Source[java/path-injection]
}
void test() throws IOException {
// "java.lang;Module;true;getResourceAsStream;(String);;Argument[0];read-file;ai-generated"
... | [
"path_traversal"
] | classic |
7 | // "java.nio.file;Files;false;writeString;;;Argument[0];create-file;manual"
Files.writeString((Path) source(), (CharSequence) null); // $ Alert[java/path-injection]
Files.writeString((Path) source(), (CharSequence) null, (Charset) null); // $ Alert[java/path-injection]
// "javax.xml.transform.st... | [
"path_traversal"
] | classic |
8 | fs.readFileSync(path.slice(4)); // $ Alert
fs.readFileSync(path.concat(unknown)); // $ Alert
fs.readFileSync(unknown.concat(path)); // $ Alert
fs.readFileSync(unknown.concat(unknown, path)); // $ Alert
fs.readFileSync(path.trim()); // $ Alert
fs.readFileSync(path.toLowerCase()); // $ Alert
fs.readFileSync(path... | [
"path_traversal"
] | classic |
9 | let filePath = url.parse(req.url, true).query["filePath"][0]; // $ Source
// Piping to stdin from a file
await $({ inputFile: filePath })`cat` // $ Alert
// Piping to stdin from a file
await execa('cat', { inputFile: filePath }); // $ Alert
// Piping Stdout to file
await execa('echo', ['exam... | [
"path_traversal"
] | classic |
10 | express = require('express'),
url = require('url'),
sanitize = require('sanitize-filename'),
pathModule = require('path')
;
let app = express();
app.get('/basic', (req, res) => {
let path = req.query.path; // $ Source
fs.readFileSync(path); // $ Alert
fs.readFileSync('./' + path); // $ Alert
... | [
"path_traversal"
] | classic |
11 | app.use(express.json());
app.post('/foo', async (req, res) => {
const dirPath = path.join(__dirname, req.query.filename || 'defaultDir'); // $ Source
mkdirp(dirPath); // $ Alert
mkdirp.sync(dirPath); // $ Alert
mkdirp.nativeSync(dirPath); // $ Alert
mkdirp.native(dirPath); // $ Alert
mkdirp.ma... | [
"path_traversal"
] | classic |
12 | require("bluebird").promisifyAll(fs).readFileSync(path); // $ Alert
});
const asyncFS = require("./my-async-fs-module");
http.createServer(function(req, res) {
var path = url.parse(req.url, true).query.path; // $ Source
fs.readFileSync(path); // $ Alert
asyncFS.readFileSync(path); // $ Alert
require("pify"... | [
"path_traversal"
] | classic |
13 | ((File) source()).delete(); // $ Alert[java/path-injection]
// "java.io;File;True;deleteOnExit;();;Argument[this];path-injection;manual"
((File) source()).deleteOnExit(); // $ Alert[java/path-injection]
// "java.io;File;True;exists;();;Argument[this];path-injection;manual"
((File) source... | [
"path_traversal"
] | classic |
14 | new FileInputStream((File) source()); // $ Alert[java/path-injection]
// "java.io;FileInputStream;true;FileInputStream;(FileDescriptor);;Argument[0];read-file;manual"
new FileInputStream((FileDescriptor) source()); // $ Alert[java/path-injection]
// "java.io;FileInputStream;true;FileInputStream;... | [
"path_traversal"
] | classic |
15 | let homeDir = path.resolve('.');
res.sendFile(homeDir + '/data/' + req.params.x); // OK - sendFile disallows ../
res.sendfile('data/' + req.params.x); // OK - sendfile disallows ../
res.sendFile(path.resolve('data', req.params.x)); // $ Alert
res.sendfile(path.join('data', req.params.x)); // $ Alert
res.sen... | [
"path_traversal"
] | classic |
16 | fs.readFileSync(path); // $ Alert
else
fs.readFileSync(path); // $ Alert
if (path.includes('..'))
fs.readFileSync(path); // $ Alert
else
fs.readFileSync(path); // $ Alert
if (!path.includes('..') && !pathModule.isAbsolute(path))
fs.readFileSync(path);
else
fs.readFileSync(path); // $ Ale... | [
"path_traversal"
] | classic |
17 | import { makeDirectory, makeDirectorySync } from 'make-dir';
const express = require('express');
const app = express();
app.get('/makedir', async (req, res) => {
const file = req.query.file; // $ Source
await makeDirectory(file); // $ Alert
makeDirectorySync(file); // $ Alert
}); | [
"path_traversal"
] | classic |
18 | }
void test(AntClassLoader acl) {
// "org.apache.tools.ant;AntClassLoader;true;addPathComponent;(File);;Argument[0];read-file;ai-generated"
acl.addPathComponent((File) source()); // $ Alert[java/path-injection]
// "org.apache.tools.ant;AntClassLoader;true;AntClassLoader;(ClassLoader,Project... | [
"path_traversal"
] | classic |
19 | ((File) source()).isHidden(); // $ Alert[java/path-injection]
// "java.io;File;True;mkdir;();;Argument[this];path-injection;manual"
((File) source()).mkdir(); // $ Alert[java/path-injection]
// "java.io;File;True;mkdirs;();;Argument[this];path-injection;manual"
((File) source()).mkdirs()... | [
"path_traversal"
] | classic |
20 | fs.rmdir(filename); // $ Alert
fs.rmdirSync(filename); // $ Alert
fs.cp(filename, "destination"); // $ Alert
fs.cp("source", filename); // $ Alert
fs.copyFileSync(filename, "destination"); // $ Alert
fs.copyFileSync("source", filename); // $ Alert
fs.cpSync(filename, "destination"); // $ Alert
... | [
"path_traversal"
] | classic |
21 | fs.readFileSync(path); // $ Alert
asyncFS.readFileSync(path); // $ Alert
require("pify")(fs.readFileSync)(path); // $ Alert
require("pify")(fs).readFileSync(path); // $ Alert
require('util.promisify')(fs.readFileSync)(path); // $ Alert
require("thenify")(fs.readFileSync)(path); // $ Alert
const readPkg ... | [
"path_traversal"
] | classic |
22 | fs.readFileSync(unknown.concat(path)); // $ Alert
fs.readFileSync(unknown.concat(unknown, path)); // $ Alert
fs.readFileSync(path.trim()); // $ Alert
fs.readFileSync(path.toLowerCase()); // $ Alert
fs.readFileSync(path.split('/')); // OK - readFile throws an exception when the filename is an array
fs.readFileSyn... | [
"path_traversal"
] | classic |
23 | const fs = require('fs');
var AdmZip = require('adm-zip');
var zip = new AdmZip("archive.zip");
var zipEntries = zip.getEntries();
zipEntries.forEach(function(zipEntry) {
fs.createWriteStream(zipEntry.entryName); // $ Alert
}); | [
"path_traversal"
] | classic |
24 | app.post('/rmsync', async (req, res) => {
const { path } = req.body; // $ Source
rimraf.sync(path); // $ Alert
rimraf.rimrafSync(path); // $ Alert
rimraf.native(path); // $ Alert
await rimraf.native(path); // $ Alert
rimraf.native.sync(path); // $ Alert
rimraf.nativeSync(path); // $ Alert
... | [
"path_traversal"
] | classic |
25 | fs.readFileSync(path); // $ Alert - can be of the form 'safe/directory/../../../etc/passwd'
return;
} else {
fs.readFileSync(path); // $ Alert
}
let normalizedPath = pathModule.join(SAFE, path);
if (pathIsInside(normalizedPath, SAFE)) {
fs.readFileSync(normalizedPath);
return;
} else {
fs.readFileSync(... | [
"path_traversal"
] | classic |
26 | var server = http.createServer(function(req, res) {
// tests for a few more uri-libraries
const qs = require("qs");
res.write(fs.readFileSync(qs.parse(req.url).foo)); // $ Alert
res.write(fs.readFileSync(qs.parse(normalizeUrl(req.url)).foo)); // $ Alert
const parseqs = require("parseqs");
res.write(fs.readF... | [
"path_traversal"
] | classic |
27 | if (!pathModule.isAbsolute(path) && !path.startsWith('..'))
fs.readFileSync(path);
path = decodeURIComponent(path);
if (!pathModule.isAbsolute(path) && !path.startsWith('..'))
fs.readFileSync(path); // $ Alert - not normalized
});
app.get('/replace', (req, res) => {
let path = pathModule.normalize(req.... | [
"path_traversal"
] | classic |
28 | fs.readFileSync('./' + path); // $ Alert
fs.readFileSync(path + '/index.html'); // $ Alert
fs.readFileSync(pathModule.join(path, 'index.html')); // $ Alert
fs.readFileSync(pathModule.join('/home/user/www', path)); // $ Alert
});
app.get('/normalize-notAbsolute', (req, res) => {
let path = pathModule.normalize(... | [
"path_traversal"
] | classic |
29 | var fs = require('fs'),
http = require('http'),
url = require('url');
var server = http.createServer(function(req, res) {
let path = url.parse(req.url, true).query.path; // $ Source
fs.readFileSync(path); // $ Alert
var obj = bla ? something() : path;
fs.readFileSync(obj.sub); // $ Alert
obj.su... | [
"path_traversal"
] | classic |
30 | require("thenify")(fs.readFileSync)(path); // $ Alert
const readPkg = require('read-pkg');
var pkg = readPkg.readPackageSync({cwd: path}); // $ Alert
var pkgPromise = readPkg.readPackageAsync({cwd: path}); // $ Alert
});
const mkdirp = require("mkdirp");
http.createServer(function(req, res) {
var path = url.p... | [
"path_traversal"
] | classic |
31 | (async () => {
const server = Hapi.server({
port: 3005,
host: 'localhost'
});
server.route({
method: 'GET',
path: '/hello',
handler: async (request, h) => {
const filepath = request.query.filepath; // $ Source
const data = await fs.readFile(fi... | [
"path_traversal"
] | classic |
32 | let newpath = pathModule.normalize(path);
var relativePath = pathModule.relative(pathModule.normalize(workspaceDir), newpath);
if (relativePath.indexOf('..' + pathModule.sep) === 0) {
fs.readFileSync(newpath); // $ Alert
} else {
fs.readFileSync(newpath);
}
let newpath = pathModule.normalize(path);
... | [
"path_traversal"
] | classic |
33 | module.exports = (req, res) => res.render(req.params[0]); // $ Alert | [
"path_traversal"
] | classic |
34 | #Sanitized
tar = tarfile.open(unsafe_filename_tar)
for entry in tar:
if os.path.isabs(entry.name) or ".." in entry.name:
raise ValueError("Illegal tar archive entry")
tar.extract(entry, "/tmp/unpack/")
#Part Sanitized
tar = tarfile.open(unsafe_filename_tar) # $ Source
for entry in tar:
if ".." in e... | [
"path_traversal"
] | classic |
35 | let newpath = pathModule.normalize(path);
var relativePath = pathModule.relative(pathModule.normalize(workspaceDir), newpath);
if (relativePath.indexOf('../') === 0) {
fs.readFileSync(newpath); // $ Alert
} else {
fs.readFileSync(newpath);
}
let newpath = pathModule.normalize(path);
var relativePat... | [
"path_traversal"
] | classic |
36 | const express = require('express');
const fs = require('fs-extra');
const app = express();
app.use(express.json());
app.post('/rmsync', (req, res) => {
const { filename } = req.body; // $ Source
fs.rmSync(filename); // $ Alert
fs.rm(filename); // $ Alert
fs.rmdir(filename); // $ Alert
fs.rmdi... | [
"path_traversal"
] | classic |
37 | mkdirp(path); // $ Alert
mkdirp.sync(path); // $ Alert
func(path);
});
function func(x) {
fs.readFileSync(x); // $ Alert
}
const fsp = require("fs/promises");
http.createServer(function(req, res) {
var path = url.parse(req.url, true).query.path; // $ Source
fsp.readFile(path); // $ Alert
}); | [
"path_traversal"
] | classic |
38 | var express = require('express');
var app = express();
app.get('/some/path', function(req, res) {
var m = require(req.param("module")); // $ Alert - loading a module based on un-sanitized query parameters
});
const resolve = require("resolve");
app.get('/some/path', function(req, res) {
var module = resolve.sync... | [
"path_traversal"
] | classic |
39 | return;
fs.readFileSync(path); // $ Alert
if (!path.match(/\./)) {
fs.readFileSync(path);
}
if (!path.match(/\.\./)) {
fs.readFileSync(path);
}
if (!path.match(/\.\.\//)) {
fs.readFileSync(path);
}
if (!path.match(/\.\.\/foo/)) {
fs.readFileSync(path); // $ Alert
}
if (!path.match(/(... | [
"path_traversal"
] | classic |
40 | Files.copy((InputStream) null, (Path) source()); // $ Alert[java/path-injection]
// "java.nio.file;Files;false;createDirectories;;;Argument[0];create-file;manual"
Files.createDirectories((Path) source()); // $ Alert[java/path-injection]
// "java.nio.file;Files;false;createDirectory;;;Argument[0]... | [
"path_traversal"
] | classic |
41 | if (special) {
return require("fs");
} else {
return require("original-fs");
}
}
var util = require("util");
http.createServer(function(req, res) {
var path = url.parse(req.url, true).query.path; // $ Source
util.promisify(fs.readFileSync)(path); // $ Alert
require("bluebird").promisify(fs.readFile... | [
"path_traversal"
] | classic |
42 | res.write(fs.readFileSync("prefix" + pathModule.normalize(path).replace(/(\.\.\/)*/, '')));
res.write(fs.readFileSync("prefix" + path.replace(/^(\.\.[\/\\])+/, ''))); // $ Alert - not normalized
res.write(fs.readFileSync(pathModule.normalize(path).replace(/^(\.\.[\/\\])+/, ''))); // $ Alert - can be absolute
});
... | [
"path_traversal"
] | classic |
43 | new FileReader((String) source(), null); // $ Alert[java/path-injection]
// "java.nio.file;Files;false;copy;;;Argument[0];read-file;manual"
Files.copy((Path) source(), (Path) null); // $ Alert[java/path-injection]
Files.copy((Path) source(), (OutputStream) null); // $ Alert[java/path-injection]
... | [
"path_traversal"
] | classic |
44 | res.write(fs.readFileSync(pathModule.join(path))); // $ Alert - taint is preserved
res.write(fs.readFileSync(pathModule.join(x, y, path, z))); // $ Alert - taint is preserved
res.write(fs.readFileSync(pathModule.normalize(path))); // $ Alert - taint is preserved
res.write(fs.readFileSync(pathModule.relative(x, pa... | [
"path_traversal"
] | classic |
45 | const app = express();
app.use(express.json());
app.post('/foo', async (req, res) => {
const dirPath = path.join(__dirname, req.query.filename || 'defaultDir'); // $ Source
mkdirp(dirPath); // $ Alert
mkdirp.sync(dirPath); // $ Alert
mkdirp.nativeSync(dirPath); // $ Alert
mkdirp.native(dirPath); /... | [
"path_traversal"
] | classic |
46 | app.get('/noDotDot', (req, res) => {
let path = pathModule.normalize(req.query.path); // $ Source
if (path.includes('..'))
return;
fs.readFileSync(path); // $ Alert - can still be absolute
if (!pathModule.isAbsolute(path))
fs.readFileSync(path);
else
fs.readFileSync(path); // $ Alert
});
app.g... | [
"path_traversal"
] | classic |
47 | fs.rm(filename); // $ Alert
fs.rmdir(filename); // $ Alert
fs.rmdirSync(filename); // $ Alert
fs.cp(filename, "destination"); // $ Alert
fs.cp("source", filename); // $ Alert
fs.copyFileSync(filename, "destination"); // $ Alert
fs.copyFileSync("source", filename); // $ Alert
fs.cpSync(filena... | [
"path_traversal"
] | classic |
48 | const path = require('path');
const app = express();
app.use(express.json());
app.post('/foo', async (req, res) => {
const dirPath = path.join(__dirname, req.query.filename || 'defaultDir'); // $ Source
mkdirp(dirPath); // $ Alert
mkdirp.sync(dirPath); // $ Alert
mkdirp.nativeSync(dirPath); // $ Aler... | [
"path_traversal"
] | classic |
49 | def normalize_then_check():
x = source()
y = normalize(x)
if y.startswith("subfolder/"):
open(y) # $ result=OK
@app.route("/path")
def check_then_normalize():
x = source()
if x.startswith("subfolder/"):
y = normalize(x)
open(y) # $ Alert | [
"path_traversal"
] | classic |
50 | if (path === 'foo.txt' || path === 'bar.txt' || someOpaqueCondition())
res.write(fs.readFileSync(path)); // $ Alert - Path is incompletely compared to white-list
path = sanitize(path);
res.write(fs.readFileSync(path)); // OK - Path is sanitized
path = url.parse(req.url, true).query.path; // $ Source
// OK... | [
"path_traversal"
] | classic |
51 | fs.readFileSync(path.substr(4)); // $ Alert
fs.readFileSync(path.slice(4)); // $ Alert
fs.readFileSync(path.concat(unknown)); // $ Alert
fs.readFileSync(unknown.concat(path)); // $ Alert
fs.readFileSync(unknown.concat(unknown, path)); // $ Alert
fs.readFileSync(path.trim()); // $ Alert
fs.readFileSync(path.toLo... | [
"path_traversal"
] | classic |
52 | if (abs.indexOf(root) !== 0) {
fs.readFileSync(path); // $ Alert
return;
}
fs.readFileSync(path);
});
var rootPath = process.cwd();
app.get('/yet-another-prefix2', (req, res) => {
let path = req.query.path; // $ Source
fs.readFileSync(path); // $ Alert
var requestPath = pathModule.join(rootPath, path)... | [
"path_traversal"
] | classic |
53 | url = require("url"),
fs = require("fs"),
gracefulFs = require("graceful-fs"),
fsExtra = require("fs-extra"),
originalFs = require("original-fs");
var server = http.createServer(function(req, res) {
var path = url.parse(req.url, true).query.path; // $ Source
fs.readFileSync(path); // $ Alert
gracefulFs.... | [
"path_traversal"
] | classic |
54 | fs.readFileSync(path); // $ Alert - wrong polarity
});
app.get('/relative-startswith', (req, res) => {
let path = pathModule.resolve(req.query.path); // $ Source
fs.readFileSync(path); // $ Alert
var self = something();
var relative = pathModule.relative(self.webroot, path);
if(relative.startsWith(".." + ... | [
"path_traversal"
] | classic |
55 | return "not this time"
f = open(path) # $ Alert
@app.route("/no-dot-dot-with-prefix")
def no_dot_dot_with_prefix():
filename = request.args.get('filename', '')
path = os.path.join(STATIC_DIR, "img-"+filename)
# Note: Since `filename` has a prefix, it's not possible to use an absolute path.
# Ther... | [
"path_traversal"
] | classic |
56 | ((File) source()).createNewFile(); // $ Alert[java/path-injection]
// "java.io;File;true;createTempFile;(String,String,File);;Argument[2];create-file;ai-generated"
File.createTempFile(";", ";", (File) source()); // $ Alert[java/path-injection]
// "java.io;File;True;delete;();;Argument[this];path... | [
"path_traversal"
] | classic |
57 | fs.copyFileSync(filename, "destination"); // $ Alert
fs.copyFileSync("source", filename); // $ Alert
fs.cpSync(filename, "destination"); // $ Alert
fs.cpSync("source", filename); // $ Alert
fs.emptydirSync(filename); // $ Alert
fs.emptydir(filename); // $ Alert
fs.opendir(filename); // $ Alert
... | [
"path_traversal"
] | classic |
58 | import (
"archive/tar"
"errors"
"io"
"os"
"path"
"path/filepath"
"strings"
)
func untarBad(reader io.Reader, prefix string) {
tarReader := tar.NewReader(reader)
header, _ := tarReader.Next() // $ Alert[go/zipslip]
os.MkdirAll(path.Dir(header.Name), 0755) // $ Sink[go/zipslip] // NOT OK
}
func unt... | [
"path_traversal"
] | classic |
59 | app.get('/slash-stuff', (req, res) => {
let path = req.query.path; // $ Source
fs.readFileSync(path); // $ Alert
fs.readFileSync(slash(path)); // $ Alert
});
app.get('/dotdot-regexp', (req, res) => {
let path = pathModule.normalize(req.query.x); // $ Source
if (pathModule.isAbsolute(path))
return;
fs... | [
"path_traversal"
] | classic |
60 | }
});
app.get('/yet-another-prefix', (req, res) => {
let path = pathModule.resolve(req.query.path); // $ Source
fs.readFileSync(path); // $ Alert
var abs = pathModule.resolve(path);
if (abs.indexOf(root) !== 0) {
fs.readFileSync(path); // $ Alert
return;
}
fs.readFileSync(path);
}); | [
"path_traversal"
] | classic |
61 | const express = require('express');
const prettier = require("prettier");
const app = express();
app.get('/some/path', function (req, res) {
const { p } = req.params; // $ Source
prettier.resolveConfig(p).then((options) => { // $ Alert
const formatted = prettier.format("foo", options);
});
pre... | [
"path_traversal"
] | classic |
62 | url = require('url');
var server = http.createServer(function(req, res) {
let path = url.parse(req.url, true).query.path; // $ Source
fs.readFileSync(path.substring(i, j));
fs.readFileSync(path.substring(4)); // $ Alert
fs.readFileSync(path.substring(0, i)); // $ Alert
fs.readFileSync(path.substr(4)); // $ Alert... | [
"path_traversal"
] | classic |
63 | rimraf.native.sync(path); // $ Alert
rimraf.nativeSync(path); // $ Alert
await rimraf.manual(path); // $ Alert
rimraf.manual(path); // $ Alert
rimraf.manual.sync(path); // $ Alert
rimraf.manualSync(path); // $ Alert
await rimraf.windows(path); // $ Alert
rimraf.windows(path); // $ Alert
... | [
"path_traversal"
] | classic |
64 | var rootPath = process.cwd();
app.get('/yet-another-prefix2', (req, res) => {
let path = req.query.path; // $ Source
fs.readFileSync(path); // $ Alert
var requestPath = pathModule.join(rootPath, path);
var targetPath;
if (!allowPath(requestPath, rootPath)) {
targetPath = rootPath;
fs.readFileSync(r... | [
"path_traversal"
] | classic |
65 | const app = express();
app.use(express.json());
app.post('/rmsync', (req, res) => {
const { filename } = req.body; // $ Source
fs.rmSync(filename); // $ Alert
fs.rm(filename); // $ Alert
fs.rmdir(filename); // $ Alert
fs.rmdirSync(filename); // $ Alert
fs.cp(filename, "destination"); // $... | [
"path_traversal"
] | classic |
66 | res.write(fs.readFileSync("prefix" + path.replace(/^(\.\.[\/\\])+/, ''))); // $ Alert - not normalized
res.write(fs.readFileSync(pathModule.normalize(path).replace(/^(\.\.[\/\\])+/, ''))); // $ Alert - can be absolute
});
import normalizeUrl from 'normalize-url';
var server = http.createServer(function(req, res) {
... | [
"path_traversal"
] | classic |
67 | fs.cpSync("source", filename); // $ Alert
fs.emptydirSync(filename); // $ Alert
fs.emptydir(filename); // $ Alert
fs.opendir(filename); // $ Alert
fs.opendirSync(filename); // $ Alert
fs.openAsBlob(filename); // $ Alert
fs.statfs(filename); // $ Alert
fs.statfsSync(filename); // $ Alert
... | [
"path_traversal"
] | classic |
68 | fs.rmSync(filename); // $ Alert
fs.rm(filename); // $ Alert
fs.rmdir(filename); // $ Alert
fs.rmdirSync(filename); // $ Alert
fs.cp(filename, "destination"); // $ Alert
fs.cp("source", filename); // $ Alert
fs.copyFileSync(filename, "destination"); // $ Alert
fs.copyFileSync("source", filena... | [
"path_traversal"
] | classic |
69 | let path = req.query.path; // $ Source
fs.readFileSync(path); // $ Alert
fs.readFileSync('./' + path); // $ Alert
fs.readFileSync(path + '/index.html'); // $ Alert
fs.readFileSync(pathModule.join(path, 'index.html')); // $ Alert
fs.readFileSync(pathModule.join('/home/user/www', path)); // $ Alert
});
app.ge... | [
"path_traversal"
] | classic |
70 | import os
# ok:dangerous-system-call-audit
os.system("ls -al")
# ok:dangerous-system-call-audit
...
dynamic_os.system(something())
# ruleid:dangerous-system-call-audit
dynamic_os = __import__("os")
getattr(dynamic_os, "system")(something())
# ruleid:dangerous-system-call-audit
dynamic_os = __import__("os")
dynamic_... | [
"a5_cmdi"
] | classic |
71 | x = x.replace(/<!--(.*?)-->/gm, ""); // $ Alert[js/incomplete-multi-character-sanitization]
x = x.replace(/\sng-[a-z-]+/, ""); // $ Alert[js/incomplete-multi-character-sanitization]
x = x.replace(/\sng-[a-z-]+/g, ""); // $ Alert[js/incomplete-multi-character-sanitization] - ng-attributes
x = x.replace(/(<!--\[CD... | [
"d4_insecure_output"
] | classic |
72 | const vm = require('vm')
let ctrl1 = function test1(req,res) {
var input = req.query.something || ''
var sandbox = {
foo: input
...
})
// ok:express-vm-injection
app.get('/', function okTest3(req,res) {
const code = `
var x = 1;
`
vm.runInThisContext(code)
res.send('hello world... | [
"b8_sandbox_escape"
] | classic |
73 | See comment in query for more details.
"""
files = request.args.get("files", "")
os.popen2("ls " + files) # $ Alert
os.popen3("ls " + files) # $ Alert
os.popen4("ls " + files) # $ Alert
platform.popen("ls " + files) # $ Alert
popen2.popen2("ls " + files) # $ Alert
popen2.popen3("ls " ... | [
"a5_cmdi"
] | classic |
74 | // Test with method binding
const execBoundAsync = es6Promisify(cp.exec.bind(cp));
execBoundAsync(cmd); // $ Alert
const promisifiedExecMulti = es6Promisify(cp.exec, {
multiArgs: true
});
promisifiedExecMulti(cmd); // $ Alert
const promisifiedCp = es6Promisify.promisifyAll(cp);
pro... | [
"a5_cmdi"
] | classic |
75 | import com.hubspot.jinjava.JinjavaConfig;
import com.hubspot.jinjava.interpret.*;
@Controller
public class JinJavaSSTI {
String sourceName = "sourceName";
@GetMapping(value = "bad1")
public void bad1(HttpServletRequest request) {
String template = request.getParameter("template"); // $ Source[java/server-side-te... | [
"ssti"
] | classic |
76 | from flask import Flask, request # $ Source=flask
app = Flask(__name__)
@app.route("/code-execution")
def code_execution():
code = request.args.get("code")
exec(code) # $ Alert=flask
eval(code) # $ Alert=flask
cmd = compile(code, "<filename>", "exec")
exec(cmd) # $ Alert=flask | [
"d4_insecure_output"
] | classic |
77 | import subprocess
import sys
import flask
app = flask.Flask(__name__)
...
@app.route("a")
def a():
ip = flask.request.args.get("ip")
# ruleid:subprocess-injection
subprocess.run("ping "+ ip)
@app.route("b")
def b():
host = flask.request.headers["HOST"]
# ruleid:subprocess-injection
subprocess... | [
"a5_cmdi"
] | classic |
78 | let tainted = req.query.foo; // $ Source[js/code-injection]
pug.compile(tainted); // $ Alert[js/code-injection]
pug.render(tainted); // $ Alert[js/code-injection]
jade.compile(tainted); // $ Alert[js/code-injection]
jade.render(tainted); // $ Alert[js/code-injection]
dot.template(tainted); // $ Ale... | [
"a5_cmdi"
] | classic |
79 | (function(){
let defaultPattern = /<(([\w:]+)[^>]*)\/>/gi;
let expanded = "<$1></$2>";
// lib1
html.replace(
/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([a-z][^\/\0>\x20\t\r\n\f]*)[^>]*)\/>/gi,
expanded
); // $ Alert[js/unsafe-html-expansion]
html.replace(/<(([a-z][^\/\0>\x20\t\r\n\f]*)[^>]*)\/>/gi... | [
"d4_insecure_output"
] | classic |
80 | re.compile(r"""<!--.*--!?>""", re.IGNORECASE), # $ Alert # NOT OK, does not match newlines
re.compile(r"""(?is)<!--.*--!?>"""), # OK
re.compile(r"""(?i)<!--.*--!?>"""), # $ Alert # NOT OK, does not match newlines [NOT DETECTED]
re.compile(r"""<script.*?>(.|\s)*?<\/script[^>]*>""", re.IGNORECASE), # $ Alert ... | [] | classic |
81 | from textwrap import dedent
def unsafe(request):
# ruleid: user-eval-format-string
message = request.POST.get('message')
print("do stuff here")
...
def fmt_unsafe(request):
# ruleid: user-eval-format-string
message = request.POST.get('message')
print("do stuff here")
code = """
print({}... | [
"d4_insecure_output"
] | classic |
82 | return s.replace(/['"]/g, "\\$&"); // $ Alert[js/incomplete-sanitization]
}
function bad6(s) {
return s.replace(/(['"])/g, "\\$1"); // $ Alert[js/incomplete-sanitization]
}
function bad7(s) {
return s.replace(/('|")/g, "\\$1"); // $ Alert[js/incomplete-sanitization]
}
function bad8(s) {
return s.replace('|', '... | [
"d4_insecure_output"
] | classic |
83 | var multer = require('multer');
var upload = multer({ dest: 'uploads/' });
var app = express();
var exec = require("child_process").exec;
app.post('/profile', upload.single('avatar'), function (req, res, next) {
exec("touch " + req.file.originalname); // $ Alert
});
app.post('/photos/upload', upload.array('pho... | [
"a5_cmdi"
] | classic |
84 | var cp = require("child_process")
module.exports = function (name) { // $ Source
cp.exec("rm -rf " + name); // $ Alert - functions exported as part of a submodule are also flagged.
};
module.exports.foo = function (name) { // $ Source
cp.exec("rm -rf " + name); // $ Alert - this is being called explicitly from chil... | [
"a5_cmdi"
] | classic |
85 | app = Flask(__name__)
@app.route("/python2-specific")
def python2_specific():
"""
These tests are mostly included to check for extra paths that can be generated if
we can track flow into the implementation of a stdlib function, and then to another sink.
See comment in query for more details.
"""
... | [
"a5_cmdi"
] | classic |
86 | first && arr.push(first);
last && arr.push(last); // $ Alert
return arr;
};
var asyncExec = require("async-execute");
module.exports.asyncStuff = function (name) { // $ Source
asyncExec("rm -rf " + name); // $ Alert
}
const myFuncs = {
myFunc: function (name) { // $ Source
asyncExec("rm -rf " + name); // $ Aler... | [
"a5_cmdi"
] | classic |
87 | from textwrap import dedent
def unsafe(request):
# ruleid: user-eval-format-string
message = request.POST.get('message')
print("do stuff here")
...
print('hello')
"""
eval(dedent(code))
def fmt_unsafe(request):
# ruleid: user-eval-format-string
message = request.POST.get('message')
... | [
"d4_insecure_output"
] | classic |
88 | s = "'" + s.replace(/'/g, "'\\''") + "'";
s = s.replace(/^(?:'')+/g, '') // unduplicate single-quote at the beginning
.replace(/\\'''/g, "\\'"); // remove non-escaped single-quote if there are enclosed between 2 escaped
}
return s;
}
module.exports.goodSanitizer = function (name) { // $ Source
cp.exec("rm -rf ... | [
"a5_cmdi"
] | classic |
89 | import express from 'express';
import { WebView } from 'react-native';
var app = express();
app.get('/some/path', function(req, res) {
let tainted = req.param("code"); // $ Source[js/code-injection]
<WebView injectedJavaScript={tainted}/>; // $ Alert[js/code-injection]
let wv = <WebView/>;
wv.injectJavaScrip... | [
"a5_cmdi"
] | classic |
90 | def test_calls(user_input)
# ruleid: dangerous-subshell
result = `foo #{user_input} bar`
# ruleid: dangerous-subshell
result2 = %x{foo #{user_input} bar} | [
"a5_cmdi"
] | classic |
91 | re.compile(r"""<script.*?>.*?<\/script>""", re.IGNORECASE | re.DOTALL), # $ Alert # NOT OK - doesn't match `</script >`
re.compile(r"""<script.*?>.*?<\/script[^>]*>""", re.IGNORECASE | re.DOTALL), # OK
re.compile(r"""<!--.*-->""", re.IGNORECASE | re.DOTALL), # OK - we don't care regexps that only match comments... | [] | classic |
92 | import type { VercelRequest, VercelResponse } from "@vercel/node";
import { exec } from "child_process";
export default function handler(req: VercelRequest, res: VercelResponse) {
const name = req.query.name as string; // $ Source
exec("echo " + name, (err, stdout) => { // $ Alert
res.send(stdout);
});
} | [
"a5_cmdi"
] | classic |
93 | url = require("url");
var server = http.createServer(function (req, res) {
let cmd = url.parse(req.url, true).query.path; // $ Source
require("cross-spawn").sync(cmd); // $ Alert
require("execa").shell(cmd); // $ Alert
require("execa").shellSync(cmd); // $ Alert
require("execa").stdout(cmd); // $ ... | [
"a5_cmdi"
] | classic |
94 | @app.route("/command2")
def command_injection2():
files = request.args.get('files', '')
# Don't let files be `; rm -rf /`
subprocess.Popen("ls " + files, shell=True) # $ Alert result=BAD
@app.route("/command3")
def first_arg_injection():
cmd = request.args.get('cmd', '')
subprocess.Popen([cmd, "pa... | [
"a5_cmdi"
] | classic |
95 | import os
import flask
import hashlib
app = flask.Flask(__name__)
...
def route_param(route_param):
print("blah")
# ruleid: os-system-injection
return os.system(route_param)
@app.route("/route_param_ok/<route_param>")
def route_param_ok(route_param):
print("blah")
# ok: os-system-injection
re... | [
"a5_cmdi"
] | classic |
96 | package testcode.groovy;
import groovy.lang.GroovyClassLoader;
import groovy.lang.GroovyCodeSource;
import groovy.lang.GroovyShell;
...
import java.io.FileNotFoundException;
import java.io.InputStreamReader;
import java.net.URI;
import java.net.URISyntaxException;
public class GroovyShellUsage {
public static v... | [
"a5_cmdi"
] | classic |
97 | (function (content) {
content = content.replace(/<script[\s\S]*?<\/script>/gi, ""); // $ Alert[js/incomplete-multi-character-sanitization]
content = content.replace(/<[a-zA-Z\/](.|\n)*?>/g, '') || ' '; // $ Alert[js/incomplete-multi-character-sanitization]
content = content.replace(/<(script|iframe|video)[\s\S]*?... | [
"d4_insecure_output"
] | classic |
98 | cp.exec("rm -rf " + name); // $ Alert
var sanitized = yetAnohterSanitizer(name);
cp.exec("rm -rf " + sanitized);
}
const cp = require("child_process");
const spawn = cp.spawn;
module.exports.shellOption = function (name) { // $ Source
cp.exec("rm -rf " + name); // $ Alert
cp.execFile("rm", ["-rf", name], {shell:... | [
"a5_cmdi"
] | classic |
99 | let obj = {};
window.addEventListener('message', (ev) => { // $ Source
let message = JSON.parse(ev.data);
window[message.name](message.payload); // $ Alert - may invoke eval
new window[message.name](message.payload); // $ Alert - may invoke jQuery $ function or similar
window["HTMLElement" + message.na... | [
"d4_insecure_output"
] | classic |
🛡️ AI-SaaS AppSec Benchmark — v25
Открытый held-out бенчмарк для оценки детекторов уязвимостей в AI-сгенерированном коде («vibe-coded» приложения: LLM-агенты, RAG, Supabase/Next-стек). Ведётся командой red-team.tech — AI-native сканера безопасности приложений.
857 размеченных примеров (518 уязвимых + 339 безопасных), 25 классов:
17 классических (CWE) + 8 AI-native (OWASP LLM Top-10). Актуальный файл — heldout_public_v25.jsonl.
Зачем это
Классический SAST (Semgrep, CodeQL) ищет синтаксические паттерны и слеп к AI-native уязвимостям — prompt injection, утечки в embeddings, RAG-poisoning, небезопасный вывод LLM. В нашем бенчмарке Semgrep показал F1 = 0.00 на всех 8 AI-native классах. Фронтир-LLM «из коробки» их видят, но дороги, требуют egress кода и хеджируют на security-задачах. Нужен специализированный локальный детектор — и нужен честный открытый бенчмарк, чтобы измерять прогресс.
Наш подход (red-team.tech)
Локальный каскад: детектор Гончая-3B (Qwen2.5-Coder, fine-tuned) + semgrep (recall-гейт) + 2-стадийный судья Gemma-3-12B (триаж → богатый вердикт с PoC) + execution-grounding (sink-gate: подозрительный код исполняется в docker-песочнице, галлюцинации отсекаются). Работает 100% локально — код клиента не уходит во внешний API. Подробнее: red-team.tech/methodology.
Сравнение с фронтиром
Предыдущая ревизия (755 примеров, 20 классов, единая таксономия и скорер для всех):
| Система | macro-F1 | AI-native | classic | exact |
|---|---|---|---|---|
| red-team.tech (каскад, локально) | 0.65 | 0.70 | 0.61 | 0.94 |
| Claude Sonnet 4.6 (egress, авториз.) | 0.58 | 0.52 | 0.64 | 0.74 |
| GPT-5 (egress) | 0.54 | 0.59 | 0.49 | 0.58 |
| Semgrep (SAST) | — | 0.00 | — | — |
Узкий специализированный каскад бьёт универсальные фронтир-модели на своей задаче — при этом локально. Перегон фронтира на v25 (25 классов) — в подготовке; ниже — метрики нашего каскада на v25.
Метрики нашего каскада на v25
| класс | P | R | F1 |
|---|---|---|---|
| d5_sysprompt_leak | 1.00 | 1.00 | 1.00 |
| path_traversal | 1.00 | 0.99 | 0.99 |
| d2_ssrf | 0.91 | 0.99 | 0.95 |
| a3_sqli | 0.68 | 0.96 | 0.80 |
| b3_service_role_client | 0.67 | 1.00 | 0.80 |
| nosql_injection | 0.71 | 0.83 | 0.77 |
| c5_public_share | 0.56 | 1.00 | 0.72 |
| b7_agent_tools | 0.68 | 0.74 | 0.71 |
| mass_assignment | 1.00 | 0.47 | 0.64 |
| d3_rag_ingest | 0.50 | 0.75 | 0.60 |
| d4_insecure_output | 0.82 | 0.45 | 0.58 |
| prototype_pollution | 1.00 | 0.38 | 0.55 |
| a5_cmdi | 0.37 | 0.94 | 0.53 |
| b5_prompt_injection | 0.33 | 1.00 | 0.50 |
| ssti | 0.58 | 0.32 | 0.41 |
| c1_embed_egress | 0.20 | 1.00 | 0.33 |
| argument_injection | 0.60 | 0.19 | 0.29 |
| b8_sandbox_escape | 0.15 | 0.88 | 0.26 |
| c3_cloud_misconfig | 1.00 | 0.09 | 0.16 |
| b2_idor | 0.00 | 0.00 | 0.00 |
| b2c_route_no_auth | 0.00 | 0.00 | 0.00 |
macro-F1 0.483 (classic 0.475 / ai-native 0.498), exact-match 0.623. Held-out 857 примеров, локальный каскад.
Execution-grounding (дикие репозитории)
На реальных GitHub-репозиториях sink-gate (execution-grounded verification) отсекает 62% ложных command-injection срабатываний (8 репозиториев, 23 из 37 confirmed-находок → refuted как физически невоспроизводимые). Это лечит главную боль ИИ-сканеров — галлюцинации.
Что нового в v25
- Таксономия 20 → 25 классов: добавлены
argument_injection,prototype_pollution,ssti,nosql_injection,mass_assignment(частые в JS/Node-стеке). - Метки пересобраны двухмодельным консенсусом (Claude Fable + Opus): устранён таксономический
дрейф — SSTI/NoSQL/argument-injection больше не под метками
a5_cmdi/a3_sqli. - Новые классы — из CodeQL test-suite (github/codeql) + реальный скрап GitHub.
- Anti-leak: тест-сет не пересекается с обучающим корпусом (проверено по нормализованному хешу).
Распределение классов (518 позитивов)
| класс | примеров | семейство |
|---|---|---|
d2_ssrf |
71 | classic |
path_traversal |
70 | classic |
c3_cloud_misconfig |
67 | classic |
a3_sqli |
56 | classic |
a5_cmdi |
52 | classic |
b7_agent_tools |
35 | AI-native |
d4_insecure_output |
31 | AI-native |
ssti |
22 | classic |
nosql_injection |
18 | classic |
b8_sandbox_escape |
17 | AI-native |
argument_injection |
16 | classic |
prototype_pollution |
16 | classic |
mass_assignment |
15 | classic |
d5_sysprompt_leak |
10 | AI-native |
c5_public_share |
9 | classic |
d3_rag_ingest |
4 | AI-native |
b2c_route_no_auth |
3 | classic |
b3_service_role_client |
2 | classic |
b5_prompt_injection |
2 | AI-native |
b2_idor |
1 | classic |
c1_embed_egress |
1 | AI-native |
Формат
JSONL, одна запись на строку:
{"id": 0, "code": "<фрагмент кода>", "classes": ["<class-id>", ...], "group": "<источник>"}
Пустой classes = безопасный код (негатив). Скорер: multi-label P/R/F1, macro по группам
classic ↔ ai-native + exact-match.
Цитирование
AI-SaaS AppSec Benchmark v25. red-team.tech, 2026. https://huggingface.co/datasets/Qwovadis/red-team-appsec-benchmark
— Ведётся red-team.tech · AI-native AppSec для кода, написанного с ИИ · Методология и лидерборд
- Downloads last month
- 191