A PHP dependency vulnerabilities scanner based on the Security Advisories Database.

Overview

Enlightn Security Checker

tests MIT Licensed Latest Stable Version Total Downloads

The Enlightn Security Checker is a command line tool that checks if your application uses dependencies with known security vulnerabilities. It uses the Security Advisories Database.

Installation Options

  1. You may install the Enlightn Security Checker with Composer globally, for use with multiple projects:
composer global require enlightn/security-checker
  1. You may also install the Enlightn Security Checker in your project as a dev dependency using Composer:
composer require --dev enlightn/security-checker
  1. Instead of installing via Composer, you may also download the security-checker.phar file. Then, in the commands below you can replace security-checker with security-checker.phar.

Usage

To check for security vulnerabilities in your dependencies, you may run the security:check command:

php security-checker security:check /path/to/composer.lock

This command will return a success status code of 0 if there are no vulnerabilities and 1 if there is at least one vulnerability.

Note: You would need to provide the full path of the security-checker executable if the directory is not in your path. For instance:

php vendor/bin/security-checker security:check /path/to/composer.lock

Options

Format

By default, this command displays the result in ANSI. You may use the --format option to display the result in JSON instead:

php security-checker security:check /path/to/composer.lock --format=json

Exclude Dev Dependencies

If you would like to exclude dev dependencies from the vulnerabilities scanning, you may use the --no-dev option (defaults to false):

php security-checker security:check /path/to/composer.lock --no-dev

Allow vulnerabilities

If you would like to exclude some vulnerabilities, you may use the --allow-list option by passing the CVE identifier, or the CVE title. You can pass multiple values as well:

php security-checker security:check /path/to/composer.lock --allow-list CVE-2018-15133 --allow-list "untrusted X-XSRF-TOKEN value"

Do not forget to wrap the title with quotes

Custom Directory for Caching Advisories Database

By default, the SecurityChecker API and the security:check command use the directory returned by the sys_get_temp_dir PHP function for storing the cached advisories database. If you wish to modify the directory, you may use the --temp-dir option:

php security-checker security:check /path/to/composer.lock --temp-dir=/tmp

API

You may also use the API directly in your own code like so:

use Enlightn\SecurityChecker\SecurityChecker;

$result = (new SecurityChecker)->check('/path/to/composer.lock');

The result above is an associative array. The key is the package name and the value is an array of vulnerabilities based on your package version. An example of the JSON encoded version is as below:

{
  "laravel/framework": {
    "version": "8.22.0",
    "time": "2021-01-13T13:37:56+00:00",
    "advisories": [{
      "title": "Unexpected bindings in QueryBuilder",
      "link": "https://blog.laravel.com/security-laravel-62011-7302-8221-released",
      "cve": null
    }]
  }
}

Contribution Guide

Thank you for considering contributing to the Enlightn security-checker project! The contribution guide can be found here.

License

The Enlightn security checkers licensed under the MIT license.

