sansec/composer-integrity-plugin

Installs: 12 964

Dependents: 1

Suggesters: 0

Security: 0

Stars: 42

Watchers: 2

Forks: 4

Open Issues: 2

Type:composer-plugin

0.2.1 2023-05-01 09:22 UTC

This package is auto-updated.

Last update: 2024-12-02 23:43:29 UTC


README

Check your installed composer packages against a list of known correct checksums (provided by Sansec).

This plugin calculates a one-way hash of:

  • composer.json and composer.lock
  • package name and package versions
  • file contents of the installed packages (checksum)

These hashes are then tested against a larger database hosted at Sansec. The use of one-way hashing provides a secure way to test your setup, without sharing file contents with a third party. The Sansec API does not store your hashes.

image

Installation & Usage

Composer Plugin

composer require sansec/composer-integrity-plugin

You can then run it:

composer integrity

PHAR

Head over to the releases page and download the latest PHAR.

You can then run it:

php composer-integrity.phar

Configuration

Both the plugin as well as the PHAR take the following optional options:

  • --skip-match: shows only non-matching checksums
  • --json: output is in json format instead of a table

Why did we make this?

Sansec specializes in forensic investigations of breached Magento stores. We noticed an increase of cases where malware was hidden in legitimate libraries under vendor. Most package managers provide some sort of integrity check for installed software, but composer does not. So, we made this plugin in order to quickly verify the integrity of an installation.

Alternatively, you could clone the composer files, recreate vendor and run a diff against your installation. But this takes much more time and original dependencies are not always available on production servers.

Caveats

The plugin does not consider patches, such as those applied through composer-patches, via a post-install-cmd composer script, or editing in vendor outright.

In such instances, it is the user's responsibility to assess the situation and take appropriate action.

License

MIT License - Copyright (c) 2023 Sansec