GCVE-1988-2026-0324
Vulnerability from gna-1988 – Published: 2026-09-11 07:55 – Updated: 2026-09-11 07:55| URL | Tags |
|---|---|
| https://vuln.freearchive.org/archive/full-disclos… | technical-descriptionexploit |
| https://seclists.org/fulldisclosure/2026/Jun/14 | technical-description |
| https://fereidani.com/contact | |
| https://fereidani.com/php-857-levenshtein-signed-… | |
| https://nmap.org/mailman/listinfo/fulldisclosure | |
| https://seclists.org/fulldisclosure/ |
{
"containers": {
"cna": {
"affected": [
{
"product": "PHP",
"vendor": "Php",
"versions": [
{
"status": "affected",
"version": "unknown"
}
]
}
],
"credits": [
{
"lang": "en",
"type": "finder",
"value": "Khashayar Fereidani"
}
],
"descriptions": [
{
"lang": "en",
"value": "# PHP 8.5.7 `levenshtein()` signed-integer overflow\n\n**Author:** Khashayar Fereidani\n**Disclosure Date:** 2026-06-18\n**Advisory:** https://fereidani.com/php-857-levenshtein-signed-integer-overflow\n**Contact:** https://fereidani.com/contact\n\n## Description\n\nThe `levenshtein()` function calculates the Levenshtein distance\nbetween two strings, optionally accepting custom costs for insertion,\nreplacement, and deletion operations. In PHP 8.5.7, the implementation\nlacks proper bounds checking for these cost parameters. When\nexceptionally large values (such as `PHP_INT_MAX`) are provided, the\narithmetic operations within the `reference_levdist()` function in\n`ext/standard/levenshtein.c` result in a signed-integer overflow. This\ntriggers undefined behavior in C and causes the function to return a\nnegative distance, which is mathematically invalid.\n\n## Proof of concept\n\n```php\n\u003c?php\n/*\n * levenshtein() signed-integer overflow\n * File: ext/standard/levenshtein.c reference_levdist() lines 47, 50, 53-58\n *\n * The user-supplied costs (cost_ins / cost_rep / cost_del, all zend_long) are\n * added with NO overflow check, e.g.:\n * p1[i2] = i2 * cost_ins; // line 47\n * p2[0] = p1[0] + cost_del; // line 50\n * c1 = p1[i2 + 1] + cost_del;// line 54 \u003c-- PHP_INT_MAX +\nPHP_INT_MAX\n * c2 = p2[i2] + cost_ins; // line 58\n *\n * Result: signed overflow (undefined behaviour in C) producing a\n * NEGATIVE edit distance, a value that is mathematically impossible.\n */\nvar_dump(levenshtein(\u0027a\u0027, \u0027b\u0027, PHP_INT_MAX, PHP_INT_MAX,\nPHP_INT_MAX)); // int(-2) (should be PHP_INT_MAX)\nvar_dump(levenshtein(\u0027a\u0027, \u0027abc\u0027, PHP_INT_MAX, PHP_INT_MAX,\nPHP_INT_MAX)); // int(-4)\nvar_dump(levenshtein(\u0027a\u0027, \u0027b\u0027, PHP_INT_MAX, 0,\nPHP_INT_MAX)); // int(-2)\necho \"All three distances are negative =\u003e signed overflow (expected \u003e= 0).\\n\";\n```\n\n## Impact\n\nThe primary risk associated with this vulnerability is an application\nlogic flaw. Applications that rely on the `levenshtein()` function to\ndetermine string similarity or calculate distance metrics might fail\nto handle negative returns properly (for instance, treating a negative\nnumber as `\u003c threshold`). This can result in unexpected behavior,\nincorrect data processing, or bypasses in business logic. Since it\ninvolves integer overflow producing a negative result rather than a\nmemory corruption issue, the scope is generally limited to logic\ndisruption rather than arbitrary code execution.\n\n## Solution\n\nTo effectively address this issue, bounds checking should be\nimplemented either on the cost parameters at the start of the\nfunction, or during intermediate calculations. Utilizing safe\narithmetic macros provided by the Zend Engine can prevent the integer\noverflow constraints from being violated:\n\n```c\n// Example: Adding overflow safeguards in ext/standard/levenshtein.c\nif (UNEXPECTED(ZEND_SIGNED_ADD_OVERFLOWS(p1[i2 + 1], cost_del))) {\n php_error_docref(NULL, E_WARNING, \"Levenshtein distance\ncalculation caused an integer overflow\");\n // Handle error, e.g., return -1 or cap\n}\n```\nAn alternative and proactive measure is to restrict the inputs for\n`cost_ins`, `cost_rep`, and `cost_del` before computing the distance,\nensuring that they wouldn\u0027t exceed `ZEND_LONG_MAX` when scaled\nrelative to the strings\u0027 lengths.\n_______________________________________________\nSent through the Full Disclosure mailing list\nhttps://nmap.org/mailman/listinfo/fulldisclosure\nWeb Archives \u0026 RSS: https://seclists.org/fulldisclosure/"
}
],
"providerMetadata": {
"dateUpdated": "2026-09-11T07:55:54Z",
"orgId": "4e2abfbf-4a2a-4b76-a4e0-d77c18ba156c",
"shortName": "VULNARCHIVE"
},
"references": [
{
"tags": [
"technical-description",
"exploit"
],
"url": "https://vuln.freearchive.org/archive/full-disclosure/2026/Jun/14"
},
{
"tags": [
"technical-description"
],
"url": "https://seclists.org/fulldisclosure/2026/Jun/14"
},
{
"url": "https://fereidani.com/contact"
},
{
"url": "https://fereidani.com/php-857-levenshtein-signed-integer-overflow"
},
{
"url": "https://nmap.org/mailman/listinfo/fulldisclosure"
},
{
"url": "https://seclists.org/fulldisclosure/"
}
],
"source": {
"defect": [
"https://seclists.org/fulldisclosure/2026/Jun/14"
],
"discovery": "EXTERNAL"
},
"title": "PHP 8.5.7 `levenshtein()` signed-integer overflow",
"x_gcve": [
{
"recordType": "advisory",
"relationships": [],
"vulnId": "GCVE-1988-2026-0324",
"x_vulnarchive": {
"archiveUrl": "https://vuln.freearchive.org/archive/full-disclosure/2026/Jun/14",
"automated": true,
"contentSha256": "54ccbc6a18fd6848395a0e5ccaba0bdf597e494673869b58873d3da2a33396eb",
"evidenceScore": 9,
"messageId": "",
"originalUrl": "https://seclists.org/fulldisclosure/2026/Jun/14",
"policy": "vulnarchive-1",
"sourceFormat": "text/html",
"sourcePublishedAt": "2026-06-19T06:26:09Z"
}
}
]
}
},
"cveMetadata": {
"assignerOrgId": "4e2abfbf-4a2a-4b76-a4e0-d77c18ba156c",
"assignerShortName": "VULNARCHIVE",
"datePublished": "2026-09-11T07:55:54Z",
"dateUpdated": "2026-09-11T07:55:54Z",
"state": "PUBLISHED",
"vulnId": "GCVE-1988-2026-0324"
},
"dataType": "CVE_RECORD",
"dataVersion": "5.2"
}
Drag nodes to arrange them. Double-click a related vulnerability to open it, or a source to visit its link. The Physics button on the left tunes the layout and the simulation; the legend at the bottom left hides or shows nodes by kind and by sighting type.
Sightings
| Author | Source | Type | Date | Other |
|---|
Nomenclature
- Seen: The vulnerability was mentioned, discussed, or observed by the user.
- Confirmed: The vulnerability has been validated from an analyst's perspective.
- Published Proof of Concept: A public proof of concept is available for this vulnerability.
- Exploited: The vulnerability was observed as exploited by the user who reported the sighting.
- Patched: The vulnerability was observed as successfully patched by the user who reported the sighting.
- Not exploited: The vulnerability was not observed as exploited by the user who reported the sighting.
- Not confirmed: The user expressed doubt about the validity of the vulnerability.
- Not patched: The vulnerability was not observed as successfully patched by the user who reported the sighting.
Vulnerability timeline
Sightings and recorded dates, grouped by day · UTC
How durations are calculated
Following the VTEM framework (Black Hat USA 2015), time to patch starts when the vendor or a coordinator was informed, total time to patch at discovery, and disclosure to patch at public disclosure; vendor response time runs from the report to its acknowledgement. Time to exploit and time unpatched start at the earliest discovery or report, falling back to public disclosure. Unpatched time ends at the first recorded patch, or the calculation time when no patch is recorded. Exploitation to patch shows the interval between those two events; a published proof of concept is a public exploit, not exploitation.
Each result shows its source dates. A negative interval means the end event came first; when date-only inputs leave the order open, the result says so. Date-only inputs are approximate. The earliest evidence wins: KEV report dates and sightings are labelled as such. Records describing another vulnerability are listed but never calculated from, and a PoC alone does not establish exploitation. Missing patch evidence does not prove that no patch exists. Filters below change the event list only.
Loading timeline…
The approach is described in our paper Mapping CVEs to MITRE ATT&CK Techniques: A Curated Gold-Set Classifier and the Limits of LLM-Assisted Label Expansion.
Browse all ATT&CK techniques and the vulnerabilities related to each.
Related by attack behaviour
Vulnerabilities whose description is nearest to this one in the vector space of the CIRCL/vulnerability-attack-technique-biencoder model. This is a similarity search over the bi-encoder space (plain cosine), not a classification, and it has no measured accuracy.