{"id":"CVE-2022-23598","aliases":["CVE-2022-23598","GHSA-jq4p-mq33-w375"],"related":[],"kind":"vulnerability","state":"published","title":"Reflected XSS vulnerability when rendering error messages in laminas-form","summary":"laminas-form is a package for validating and displaying simple and complex forms. When rendering validation error messages via the `formElementErrors()` view helper shipped with laminas-form, many messages will contain the submitted value. However, in laminas-form prior to version 3.1.1, the value was not being escaped for HTML contexts, which could potentially lead to a reflected cross-site scripting attack. Versions 3.1.1 and above contain a patch to mitigate the vulnerability. A workaround is available. One may manually place code at the top of a view script where one calls the `formElementErrors()` view helper. More information about this workaround is available on the GitHub Security Advisory.","summarySource":"cvelist","descriptions":[{"lang":"en","text":"laminas-form is a package for validating and displaying simple and complex forms. When rendering validation error messages via the `formElementErrors()` view helper shipped with laminas-form, many messages will contain the submitted value. However, in laminas-form prior to version 3.1.1, the value was not being escaped for HTML contexts, which could potentially lead to a reflected cross-site scripting attack. Versions 3.1.1 and above contain a patch to mitigate the vulnerability. A workaround is available. One may manually place code at the top of a view script where one calls the `formElementErrors()` view helper. More information about this workaround is available on the GitHub Security Advisory.","source":"cvelist"},{"lang":"en","text":"### 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)","format":"markdown","source":"ghsa"},{"lang":"es","text":"laminas-form es un paquete para la comprobación y visualización de formularios simples y complejos. Cuando son mostrados los mensajes de error de comprobación por medio del ayudante de vista \"formElementErrors()\" incluido en laminas-form, muchos mensajes contienen el valor enviado. Sin embargo, en laminas-form versiones anteriores a 3.1.1, el valor no es escapado para los contextos HTML, lo que potencialmente podía conllevar a un ataque de tipo Cross-site scripting reflejado. Las versiones 3.1.1 y superiores contienen un parche para mitigar la vulnerabilidad. Se presenta una solución disponible. Puede colocarse manualmente un código en la parte superior de un script de visualización donde es llamado al ayudante de visualización \"formElementErrors()\". Se presenta más información sobre esta medida de mitigación en el aviso de seguridad de GitHub","source":"nvd"}],"published":"2022-01-28T22:00:16.000Z","modified":"2026-06-17T04:30:26.860Z","severity":{"scorer":"GitHub_M","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N","score":6.1,"rating":"MEDIUM"},"severities":[{"scorer":"GitHub_M","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N","score":6.1,"rating":"MEDIUM"},{"scorer":"GitHub","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N","score":6.1,"rating":"MEDIUM"},{"scorer":"NVD","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N","score":6.1,"rating":"MEDIUM"},{"scorer":"NVD","scheme":"CVSS:2.0","vector":"AV:N/AC:M/Au:N/C:N/I:P/A:N","score":4.3,"rating":"MEDIUM"}],"cwes":["CWE-79"],"affected":[{"ranges":[{"version":"< 3.1.1","status":"affected"}],"vendor":"laminas","product":"laminas-form","source":"cvelist"},{"ranges":[{"type":"ecosystem","introduced":"3.1.0","status":"affected","fixed":"3.1.1"}],"ecosystem":"Packagist","package":"laminas/laminas-form","purl":"pkg:composer/laminas/laminas-form","source":"ghsa"},{"ranges":[{"type":"ecosystem","introduced":"3.0.0","status":"affected","fixed":"3.0.2"}],"ecosystem":"Packagist","package":"laminas/laminas-form","purl":"pkg:composer/laminas/laminas-form","source":"ghsa"},{"ranges":[{"type":"ecosystem","introduced":"0","status":"affected","fixed":"2.17.1"}],"ecosystem":"Packagist","package":"laminas/laminas-form","purl":"pkg:composer/laminas/laminas-form","source":"ghsa"},{"ranges":[{"status":"affected","fixed":"2.17.1"},{"status":"affected","introduced":"3.0.0","fixed":"3.0.2"},{"status":"affected","version":"3.1.0"}],"vendor":"getlaminas","product":"laminas-form","cpe":"cpe:2.3:a:getlaminas:laminas-form:*:*:*:*:*:*:*:*","source":"nvd"},{"ranges":[{"status":"affected","version":"34"},{"status":"affected","version":"35"}],"vendor":"fedoraproject","product":"fedora","cpe":"cpe:2.3:o:fedoraproject:fedora:34:*:*:*:*:*:*:*","source":"nvd"}],"references":[{"url":"https://github.com/laminas/laminas-form/security/advisories/GHSA-jq4p-mq33-w375","tags":["mitigation","third-party-advisory","web","x-refsource-confirm","x-transferred"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://github.com/laminas/laminas-form/commit/43005a3ec4c2292d4f825273768d9b884acbca37","tags":["patch","third-party-advisory","web","x-refsource-misc","x-transferred"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://getlaminas.org/security/advisory/LP-2022-01","tags":["mitigation","third-party-advisory","web","x-refsource-misc","x-transferred"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://lists.fedoraproject.org/archives/list/package-announce%40lists.fedoraproject.org/message/SLNABVK26CE4PFL57VLY242FW3QY4CPC/","tags":["vendor-advisory","x-refsource-fedora","x-transferred"],"sources":["cvelist","nvd"]},{"url":"https://lists.fedoraproject.org/archives/list/package-announce%40lists.fedoraproject.org/message/CFF6WJ5I7PSEBRF6I753WKE2BXFBGQXE/","tags":["vendor-advisory","x-refsource-fedora","x-transferred"],"sources":["cvelist","nvd"]},{"url":"https://nvd.nist.gov/vuln/detail/CVE-2022-23598","tags":["advisory"],"sources":["ghsa"]},{"url":"https://github.com/laminas/laminas-form","tags":["web"],"sources":["ghsa"]},{"url":"https://github.com/laminas/laminas-form/releases/tag/2.17.1","tags":["web"],"sources":["ghsa"]},{"url":"https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/CFF6WJ5I7PSEBRF6I753WKE2BXFBGQXE","tags":["web"],"sources":["ghsa"]},{"url":"https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/SLNABVK26CE4PFL57VLY242FW3QY4CPC","tags":["web"],"sources":["ghsa"]}],"credits":[],"assigner":"GitHub_M","ssvc":{"scorer":"CISA-ADP","exploitation":"none","automatable":"no","technicalImpact":"partial","date":"2025-04-23T14:11:31.706Z"},"sources":[{"source":"cvelist","name":"CVE List","id":"CVE-2022-23598","url":"https://www.cve.org/CVERecord?id=CVE-2022-23598","licence":"CVE Terms of Use","modified":"2025-04-23T19:08:45.281Z"},{"source":"ghsa","name":"GitHub Advisory Database","id":"GHSA-jq4p-mq33-w375","url":"https://github.com/advisories/GHSA-jq4p-mq33-w375","licence":"CC-BY-4.0","modified":"2024-02-19T05:32:54.368Z"},{"source":"nvd","name":"NVD","id":"CVE-2022-23598","url":"https://nvd.nist.gov/vuln/detail/CVE-2022-23598","licence":"Public domain","modified":"2026-06-17T04:30:26.860Z"}],"updatedAt":"2026-11-25T22:58:09.444Z","epss":{"score":0.01023,"percentile":0.62675,"date":"2026-11-30T12:00:22.000Z"}}