The vulnerability lies in Composer's handling of output displayed in the terminal. Data from remote sources, such as security advisories or package information, could contain ANSI escape sequences. When Composer commands rendered this data, these sequences were not sanitized, allowing them to be interpreted by the user's terminal. This could lead to garbled output, UI confusion, or a denial-of-service condition on the terminal application.
The patch addresses this by introducing a new static method, Composer\IO\ConsoleIO::sanitize(), which is designed to strip ANSI escape codes and other control characters from strings. This sanitization function is then applied proactively in multiple locations:
write() and writeError() methods in ConsoleIO now sanitize all messages before they are printed, providing a broad layer of protection.ask, askConfirmation, select, etc.) now sanitize the question text and any default values or choices that are displayed.outputAdvisoriesTable) and abandoned package information (outputAbandonedPackages) now explicitly sanitize the data before rendering it in tables.By implementing this output sanitization, the patch ensures that potentially malicious control characters from external sources are neutralized before they can affect the user's terminal, effectively mitigating the vulnerability.
Composer\Advisory\Auditor::outputAdvisoriesTablesrc/Composer/Advisory/Auditor.php
Composer\Advisory\Auditor::outputAbandonedPackagessrc/Composer/Advisory/Auditor.php
Composer\IO\ConsoleIO::writesrc/Composer/IO/ConsoleIO.php
Composer\IO\ConsoleIO::writeErrorsrc/Composer/IO/ConsoleIO.php
Composer\IO\ConsoleIO::asksrc/Composer/IO/ConsoleIO.php
Composer\IO\ConsoleIO::askConfirmationsrc/Composer/IO/ConsoleIO.php
Composer\IO\ConsoleIO::askAndValidatesrc/Composer/IO/ConsoleIO.php
Composer\IO\ConsoleIO::askAndHideAnswersrc/Composer/IO/ConsoleIO.php
Composer\IO\ConsoleIO::selectsrc/Composer/IO/ConsoleIO.php
| Package Name | Ecosystem | Vulnerable Versions | First Patched Version |
|---|---|---|---|
| composer/composer | composer | >= 2.0.0, < 2.2.26 | 2.2.26 |
| composer/composer | composer | >= 2.3.0, < 2.9.3 | 2.9.3 |
A Semantic Attack on Google Gemini - Read the Latest Research