{"id":"CVE-2022-23598","aliases":["GHSA-jq4p-mq33-w375"],"url":"https://o3.security/vulnerability/CVE-2022-23598","summary":"Reflected XSS vulnerability when rendering error messages in laminas-form","details":"### Impact\n\nWhen rendering validation error messages via the `formElementErrors()` view helper shipped with laminas-form, many messages will contain the submitted value. However, in vulnerable versions of laminas-form, the value was not being escaped for HTML contexts, which can potentially lead to a Reflected Cross-Site Scripting (XSS) attack.\n\n### Patches\n\nThe following versions were issued to mitigate the vulnerability:\n\n- 2.17.1\n- 3.0.2\n- 3.1.1\n\n### Workarounds\n\nAt the top of a view script where you call the `formElementErrors()` view helper, place the following code:\n\n```php\nuse Laminas\\Form\\ElementInterface;\nuse Laminas\\View\\PhpRenderer;\n\n$escapeMessages = function (ElementInterface $formOrElement, PhpRenderer $renderer): void {\n    $messages = $element->getMessages();\n    if (! $messages) {\n        return;\n    }\n\n    $escaped  = [];\n    array_walk_recursive(\n        $messages,\n        static function (string $item) use (&$escaped, $renderer): void {\n            $escaped[] = $renderer->escapeHtml($item);\n        }\n    };\n\n    $element->setMessages($escaped);\n};\n```\n\nBefore calling `formElementErrors()` with a form, fieldset, or element, call the above closure as follows\n\n```php\n// Usage with a form\n// $this is the view renderer\n$escapeMessages($form, $this);\n\n// Usage with a fieldset\n// $this is the view renderer\n$escapeMessages($fieldset, $this);\n\n// Usage with a form element\n// $this is the view renderer\n$escapeMessages($element, $this);\n```\n\n### For more information\n\nIf you have any questions or comments about this advisory:\n\n* [Open an issue](https://github.com/laminas/laminas-form/issues/new)\n* Email us at [security@getlaminas.org](mailto:security@getlaminas.org)","published":"2022-01-28T22:00:16Z","modified":"2026-08-12T03:51:40.330711805Z","cvss":{"score":6.1,"severity":"MEDIUM","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N"},"epss":{"score":0.00989,"percentile":0.59337,"asOf":"2026-08-23"},"cisaKev":null,"exploitsKnown":1,"affectedPackages":[{"ecosystem":"Packagist","name":"laminas/laminas-form","fixedVersion":"3.1.1"},{"ecosystem":"Packagist","name":"laminas/laminas-form","fixedVersion":"3.0.2"},{"ecosystem":"Packagist","name":"laminas/laminas-form","fixedVersion":"2.17.1"}],"fix":{"url":"https://github.com/laminas/laminas-form/commit/43005a3ec4c2292d4f825273768d9b884acbca37","label":"laminas/laminas-form@43005a3"},"references":[{"type":"ADVISORY","url":"https://getlaminas.org/security/advisory/LP-2022-01"},{"type":"ADVISORY","url":"https://github.com/CVEProject/cvelistV5/tree/main/cves/2022/23xxx/CVE-2022-23598.json"},{"type":"ADVISORY","url":"https://github.com/laminas/laminas-form/security/advisories/GHSA-jq4p-mq33-w375"},{"type":"ADVISORY","url":"https://lists.fedoraproject.org/archives/list/package-announce%40lists.fedoraproject.org/message/CFF6WJ5I7PSEBRF6I753WKE2BXFBGQXE/"},{"type":"ADVISORY","url":"https://lists.fedoraproject.org/archives/list/package-announce%40lists.fedoraproject.org/message/SLNABVK26CE4PFL57VLY242FW3QY4CPC/"},{"type":"ADVISORY","url":"https://nvd.nist.gov/vuln/detail/CVE-2022-23598"},{"type":"FIX","url":"https://github.com/laminas/laminas-form/commit/43005a3ec4c2292d4f825273768d9b884acbca37"},{"type":"WEB","url":"https://github.com/laminas/laminas-form"},{"type":"WEB","url":"https://github.com/laminas/laminas-form/releases/tag/2.17.1"},{"type":"WEB","url":"https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/CFF6WJ5I7PSEBRF6I753WKE2BXFBGQXE"},{"type":"WEB","url":"https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/SLNABVK26CE4PFL57VLY242FW3QY4CPC"}],"provenance":{"sources":["OSV.dev","FIRST.org (EPSS)"],"lastVerified":"2026-08-12T03:51:40.330711805Z"}}