Guides / Languages and packages
Check PHP dependencies with composer audit
composer audit, part of Composer itself, checks the packages of a project against the security advisories that Packagist publishes. composer require and composer update also refuse versions with a known advisory.
Check your Composer version
composer --version
Commands and output on this page are from Composer 2.11.3 (the current release in November 2026) with PHP 8.5. Older 2.x releases have composer audit, but the blocking and the policy settings may be missing or have other names. Update with composer self-update, or use a newer composer image in Docker builds.
Run the audit
composer audit checks the packages installed in vendor/. Add --locked to check the lockfile, which is what a deploy installs:
composer audit --locked
For a project locked at guzzlehttp/guzzle 7.4.4 (one of eleven entries):
Found 11 security vulnerability advisories affecting 1 package:
+-------------------+----------------------------------------------------------------------------------+
| Package | guzzlehttp/guzzle |
| Severity | high |
| Advisory ID | PKSA-k1b4-kshy-xgbh |
| CVE | CVE-2022-31090 |
| Title | CURLOPT_HTTPAUTH option not cleared on change of origin |
| URL | https://github.com/guzzle/guzzle/security/advisories/GHSA-25mq-v84q-4j7r |
| Affected versions | >=7,<7.4.5|>=4,<6.5.8 |
| Reported at | 2022-06-20T22:16:07+00:00 |
+-------------------+----------------------------------------------------------------------------------+
--format=summary prints only the count, --format=json the full list for scripts. --no-dev leaves out the packages of require-dev, which do not run in production when you deploy with composer install --no-dev.
The exit code is 0 when the audit finds nothing and 1 when it finds an advisory, so the command can gate a CI job as it is. Since Composer 2.7, abandoned packages also fail the audit; --abandoned=report lists them without failing.
Versions with advisories are blocked on update
When you add or update a package, Composer leaves out versions that have a security advisory:
composer require guzzlehttp/guzzle:7.4.4
Problem 1
- Root composer.json requires guzzlehttp/guzzle 7.4.4 (exact version match: 7.4.4 or 7.4.4.0),
found guzzlehttp/guzzle[7.4.4] but these were not loaded, because they are affected by
security advisories ("PKSA-cnw1-2ytm-cgr8", ...). Go to https://packagist.org/security-advisories/
to find advisory details. To ignore the advisories, add their IDs to the
"policy.advisories.ignore-id" config or add the package to "policy.advisories.ignore".
To turn the feature off entirely, you can set "policy.advisories.block" to false.
Installation failed, reverting ./composer.json to its original content.
The setting is policy.advisories.block, on by default. It applies when Composer resolves versions: a composer.lock that already holds a vulnerable version keeps it, and only the audit reports it.
To install a blocked version on purpose, for example to reproduce a bug, pass --no-blocking to that one require, update or install command.
Fix findings
Update the package and its dependencies within the constraints of composer.json:
composer update guzzlehttp/guzzle --with-dependencies
composer audit --locked
If the constraint excludes the fixed version (an exact 7.4.4, as in the example), raise it. Add -W (--with-all-dependencies) when the new version needs newer dependencies than the lockfile has:
composer require guzzlehttp/guzzle:^7.10 -W
- Upgrading guzzlehttp/guzzle (7.4.4 => 7.17.0)
- Upgrading guzzlehttp/promises (1.5.3 => 2.6.2)
Writing lock file
No security vulnerability advisories found.
For a package that only comes in as a dependency of a dependency, composer why shows which package requires it and with which constraint:
composer why guzzlehttp/psr7 --locked
guzzlehttp/guzzle 7.4.4 requires guzzlehttp/psr7 (^1.8.3 || ^2.1)
Ignore an advisory
Record an advisory that does not apply to you in composer.json, with the reason:
{
"config": {
"policy": {
"advisories": {
"ignore-id": {
"CVE-2022-31090": "We do not use the curl handler with CURLOPT_HTTPAUTH."
}
}
}
}
}
The audit then lists the advisory under Found 1 ignored security vulnerability advisory and no longer counts it. CVE, GHSA and PKSA IDs work. Composer 2.11.3 still reads the older config.audit.ignore key with the same content; the documentation marks it as deprecated.
Deploy from the lockfile
Commit composer.lock. On the server or in the image build, install the versions it lists:
composer install --no-dev --no-interaction --optimize-autoloader
composer install never changes the lockfile. When composer.json was changed without an update, it warns:
Warning: The lock file is not up to date with the latest changes in composer.json. You may be getting outdated dependencies. ...
In a Dockerfile, copy the two files first so that Docker caches the dependency layer:
COPY composer.json composer.lock ./
RUN composer install --no-dev --no-interaction --no-scripts --no-autoloader
COPY . .
RUN composer dump-autoload --optimize --no-dev
Run it in CI
The schedule in this GitHub Actions job reports new advisories on days without commits:
name: composer audit
on:
push:
pull_request:
schedule:
- cron: "41 6 * * *"
jobs:
audit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- uses: shivammathur/setup-php@v2
with:
php-version: "8.5"
tools: composer:v2
- run: composer audit --locked --no-dev
In GitLab CI, the composer image is enough:
composer-audit:
image: composer:2.11.3
script:
- composer audit --locked --no-dev
What it does not cover
PHP itself, its extensions and the web server come from the operating system or the container base image and get their fixes there. WordPress, Drupal and other applications installed outside Composer keep their own lists of plugins and themes, which composer audit does not see.
The Vulnpocalypse agent reads the composer.lock of the app paths you configure, and Vulnpocalypse checks it against new advisories every day.
Sources
- Composer command-line interface:
auditoptions and exit codes,--no-blocking,--with-dependencies,--with-all-dependencies,why - Composer configuration: policy and audit:
policy.advisories.block,ignore-id, the deprecatedauditkeys,abandonedset tofailby default since 2.7 - composer image on Docker Hub: 2.11.3 as the current release
- GHSA-25mq-v84q-4j7r: Guzzle CVE-2022-31090, used in the example
Check your servers every day
The Vulnpocalypse agent reports the packages and settings of a server once a day, and the digest lists what to fix, most urgent first.