关于pip-auditpip-audit是一款功能强大的安全漏洞扫描工具 , 该工具主要针对Python环境 , 可以帮助广大研究人员扫描和测试Python包中的已知安全漏洞 。pip-audit使用了PythonPackagingAdvisory数据库PyPIJSONAPI作为漏洞报告源 。
功能介绍
1、支持对本地环境和依赖组件(requirements风格文件)进行安全审计;工具安装pip-audit基于Python开发 , 且要求本地环境为Python 3.7或更新版本 。安装并配置好Python环境之后 , 就可以使用下列命令并通过pip来安装pip-audit了:
2、支持多种漏洞服务(PyPI、OSV);
3、支持以CycloneDX XML或JSON格式发送SBOM;
4、提供人类和机器均可读的输出格式(columnar、JSON);
5、无缝接入 / 重用本地pip缓存;
python -m pip install pip-audit第三方包pip-audit的正常运行需要使用到多个第三方包 , 具体组件包名称和版本如下图所示:
除此之外 , 我们还可以通过conda来安装pip-audit:
conda install -c conda-forge pip-audit
工具使用我们可以直接将pip-audit以独立程序运行 , 或通过“python -m”运行:
pip-audit --helppython -m pip_audit --helpusage: pip-audit [-h] [-V] [-l] [-r REQUIREMENTS] [-f FORMAT] [-s SERVICE][-d] [-S] [--desc [{on,off,auto}]] [--cache-dir CACHE_DIR][--progress-spinner {on,off}] [--timeout TIMEOUT][--path PATHS] [-v] [--fix] [--require-hashes]audit the Python environment for dependencies with known vulnerabilitiesoptional arguments:-h, --helpshow this help message and exit-V, --versionshow program's version number and exit-l, --localshow only results for dependencies in the localenvironment (default: False)-r REQUIREMENTS, --requirement REQUIREMENTSaudit the given requirements file; this option can beused multiple times (default: None)-f FORMAT, --format FORMATthe format to emit audit results in (choices: columns,json, cyclonedx-json, cyclonedx-xml) (default:columns)-s SERVICE, --vulnerability-service SERVICEthe vulnerability service to audit dependenciesagainst (choices: osv, pypi) (default: pypi)-d, --dry-runwithout `--fix`: collect all dependencies but do notperform the auditing step; with `--fix`: perform theauditing step but do not perform any fixes (default:False)-S, --strictfail the entire audit if dependency collection failson any dependency (default: False)--desc [{on,off,auto}]include a description for each vulnerability; `auto`defaults to `on` for the `json` format. This flag hasno effect on the `cyclonedx-json` or `cyclonedx-xml`formats. (default: auto)--cache-dir CACHE_DIRthe directory to use as an HTTP cache for PyPI; usesthe `pip` HTTP cache by default (default: None)--progress-spinner {on,off}display a progress spinner (default: on)--timeout TIMEOUTset the socket timeout (default: 15)--path PATHSrestrict to the specified installation path forauditing packages; this option can be used multipletimes (default: [])-v, --verbosegive more output; this setting overrides the`PIP_AUDIT_LOGLEVEL` variable and is equivalent tosetting it to `debug` (default: False)--fixautomatically upgrade dependencies with knownvulnerabilities (default: False)--require-hashesrequire a hash to check each requirement against, forrepeatable audits; this option is implied when anypackage in a requirements file has a `--hash` option.(default: False)退出代码任务完成后 , pip-audit将会退出运行 , 并返回一个代码以显示其状态 , 其中:0:未检测到已知漏洞;工具使用样例审计当前Python环境中的依赖:
1:检测到了一个或多个已知漏洞;
$ pip-auditNo known vulnerabilities found审计给定requirements文件的依赖:$ pip-audit -r ./requirements.txtNo known vulnerabilities found审计一个requirements文件 , 并排除系统包:$ pip-audit -r ./requirements.txt -lNo known vulnerabilities found审计依赖中发现的安全漏洞:$ pip-auditFound 2 known vulnerabilities in 1 packageNameVersion IDFix Versions----------- -------------- ------------Flask 0.5PYSEC-2019-179 1.0Flask 0.5PYSEC-2018-660.12.3审计依赖(包含描述):$ pip-audit --descFound 2 known vulnerabilities in 1 packageNameVersion IDFix Versions Description----------- -------------- ------------ --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------Flask 0.5PYSEC-2019-179 1.0The Pallets Project Flask before 1.0 is affected by: unexpected memory usage. The impact is: denial of service. The attack vector is: crafted encoded JSON data. The fixed version is: 1. NOTE: this may overlap CVE-2018-1000656.Flask 0.5PYSEC-2018-660.12.3The Pallets Project flask version Before 0.12.3 contains a CWE-20: Improper Input Validation vulnerability in flask that can result in Large amount of memory usage possibly leading to denial of service. This attack appear to be exploitable via Attacker provides JSON data in incorrect encoding. This vulnerability appears to have been fixed in 0.12.3. NOTE: this may overlap CVE-2019-1010083.审计JSON格式依赖:$ pip-audit -f json | jqFound 2 known vulnerabilities in 1 package[{"name": "flask","version": "0.5","vulns": [{"id": "PYSEC-2019-179","fix_versions": ["1.0"],"description": "The Pallets Project Flask before 1.0 is affected by: unexpected memory usage. The impact is: denial of service. The attack vector is: crafted encoded JSON data. The fixed version is: 1. NOTE: this may overlap CVE-2018-1000656."},{"id": "PYSEC-2018-66","fix_versions": ["0.12.3"],"description": "The Pallets Project flask version Before 0.12.3 contains a CWE-20: Improper Input Validation vulnerability in flask that can result in Large amount of memory usage possibly leading to denial of service. This attack appear to be exploitable via Attacker provides JSON data in incorrect encoding. This vulnerability appears to have been fixed in 0.12.3. NOTE: this may overlap CVE-2019-1010083."}]},{"name": "jinja2","version": "3.0.2","vulns": []},{"name": "pip","version": "21.3.1","vulns": []},{"name": "setuptools","version": "57.4.0","vulns": []},{"name": "werkzeug","version": "2.0.2","vulns": []},{"name": "markupsafe","version": "2.0.1","vulns": []}]【一>所有资源关注我 , 私信回复“资料”获取<一】审计并尝试自动审计存在漏洞的依赖:
1、网络安全学习路线
2、电子书籍(白帽子)
3、安全大厂内部视频
4、100份src文档
5、常见安全面试题
6、ctf大赛经典题目解析
7、全套工具包
8、应急响应笔记
$ pip-audit --fixFound 2 known vulnerabilities in 1 package and fixed 2 vulnerabilities in 1 packageNameVersion IDFix Versions Applied Fix----- ------- -------------- ------------ ----------------------------------------flask 0.5PYSEC-2019-179 1.0Successfully upgraded flask (0.5 => 1.0)flask 0.5PYSEC-2018-660.12.3Successfully upgraded flask (0.5 => 1.0)许可证协议【漏洞扫描工具有哪些 常用web漏洞扫描工具推荐】本项目的开发与发布遵循 Apache 2.0开源许可证协议 。- 甜品店的优势与劣势swot分析,甜品店的优势与劣势swot分析?
- 老龄化服务创业项目,老龄化服务创业项目经验分享?
- 产品代理销售方案,产品代理销售方案策略分析?
- cps推广是什么意思,cps推广名词含义解释?
- 毕业论文初稿要写到什么程度,毕业论文初稿要写到什么程度及出现的问题?
- 淘宝客推广,淘宝客推广定义攻略?
- 10元店进货渠道,10元店进货渠道如何选品?
- 免费入驻的卖货平台,免费入驻的卖货平台有哪些?
- 创业团队主要五个职务,抖音运营创业团队主要五个职务?
- 淘宝网客服,淘宝网客服的话术技巧?
