Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

As this course focuses on security testing for Python, an essential first step is to assess your environment for known vulnerable dependencies. A practical tool for this purpose is pip-audit.

pip-audit scans installed Python packages and compares them against publicly disclosed vulnerabilities from trusted advisory databases. It helps you identify packages with known security issues so that you can update, replace, or remediate them as part of your security testing process.

What pip-audit Does — and Does Not Do

pip-audit analyses dependency trees, not source code. It identifies known vulnerabilities in package versions, but it does not perform static code analysis and does not examine your application logic.

It is important to understand its limitations:

pip-audit is first and foremost an simple and fast test tool for auditing tool for known vulnerabilities in Python packages.


Installation

Install pip-audit into your Python environment:

python -m pip install pip-audit

Basic Usage

First, activate your virtual environment (recommended for security testing to avoid contaminating your system environment).

Then run:

pip-audit

This will:


Auditing a Requirements File

To audit dependencies defined in a requirements file:

pip-audit -r requirements.txt

This checks the resolved dependency set similarly to installing the requirements, but in an isolated context to minimise conflicts with your current environment.


Using pip-audit in Security Testing

Within a security testing workflow, pip-audit should be used:

It is best combined with:

In short, pip-audit helps you identify known risks in your dependency tree, but it should be part of a broader, defence-in-depth security testing strategy rather than relied upon as a single line of defence.