Laravel Known Dependency Vulnerabilities: How to Find and Fix Insecure Composer Packages

Your composer.lock contains packages with published security advisories. Update affected packages or apply patches before attackers exploit known CVEs.

High severity Application Security Updated 2026-05-01 Markdown

The PHP security advisory ecosystem tracks known vulnerabilities in open-source packages through two primary sources: the GitHub Advisory Database and the PHP Security Advisories Database maintained by FriendsOfPHP. Each advisory documents a specific vulnerability in a specific version range of a package, assigns a severity level, describes the impact, and identifies the fixed version. The composer audit command queries these databases against your installed package versions.

When a CVE is published for a PHP package, the exploit timeline is often measured in hours. Security researchers frequently publish proof-of-concept code alongside disclosures, and automated vulnerability scanners immediately begin probing the internet for applications running the vulnerable version. Attackers use tools like Shodan and Censys to identify Laravel applications by their HTTP response signatures, then cross-reference with published advisories to find applications that haven't updated. The window between advisory publication and exploitation is shrinking.

Real-world impact from unpatched dependencies ranges from information disclosure to remote code execution. CVE-2021-3129 in spatie/laravel-ignition, CVE-2018-15133 in laravel/framework (MAC check bypass enabling RCE), and multiple vulnerabilities in tymon/jwt-auth have all resulted in serious compromises of production Laravel applications. Running composer audit with zero advisories is a baseline requirement for production applications. Integrating it into CI ensures every pull request and deployment starts from a known-clean dependency state.

The Problem

PHP packages with known security vulnerabilities are published in the GitHub Advisory Database and the PHP Security Advisories Database. If your composer.lock pins a version with a known CVE, your application is vulnerable to published exploits. Attackers specifically target known vulnerabilities because the exploit details are public and the fix is documented — they just need to find applications that haven't updated yet.

How to Fix

  1. 1

    Check for known vulnerabilities

    Use Composer's built-in audit command:

    composer audit

    This checks your installed packages against the PHP Security Advisories Database and GitHub Advisory Database. It reports: - Package name and version - Advisory ID (CVE or GHSA) - Severity and description - Fixed version

  2. 2

    Update affected packages

    Update packages with known advisories:

    # Update a specific package
    composer update vendor/package --with-dependencies
    # Update all packages
    composer update
    # If a major version update is required
    composer require vendor/package:^2.0

    After updating, run your test suite to verify nothing breaks:

    php artisan test
  3. 3

    Handle packages that cannot be updated immediately

    If an update introduces breaking changes you cannot address immediately:

    1. Read the advisory to understand the attack vector 2. Implement a workaround or mitigation (e.g., input validation, WAF rule) 3. Create a ticket to track the update 4. Set a deadline — do not leave known vulnerabilities indefinitely

    For abandoned packages with no fix available, find an alternative:

    composer suggests --by-package vendor/package
  4. 4

    Add audit to your CI pipeline

    Add a step that fails the build on known advisories:
    # GitHub Actions
    - name: Security Audit
      run: composer audit --format=json
    # Or use Roave Security Advisories to prevent insecure installs
    composer require --dev roave/security-advisories:dev-latest

    This meta-package conflicts with any package that has a known advisory, preventing installation.

How to Verify

Run the audit and verify no advisories remain:

composer audit
# Output should be: No security vulnerability advisories found.

Run php artisan stackshield:scan --check=SS030 to verify.

Prevention

Run composer audit in CI on every pull request. Use Dependabot or Renovate to get automatic update PRs. Subscribe to the PHP Security Advisories mailing list. Pin exact versions in composer.json and update deliberately. Use StackShield to monitor dependencies continuously.

Frequently Asked Questions

How often should I run composer audit?

On every CI run and at least weekly for production applications. New advisories are published regularly. Dependabot or a similar tool can automate this by opening PRs when new advisories affect your dependencies.

What if the vulnerable package is a transitive dependency?

Use composer why vendor/vulnerable-package to find which of your direct dependencies requires it. Then update the direct dependency, which should pull in the fixed transitive version. If the direct dependency hasn't updated yet, open an issue on their repository.

What is the difference between composer audit and composer outdated?

composer audit checks your installed package versions against the PHP Security Advisory Database and reports only packages with published security vulnerabilities. composer outdated reports any package where a newer version is available, regardless of security implications. Both are useful: audit for security compliance, outdated for general maintenance hygiene. In CI, run composer audit --no-dev with a non-zero exit code on findings.

Should I run composer update during a CI deployment to production?

No. Production deployments should install from a lockfile using composer install --no-dev, not composer update. Updating during deployment introduces unreviewed package changes. Instead, run composer update in development, review the changes, commit the updated composer.lock, and deploy that lockfile. Run composer audit on the committed lockfile in your CI pipeline.

What is the roave/security-advisories package and how does it work?

roave/security-advisories is a Composer meta-package that conflicts with every package version listed in the PHP Security Advisory Database. Installing it with composer require --dev roave/security-advisories:dev-latest causes composer install to fail if any of your dependencies have a known advisory. This provides a hard block rather than a warning, preventing advisory-vulnerable packages from being installed at all.

Related Security Terms

Free security check

Is your Laravel app exposed right now?

34% of Laravel apps we scan have at least one critical issue. Most teams don't find out until something breaks. Our free scan checks your live application in under 60 seconds.

18% have debug mode on
72% missing security headers
12% have exposed .env
Scan My App Free No signup required. Results in 60 seconds.