Vulnerability DatabaseGHSA-m9j4-54gj-jvf8

GHSA-m9j4-54gj-jvf8: 
PHP vulnerability analysis and mitigation

Summary

league\csv CharsetConverter::filter() can accumulate an unbounded amount of input in memory and repeatedly revalidate the growing buffer when processing streams containing invalid multibyte sequences, resulting in quadratic CPU consumption and excessive memory usage.

Details

CharsetConverter::filter() validates the accumulated input with mb_check_encoding(). If validation fails and the stream is not closing, it stores the whole input in $this->buffer and returns PSFS_FEED_ME. The intent is to wait for the rest of a multibyte character split across two chunks. But a byte sequence that is invalid anywhere in the buffer, not just an incomplete character at its end, never becomes valid however much more data arrives. So one invalid byte near the start of a file makes the filter keep the entire rest of the stream in memory, and re-validate the growing buffer on every 8 KiB chunk, until EOF. No record is returned before that. CPU is O(n^2) and memory is a multiple of the file size. Offended source code: https://github.com/thephpleague/csv/blob/master/src/CharsetConverter.php#L267-L273

Proof of concept

Requires that you install league/csv and a huge file with invalid encoded characters is processed using the CharserConverter class as a stream filter.

  • Install league/csv (9.22+ release).
  • Convert a single large CSV document containing a single invalid character using CharserConverter as a stream filter implementing class.
  • Measure wall-clock time as the paragraph size doubles.
<?php
    use League\Csv\CharsetConverter;
    use League\Csv\Reader;
    $path = tempnam(sys_get_temp_dir(), 'csv');
    $h = fopen($path, 'wb');
    fwrite($h, "\xFF,x\n");                       // one byte that is invalid in UTF-8
    for ($i = 0; $i < 16_000; ++$i) {             // ~14.4 MB
        fwrite($h, str_repeat('abcdefgh,', 100)."\n");
    }
    fclose($h);
    $reader = Reader::from($path, 'r');
    CharsetConverter::addTo($reader, 'UTF-8', 'ISO-8859-1');
    $t = hrtime(true);;
    foreach ($reader as $record) { break; }       // first record only
    printf("%.1f s, %.1f MB peak\n", hrtime(true) - $t, memory_get_peak_usage() / 1e6);

Impact

Type of vulnerability: Denial of Service (DoS) due to uncontrolled resource consumption (CWE-400). Who is impacted: Applications using the CharsetConverter stream filter from the League\Csv library to process untrusted or malformed input streams. An attacker able to supply a crafted input stream containing invalid multibyte character sequences can cause the filter to accumulate an ever-growing buffer and repeatedly validate it. This results in quadratic CPU consumption and excessive memory usage, potentially exhausting the application's available resources. The vulnerability can affect application availability and may cause significant performance degradation or process termination due to memory exhaustion.


Source: NVD

Related PHP vulnerabilities:

CVE ID

Severity

Score

Technologies

Component name

CISA KEV exploit

Has fix

Published date

GHSA-hx92-2qxg-m977HIGH7.8
  • PHP logoPHP
  • ray/aop
NoYesNov 21, 2026
GHSA-p5q8-69rj-ff33HIGH7.8
  • PHP logoPHP
  • ray/di
NoYesNov 21, 2026
GHSA-vpqj-26g5-4qqmHIGH7.4
  • PHP logoPHP
  • simplesamlphp/saml2
NoNoNov 22, 2026
GHSA-2g6w-c7gx-fxj8MEDIUM5.4
  • PHP logoPHP
  • guzzlehttp/guzzle
NoYesNov 21, 2026
GHSA-m9j4-54gj-jvf8MEDIUM5.3
  • PHP logoPHP
  • league/csv
NoYesNov 22, 2026

Free Vulnerability Assessment

Benchmark your Cloud Security Posture

Evaluate your cloud security practices across 9 security domains to benchmark your risk level and identify gaps in your defenses.

Request assessment

Additional Wiz resources

Get a personalized demo

Ready to see Wiz in action?

"Best User Experience I have ever seen, provides full visibility to cloud workloads."
David EstlickCISO
"Wiz provides a single pane of glass to see what is going on in our cloud environments."
Adam FletcherChief Security Officer
"We know that if Wiz identifies something as critical, it actually is."
Greg PoniatowskiHead of Threat and Vulnerability Management