Skip to content

Packagist

The main repository of PHP packages, which Composer installs from.

  • Registries

About

Packagist is the main public repository for PHP packages, and Composer is the tool that installs them. Laravel apps are built largely from it, and many WordPress plugins bundle its packages inside them. Packagist lists each package, but the code itself is fetched from the project's own source repository.

While it installs, Composer runs your project's own scripts and any plugins you allow, with the rights of whoever runs it. Other packages run inside the app when PHP loads them, on every request.

If It Is Malicious

If a Composer package is malicious, it runs inside a PHP app with the app's rights, on every server and build that installs it.

Its code runs inside these technologies.

See It in the Stack

Examples

These are well-known names from Packagist, written as you would meet them in an inventory, an alert or a lockfile, the file that records every version a build installed.

laravel/framework
The Laravel framework itself.
guzzlehttp/guzzle
The HTTP client a great many PHP apps use.
monolog/monolog
Logging for PHP, used by Laravel and Symfony.
symfony/console
Command-line building blocks, used by Laravel and by Composer itself.
phpunit/phpunit
The standard test framework, installed for development.

How Bad Code Gets In

These are the ways bad code can reach your systems through Packagist. None of them needs a flaw in your own code, so outside code needs checking as much as your own.

  • A maintainer's account is taken over and the package is pointed at a different source repository.
  • A project's source repository is deleted or renamed, and its old address later serves someone else's code.
  • A package named like a popular one catches careless installs.
  • A Composer plugin runs code during install on every machine that allows it.

How to Check

These checks show what came from Packagist, whether a known bad version is in use, and how to keep one out next time.

  • Commit composer.lock and install from it in every build.
  • Run composer audit, which checks installed packages against known advisories.
  • Keep allow-plugins to the plugins you trust, so no other package runs code at install.
  • Serve the packages you use from a private repository, such as Private Packagist or Satis.

Well-Known Incidents

Each incident below is a real case, told at the level of its public advisory. The tag says how the bad code got in, and the link opens the primary source.

  • Hijacked Account2023

    Packagist Account Takeover

    An attacker got into four inactive maintainer accounts, likely with passwords leaked on other sites, and pointed their packages at copies of the code under the attacker's control.

    Reach Fourteen packages were pointed elsewhere, Doctrine ones among them. The copies only changed a description, so no bad code went out.

    Affecteddoctrine/instantiatoracmephp/corejdorn/sql-formatter

    Source: blog.packagist.com (opens in a new tab)

In Common Stacks

These common stacks take code from Packagist. Open one to see where that code sits among its layers and who runs each one.

Sources

Product names and logos are trademarks of their owners, shown only to name each product, with no endorsement implied. npm is a registered trademark of npm, Inc.

Apache, Apache HTTP Server, Tomcat and Log4j are trademarks of the Apache Software Foundation. Node.js® is a registered trademark of the OpenJS Foundation, and Kubernetes® of LF Projects, LLC.

Linux® is the registered trademark of Linus Torvalds in the U.S. and other countries. Docker and the Docker logo are trademarks or registered trademarks of Docker, Inc. in the United States and/or other countries.

MongoDB® is a registered trademark of MongoDB, Inc. Redis® is a registered trademark of Redis Ltd. Any rights therein are reserved to Redis Ltd.

PHP logo by Colin Viebrock, CC BY-SA 4.0 (opens in a new tab). Ruby logo © 2006 Yukihiro Matsumoto, CC BY-SA 2.5 (opens in a new tab). Tux by Larry Ewing, with Garrett LeSage and IFo Hancroft.

Puma logo © Evan Phoenix and contributors, CC BY-ND 3.0 (opens in a new tab). NuGet logo from NuGet's Media repository, CC BY 2.0 (opens in a new tab).

Gunicorn logo © Benoît Chesneau and Paul J. Davis, MIT licence for the Gunicorn logo (opens in a new tab). Packagist logo © 2011 Jordi Boggiano and Nils Adermann, MIT licence for the Packagist logo (opens in a new tab).

MIT Licence Notices for the Gunicorn and Packagist Logos

Gunicorn logo

2009-2024 (c) Benoît Chesneau <benoitc@gunicorn.org> 2009-2015 (c) Paul J. Davis <paul.joseph.davis@gmail.com>

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Packagist logo

Copyright (c) 2011 Jordi Boggiano, Nils Adermann

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.