Mafalda Ferreira,Miguel Monteiro,Tiago Brito,Miguel E. Coimbra,Nuno Santos,Limin Jia和JoséFragosoSantos。 2024。具有多元相关图的JavaScript的有效静态漏洞分析。 https://doi.org/xxxx
工件评估文件夹包含用于复制原始论文结果和数字的所有必要说明和脚本。
| Mafalda Ferreira | JoséFragosoSantos | Filipe Marques | Nuno Santos |
Graph.js是一种静态漏洞扫描仪,专门分析NPM软件包并检测污染风格和原型污染漏洞。
其执行流由两个阶段组成:图形构造和图形查询。在第一阶段,Graph.js构建了要分析程序的多元依赖图(MDG)。基于图的数据结构将抽象语法树,控制流程图和数据依赖关系图聚合到相同的表示形式中。该阶段有两个输出:
在第二阶段中,Graph.js将图导入到Neo4J图形数据库中,并执行用Cypher编写的图形查询,以捕获脆弱的代码模式,例如,将不可靠源连接到危险源的数据依赖关系路径。
Graph.js使用节点生成图形,并使用Neo4J查询图。
它可以在本地执行,也可以在Docker容器中执行(更容易,更健壮的设置)。
通过运行命令来构建Docker容器:
docker build -t graphjs .
通过运行命令来设置本地环境:
./setup.sh
Graph.js提供命令行接口。用-H运行它以进行简短描述。
Usage: ./graphjs_docker.sh -f <file> [options]
Description: Run Graph.js for a given file <file> in a Docker container.
Required:
-f <file> Filename (.js).
Options:
-o <path> Path to store analysis results.
-l Store docker logs.
-e Create exploit template.
-s Silent mode: Does not save graph .svg.
-h Print this help.要运行Graph.js,请运行命令:
./graphjs_docker.sh -f < file_to_analyze > [options]Graph.js提供命令行接口。用-H运行它以进行简短描述。
Usage: graphjs.py [-h] -f FILE [-o OUTPUT] [-s] [-d] [-e]
Options:
-h, --help show this help message and exit
-f FILE, --file FILE Path to JavaScript file (.js) or directory containing JavaScript files for analysis.
-o OUTPUT, --output OUTPUT
Path to store all output files.
-s, --silent Silent mode - no console and graph output.
-d, --docker Query mode - executes neo4j in a docker container instead of running locally.
-e, --exploit Generates symbolic tests.要运行Graph.js,请运行命令:
python3 graphjs.py -f < file_to_analyze > [options]默认情况下,所有结果都存储在graphjs-results文件夹中,在项目的根部,具有以下结构:
graphjs-results
├── graph
│ ├── graph_stats.json (stores some metrics)
│ ├── nodes.csv (csv file of the graph nodes)
│ ├── rels.csv (csv file of the graph relationships)
│ └── normalized.js (normalized code)
└── taint_summary_detection.json (detection results)
Graph.JS代码旨在启用其他人的直接用法,并且可以轻松适应以适应新方案。如前所述,Graph.js由两个阶段组成:图形结构和图形查询。图形构造代码位于graphjs/parser/src文件夹中,最相关的文件组织如下:
src
├── parser.ts
├── output # Code to generate outputs (.csv and .svg)
├── traverse # Parsing algorithms
├── dependency
│ ├── structures/dependency_trackers.ts
│ └── dep_builder.ts
├── ast-builder.ts
├── cfg-builder.ts
└── cg-builder.ts
参考MDG Construction算法的代码位于src/traverse/dependency, where the file结构/distionency_trackers.ts`包含本文中引用的规则和结构。 MDG旨在通用,因此所有建筑步骤都可以通过创建新类型的节点和边缘来适应新方案。
查询的代码位于graphjs/detection文件夹中。这些查询是完全可自定义的,因此,不仅可以修改现有查询,而且还可以创建新的查询来搜索图表中的新模式和不同的模式。
npm start -- -f < file_to_be_analyzed > [options]| 描述 | 旗帜 | 默认 | 必需的 | 需要 |
|---|---|---|---|---|
| javascript文件要分析 | -f | - | 是的 | - |
| 配置文件的位置 | -c | '../config.json' | 不 | - |
| 标准化文件的位置 | -o | - | 不 | - |
| 图形输出目录的位置(CSV和SVG文件) | -g | 'src/graphs/' | 不 | - |
| 输出图形CSV文件 | -CSV | 错误的 | 不 | - |
| 输出图形 | - 图形 | 错误的 | 不 | - |
| 设置图形图中要忽略的结构数组 | -i = [AST,CFG ...] | [] | 不 | 图形 |
| 设置图形图中要忽略的功能数组 | -if = [...] | [] | 不 | 图形 |
| 在图中显示每个语句中的代码 | -SC | 错误的 | 不 | 图形 |
| 静音模式(不是冗长) | - 沉默的 | 错误的 | 不 | - |
Graph.js的开发与该组进行的其他研究有关。
这项工作包括用于检测Node.js代码中漏洞的静态代码分析工具的经验研究。我们创建了一个由957个Node.js代码漏洞的策划数据集,该数据集通过分析NPM Advisory报告中包含的信息来表征和注释。
该数据集可在此处提供。
与这项工作相关的出版物是:
@inproceedings{vulcan_tor,
author = {Brito, Tiago and Ferreira, Mafalda and Monteiro, Miguel and Lopes, Pedro and Barros, Miguel and Santos, José Fragoso and Santos, Nuno},
booktitle = {IEEE Transactions on Reliability},
title = {Study of JavaScript Static Analysis Tools for Vulnerability Detection in Node.js Packages},
year = {2023},
pages = {1-16},
doi = {10.1109/TR.2023.3286301},
}
在这项工作中,我们开发了Rulekeeper的原型,这是一个用于Web框架的GDPR感知的策略合规系统。 RuleKeeper使用Graph.js自动检查Node.js服务器中的GDPR合规性错误。
原型可在此处使用。
与这项工作相关的出版物是:
@inproceedings{ferreira_sp23,
author = {Ferreira, Mafalda and Brito, Tiago and Santos, José Fragoso and Santos, Nuno},
title = {RuleKeeper: GDPR-Aware Personal Data Compliance for Web Frameworks},
booktitle = {Proceedings of 44th IEEE Symposium on Security and Privacy (S&P'23)},
year = {2023},
doi = {10.1109/SP46215.2023.00058},
pages = {1014-1031},
publisher = {IEEE Computer Society},
address = {Los Alamitos, CA, USA},
}