Comments
  • feature request: add a way to whitelist security issues

    feature request: add a way to whitelist security issues

    Sometimes the real world happens, and you want to whitelist a security issue. There are multiple valid reasons for doing this like for example the code path with the vulnerability isn't reachable

    i would think something like would work, --whitelist identifier where identifier could be a CVE or GHSA or other ID

    enhancement help wanted 
    opened by mjrider 6
  • Permission failure when using this package with multiple users on the same server

    Permission failure when using this package with multiple users on the same server

    Hello,

    I am using this package through https://github.com/Jorijn/laravel-security-checker . When using this package on one server with multiple users(user1, user2), user1 is the owner of the file /tmp/php_security_advisories.json. So any attempt to run the security checker with user2 gives me a 'Permission Denied'.

    user1 works completely as expected. user2 gets the following error:

    file_put_contents(/tmp/php_security_advisories.json): failed to open stream: Permission denied. vendor/enlightn/security-checker/src/AdvisoryFetcher.php:138

    Possible solution: Maybe the library on user1 could delete the files when its done with them, so user2 can put the required files there when it needs to.

    Best regards, Thomas

    enhancement 
    opened by thomasderoo4 4
  • Phar autoloader cannot find class Symfony\Component\Process\ExecutableFinder;

    Phar autoloader cannot find class Symfony\Component\Process\ExecutableFinder;

    Downloaded latest phar file. Attempting to execute with php ./security-checker.phar security:check ./composer.lock --no-dev --temp-dir=/tmp. It fails with message:

    PHP Fatal error:  Uncaught Error: Class 'Symfony\Component\Process\ExecutableFinder' not found in phar:///apps/foobar/security-checker.phar/src/ZipExtractor.php:39
    Stack trace:
    #0 phar:///apps/foobar/security-checker.phar/src/ZipExtractor.php(19): Enlightn\SecurityChecker\ZipExtractor->unzipCommandExists()
    #1 phar:///apps/foobar/security-checker.phar/src/AdvisoryFetcher.php(44): Enlightn\SecurityChecker\ZipExtractor->extract()
    #2 phar:///apps/foobar/security-checker.phar/src/SecurityChecker.php(25): Enlightn\SecurityChecker\AdvisoryFetcher->fetchAdvisories()
    #3 phar:///apps/foobar/security-checker.phar/src/SecurityCheckerCommand.php(64): Enlightn\SecurityChecker\SecurityChecker->check()
    #4 phar:///apps/foobar/security-checker.phar/vendor/symfony/console/Command/Command.php(256): Enlightn\SecurityChecker\SecurityCheckerCommand->execute()
    #5 phar:///apps/foobar/security-checker.phar/vendor/symfony/console/Application.php(971): Symfony\Component\Console\Command\Command->run()
    #6 phar:///apps/foobar/security-checker.phar/vendor/symfony/console/Applicatio in phar:///apps/rti/security-checker.phar/src/ZipExtractor.php on line 39
    

    Source OS is Ubuntu 20.04LTS. Local PHP cli version is:

    PHP 7.4.21 (cli) (built: Jul  1 2021 16:09:23) ( NTS )
    Copyright (c) The PHP Group
    Zend Engine v3.4.0, Copyright (c) Zend Technologies
        with Zend OPcache v7.4.21, Copyright (c), by Zend Technologies
    

    Tested with and without Ubuntu unzip package installed. Thoughts?

    bug 
    opened by codeguy 3
  • Security check does not work properly with

    Security check does not work properly with "dev" packages

    The problem is that all occurrences of "v" in the version string are replaced by nothing. This leads to the version "dev-master" becoming "de-master": https://github.com/enlightn/security-checker/blob/ba15c4cc33499f2652f788273b7cf73cc174e7dc/src/Composer.php#L38

    And therefore the implemented comparison in "isDevPackage" never matches: https://github.com/enlightn/security-checker/blob/ba15c4cc33499f2652f788273b7cf73cc174e7dc/src/AdvisoryAnalyzer.php#L109

    Apart from that, the ending delimiter is missing in this regular expression: https://github.com/enlightn/security-checker/blob/ba15c4cc33499f2652f788273b7cf73cc174e7dc/src/AdvisoryAnalyzer.php#L42

    bug 
    opened by sharpcode-mthaler 3
  • Replace `curl -sS https://getcomposer.org/installer | php` with link to docs?

    Replace `curl -sS https://getcomposer.org/installer | php` with link to docs?

    First of all: thank you very much for making this available! In lieu of the Sensiolabs deprecation, it is much appriciated. 🙌

    Now, to my issue...

    The security-checker CLI file contains a line prompting people to run curl -sS https://getcomposer.org/installer | php.

    For a security package, I find this in rather poor judgment.

    I would strongly suggest that it would be better to just direct users to https://getcomposer.org/download/ and ask them to follow the instructions there.

    Security issues aside, it can be confusing for users, as composer might be installed but simply not (yet) have run.

    Less experienced users are likely to follow the suggestion ad-verbatim, which could lead to all sorts of trouble (which could easily be avoided by educating the user via the Composer install guide).

    If you concur, I don't mind following up with an MR to make this happen.

    enhancement 
    opened by Potherca 3
  • Updated phar available?

    Updated phar available?

    Has the phar version at https://www.laravel-enlightn.com/security-checker.phar been updated to the latest version?

    I'm running it on PHP 8.1.2 and getting:

    Fatal error: Uncaught Error: Class "Symfony\Component\Process\ExecutableFinder" not found in phar:///Users/myuser/myapp/php-security-checker/src/ZipExtractor.php:39
    
    opened by ejunker 2
  • Fix --no-dev input option

    Fix --no-dev input option

    Just realized that the --no-dev option added today in https://github.com/enlightn/security-checker/pull/14 needs to be VALUE_NONE for it to work. This PR fixes the bug.

    bug 
    opened by paras-malhotra 2
  • Give some output in case no vulnerabilities are found

    Give some output in case no vulnerabilities are found

    Like "No known security vulnerabilities found.✓"

    At least with one of the verbosity options.

    Otherwise you don't knot if the command did something at all.

    enhancement 
    opened by oliworx 2
  • Add allow list option to exclude vulnerabilities by CVE or title

    Add allow list option to exclude vulnerabilities by CVE or title

    Closes #20.

    This feature allow a list of vulnerabilities to be ignored when checking.

    Use:

    php security-checker security:check /path/to/composer.lock --allow-list CVE-2018-15133 --allow-list "untrusted X-XSRF-TOKEN value"
    

    Some vulnerabilities does not have the CVE code, for these we can pass the title as shown in the example

    There where no breaking changes since i just added a option to the command and all tests are passing

    enhancement 
    opened by jleonardolemos 1
  • Add option to exclude dev dependencies from scanning

    Add option to exclude dev dependencies from scanning

    Hey there,

    Thanks very much for this tool firstly.

    Secondly, I've made a small change (+ tests) to add an optional flag on the CLI, to wire up the existing excludeDev flag that existed under the hood.

    I used --no-dev to match the composer flag for install.

    I've tried to make sure it makes sense, let me know what you think.

    enhancement 
    opened by mikeyjk 1
  • Drop ext-zip requirement via unzip command

    Drop ext-zip requirement via unzip command

    This PR drops the ext-zip requirement by introducing a ZipExtractor class. This class extracts the zip using the unzip command (if it exists) and deferring to the ZipArchive (requiring ext-zip) if it doesn't.

    If both the unzip command and ext-zip don't exist, it throws a RuntimeException. It is unlikely that both don't exist as Composer itself needs either of them to work properly.

    enhancement 
    opened by paras-malhotra 0
  • Use http client discovery

    Use http client discovery

    The security checker now has a hard dependency on guzzlehttp/guzzle, which unfortunately had a few security issues in the last weeks. So even when not using guzzlehttp in your application, this would generate a security warning.

    By following https://docs.php-http.org/en/latest/httplug/library-developers.html we implemented ClientDiscovery so an existing PSR-18 compatible HTTP client (i.e. symfony/http-client) could be reused.

    Unfortunately this is not possible while keeping PHP 5.6 support because psr/http-factory requires >= 7.0.

    Is this acceptable for a 1.11 release or should it target a 2.0 release? composer.json must be updated according to this choice..

    See https://github.com/enlightn/security-checker/pull/29

    opened by arjenschol 0
  • Use http client discovery

    Use http client discovery

    The security checker now has a hard dependency on guzzlehttp/guzzle, which unfortunately had a few security issues in the last weeks. So even when not using guzzlehttp in your application, this would generate a security warning.

    By following https://docs.php-http.org/en/latest/httplug/library-developers.html we implemented ClientDiscovery so an existing PSR-18 compatible HTTP client (i.e. symfony/http-client) could be reused.

    Unfortunately this is not possible while keeping PHP 5.6 support because psr/http-factory requires >= 7.0.

    Is this acceptable for a 1.11 release or should it target a 2.0 release? composer.json must be updated according to this choice..

    opened by arjenschol 1
  • Force extension with --use-ext

    Force extension with --use-ext

    Closes #22

    Add an --use-ext option in order to provide a way to force a specific zip tool as the follow:

    php security-checker security:check /path/to/composer.lock --use-ext system-unzip
    

    We can use system-unzip force system unzip command and zip-extension to force PHP Zip Extension and any other option will be silently ignored.

    Some considerations:

    1. If we chose for zip-extension explicitly and the zip extension is not installed than an exception will be thrown, should it be handled?
    2. If we chose for system-unzip explicitly and the unzip command does not exists than an error will happen, should it be handled?
    3. Because the classes are very coupled with the new operator i was not able to test very well without very clumsy mock strategies, i just wrote a test to ensure that ti code is running fine and nothing is broken.
    enhancement 
    opened by jleonardolemos 1
  • Unzip problems with v1.8.0+

    Unzip problems with v1.8.0+

    Hi,

    This change has broken this tool for me.

    I am using the php:7.1-fpm-alpine Docker image and trying to run the security-checker fails with the following error:

    image

    v1.7.0 works fine:

    image

    I presume the problem is that the version of unzip within BusyBox cannot handle the zip file:

    image

    Because it works fine on the unzip command in my host OS (Ubuntu 20.04

    Cheers!

    Dan

    enhancement help wanted 
    opened by danherd 12
Releases(v1.10.0)
Owner
Enlightn
Your performance/security consultant, an artisan command away
Enlightn
Dobren Dragojević 6 Jun 11, 2023
FUGIO: Automatic Exploit Generation for PHP Object Injection Vulnerabilities

FUGIO FUGIO is the first automatic exploit generation (AEG) tool for PHP object injection (POI) vulnerabilities. When exploiting a POI vulnerability,

KAIST Web Security and Privacy Lab 53 Dec 23, 2022
A story about SQLinject and a demonstration of some vulnerabilities and tools

Предысловие Если не умру,буду дальше развивать эту тему Идея которая пришла мне в голову,<<А почему бы не рассказать об уязвимостях SQL?>>.Поэтому я б

null 0 Jun 11, 2022
Scanner, signatures and the largest collection of Magento malware

Improved malware scanner now available Good news: our opensource malware scanner "mwscan" has been succeeded by a much better one called eComscan. It

Willem de Groot 651 Dec 6, 2022
A simple, type-safe, zero dependency port of the javascript fetch WebApi for PHP.

A simple, type-safe, zero dependency port of the javascript fetch WebApi for PHP.

Matias Navarro Carter 105 Jan 4, 2023
Dependency graph visualization for composer.json (PHP + Composer)

clue/graph-composer Graph visualization for your project's composer.json and its dependencies: Table of contents Usage graph-composer show graph-compo

Christian Lück 797 Jan 5, 2023
Detect flaws in your architecture, before they drag you down into the depths of dependency hell ...

Detect flaws in your architecture before they drag you down into the depths of dependency hell ... What it does System Requirements Installation Phive

Michael Haeuslmann 507 Dec 27, 2022
🪃 Zero-dependency global `kirbylog()` helper for any content

Kirbylog The most simple, Kirby-esque way to log content to file. Most of the time, I just want to log some string or array to a file. That's what thi

Johann Schopplich 11 Nov 9, 2022
Library for check dependency between modules inside projects

PHP Dependency analyzer PHP DA is tool for check and support dependencies inside your project clear. For example: You have project with 3 root namespa

Kir Apukhtin 12 Nov 15, 2022
An installer package that let's you install NodeJS and NPM as a Composer dependency.

NodeJS installer for Composer This is an installer that will download NodeJS and NPM and install them in your Composer dependencies. Installation is s

TheCodingMachine 106 Sep 30, 2022
A small CLI tool to check missing dependency declarations in the composer.json and module.xml

Integrity checker Package allows to run static analysis on Magento 2 Module Packages to provide an integrity check of package. Supported tools: Compos

run_as_root GmbH 13 Dec 19, 2022
Simple, single-file and dependency-free AWS S3 client.

Simple, single-file and dependency-free AWS S3 client. Why? In some scenarios we want the simplest and lightest S3 client possible. For example in Bre

Matthieu Napoli 28 Nov 15, 2022
This project processes a small database with php all on a web server. This project uses XAMPP to run the web server and the database.

PHP-introduction This project processes a small database with php all on a web server. This project uses XAMPP to run the web server and the database.

Tyler Jacques 1 Jan 6, 2022
A PHP MySQL database client class to simplify database access

This lightweight database class is written with PHP and uses the MySQLi extension, it uses prepared statements to properly secure your queries, no need to worry about SQL injection attacks.

Khader Handal 50 Jul 30, 2022
[READ-ONLY] CakePHP Utility classes such as Inflector, Text, Hash, Security and Xml. This repo is a split of the main code that can be found in https://github.com/cakephp/cakephp

CakePHP Utility Classes This library provides a range of utility classes that are used throughout the CakePHP framework What's in the toolbox? Hash A

CakePHP 112 Feb 15, 2022
Here are few exercises to practice how to implement API Security with NGINX App-Protect WAF.

api-security-lab This repo contains files for customers and partners to practice an API Security with NGINX App-Protect WAF. To demonstrate the capabi

null 4 Mar 30, 2022
Your performance & security consultant, an artisan command away.

Enlightn A Laravel Tool To Boost Your App's Performance & Security Introduction Think of Enlightn as your performance and security consultant. Enlight

Enlightn 726 Jan 1, 2023
A curated list of resources for learning about application security

Awesome AppSec A curated list of resources for learning about application security. Contains books, websites, blog posts, and self-assessment quizzes.

Paragon Initiative Enterprises 5.4k Jan 7, 2023
Harden request headers, login interface and passwords to increase backend security.

JvMTECH.NeosHardening Package for Neos CMS Harden request headers, login interface and passwords to increase backend security. Installation composer r

Jung von Matt TECH 3 May 4, 2022