A malicious package can make Composer write files with content the attacker chooses anywhere Composer's user can write, outside vendor/ and outside your project. Written to the right place, such as a shell startup file, SSH authorized_keys or a cron entry, that can lead to running the attacker's code.
Composer didn't check that every package name was a valid vendor/package name before installing.
Who is affected
Projects that install packages from a third-party Composer repository that doesn't check package names itself. Look at the repositories section of your composer.json. The Composer advisory says Packagist.org and Private Packagist are safe because they validate names. It's a supply-chain risk: a malicious or compromised package has to be in your dependencies.
What to do
Update composer/composer to 2.10.2, or to 2.2.29 if you stay on 2.2. Composer 1.x is also affected, so move to one of those 2.x releases. The fix checks every resolved package name before anything is written to composer.lock or installed, and stops with a security error otherwise.
Until you can update, don't use untrusted package repositories. If you need one, Composer suggests mirroring it through an internal repository such as Private Packagist.
Reported by iliaal.