{"id":"CVE-2022-23598","aliases":["EUVD-2022-0630","GHSA-jq4p-mq33-w375"],"status":"published","title":"Reflected XSS vulnerability when rendering error messages in laminas-form","description":"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.","severity":{"version":"3.1","score":6.1,"vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N","level":"medium","assessor":"cna","from":"cve"},"epss":{"day":"2026-11-10","score":0.00989,"percentile":0.6279,"model":"v2026.06.15"},"facts":{"in_kev":false,"known_exploited":false,"public_exploit":false,"fix_available":true},"cwes":["CWE-79"],"published":"2022-01-28T22:00:16Z","modified":"2026-10-28T02:30:28Z","fixes":[{"ecosystem":"Packagist","package":"laminas/laminas-form","fixed_in":["3.1.1","3.0.2","2.17.1"],"sources":["ghsa","osv"]}],"affected":[{"source":"ghsa","ecosystem":"Packagist","package":"laminas/laminas-form","ranges":[{"type":"ECOSYSTEM","events":[{"introduced":"3.1.0"},{"fixed":"3.1.1"}]}]},{"source":"ghsa","ecosystem":"Packagist","package":"laminas/laminas-form","ranges":[{"type":"ECOSYSTEM","events":[{"introduced":"3.0.0"},{"fixed":"3.0.2"}]}]},{"source":"ghsa","ecosystem":"Packagist","package":"laminas/laminas-form","ranges":[{"type":"ECOSYSTEM","events":[{"introduced":"0"},{"fixed":"2.17.1"}]}]},{"source":"osv","ecosystem":"Packagist","package":"laminas/laminas-form","ranges":[{"type":"ECOSYSTEM","events":[{"introduced":"3.1.0"},{"fixed":"3.1.1"}]}],"versions":["3.1.0"]},{"source":"osv","ecosystem":"Packagist","package":"laminas/laminas-form","ranges":[{"type":"ECOSYSTEM","events":[{"introduced":"3.0.0"},{"fixed":"3.0.2"}]}],"versions":["3.0.0","3.0.1"]},{"source":"osv","ecosystem":"Packagist","package":"laminas/laminas-form","ranges":[{"type":"ECOSYSTEM","events":[{"introduced":"0"},{"fixed":"2.17.1"}]}],"versions":["2.0.0","2.0.1","2.0.2","2.0.3","2.0.4","2.0.5","2.0.6","2.0.7","2.0.8","2.1.0","2.1.1","2.1.2","2.1.3","2.1.4","2.1.5","2.1.6","2.10.0","2.10.1","2.10.2","2.11.0","2.12.0","2.12.1","2.13.0","2.14.0","2.14.1","2.14.2","2.14.3","2.14.4","2.14.5","2.14.6","2.15.0","2.15.1","2.16.0","2.16.1","2.16.2","2.16.3","2.17.0","2.2.0","2.2.0rc1","2.2.0rc2","2.2.0rc3","2.2.1","2.2.10","2.2.2","2.2.3","2.2.4","2.2.5","2.2.6","2.2.7","2.2.8","2.2.9","2.3.0","2.3.1","2.3.2","2.3.3","2.3.4","2.3.5","2.3.6","2.3.7","2.3.8","2.3.9","2.4.0","2.4.0rc1","2.4.0rc2","2.4.0rc3","2.4.0rc4","2.4.0rc5","2.4.0rc6","2.4.0rc7","2.4.1","2.4.10","2.4.11","2.4.12","2.4.13","2.4.2","2.4.3","2.4.4","2.4.5","2.4.6","2.4.7","2.4.8","2.4.9","2.5.0","2.5.1","2.5.2","2.5.3","2.6.0","2.7.0","2.7.1","2.8.0","2.8.1","2.8.2","2.8.3","2.8.4","2.9.0","2.9.1","2.9.2"]}],"products":[{"vendor":"fedoraproject","product":"fedora"},{"vendor":"getlaminas","product":"laminas-form"},{"vendor":"laminas","product":"laminas-form"}],"references":[{"url":"https://github.com/laminas/laminas-form/security/advisories/GHSA-jq4p-mq33-w375","tags":["x_refsource_CONFIRM","x_transferred","Mitigation","Third Party Advisory","advisory","web"]},{"url":"https://github.com/laminas/laminas-form/commit/43005a3ec4c2292d4f825273768d9b884acbca37","tags":["x_refsource_MISC","x_transferred","Patch","Third Party Advisory","fix","web"]},{"url":"https://getlaminas.org/security/advisory/LP-2022-01","tags":["x_refsource_MISC","x_transferred","Mitigation","Third Party Advisory","advisory","web"]},{"url":"https://lists.fedoraproject.org/archives/list/package-announce%40lists.fedoraproject.org/message/SLNABVK26CE4PFL57VLY242FW3QY4CPC/","tags":["vendor-advisory","x_refsource_FEDORA","x_transferred","advisory"]},{"url":"https://lists.fedoraproject.org/archives/list/package-announce%40lists.fedoraproject.org/message/CFF6WJ5I7PSEBRF6I753WKE2BXFBGQXE/","tags":["vendor-advisory","x_refsource_FEDORA","x_transferred","advisory"]},{"url":"https://nvd.nist.gov/vuln/detail/CVE-2022-23598","tags":["advisory"]},{"url":"https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/CFF6WJ5I7PSEBRF6I753WKE2BXFBGQXE/"},{"url":"https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/SLNABVK26CE4PFL57VLY242FW3QY4CPC/"},{"url":"https://github.com/laminas/laminas-form/releases/tag/2.17.1","tags":["web"]},{"url":"https://github.com/advisories/GHSA-jq4p-mq33-w375"},{"url":"https://github.com/CVEProject/cvelistV5/tree/main/cves/2022/23xxx/CVE-2022-23598.json","tags":["advisory"]},{"url":"https://github.com/laminas/laminas-form","tags":["web"]},{"url":"https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/CFF6WJ5I7PSEBRF6I753WKE2BXFBGQXE","tags":["web"]},{"url":"https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/SLNABVK26CE4PFL57VLY242FW3QY4CPC","tags":["web"]}],"sources":{"cve":[{"id":"CVE-2022-23598","title":"Reflected XSS vulnerability when rendering error messages in laminas-form","description":"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.","status":"published","published":"2022-01-28T22:00:16Z","modified":"2025-04-23T19:08:45.281Z","cvss":[{"version":"3.1","score":6.1,"vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N","level":"medium","assessor":"cna"}],"cwes":["CWE-79"],"updated_at":"2026-11-02T14:34:29.842547Z"}],"euvd":[{"id":"EUVD-2022-0630","description":"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.","status":"published","published":"2022-01-28T22:00:16Z","modified":"2025-04-23T19:08:45Z","cvss":[{"version":"3.1","score":6.1,"vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N","level":"medium"}],"updated_at":"2026-11-02T20:52:06.891582Z"}],"ghsa":[{"id":"GHSA-jq4p-mq33-w375","title":"Cross-site Scripting when rendering error messages in laminas-form","description":"### 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-\u003egetMessages();\n    if (! $messages) {\n        return;\n    }\n\n    $escaped  = [];\n    array_walk_recursive(\n        $messages,\n        static function (string $item) use (\u0026$escaped, $renderer): void {\n            $escaped[] = $renderer-\u003eescapeHtml($item);\n        }\n    };\n\n    $element-\u003esetMessages($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)","status":"published","published":"2022-01-28T23:08:29Z","modified":"2023-02-03T05:05:33Z","cvss":[{"version":"3.1","score":6.1,"vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N","level":"medium"}],"cwes":["CWE-79"],"updated_at":"2026-11-02T14:36:42.703723Z"}],"nvd":[{"id":"CVE-2022-23598","description":"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.","status":"published","published":"2022-01-28T22:15:16.77Z","modified":"2026-06-17T04:30:26.86Z","cvss":[{"version":"3.1","score":6.1,"vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N","level":"medium","assessor":"secondary"},{"version":"3.1","score":6.1,"vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N","level":"medium","assessor":"primary"},{"version":"2.0","score":4.3,"vector":"AV:N/AC:M/Au:N/C:N/I:P/A:N","level":"medium","assessor":"primary"}],"cwes":["CWE-79"],"updated_at":"2026-11-02T14:07:11.52734Z"}],"osv":[{"id":"CVE-2022-23598","title":"Reflected XSS vulnerability when rendering error messages in laminas-form","description":"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.","status":"published","published":"2022-01-28T22:00:16Z","modified":"2026-10-28T02:30:28.179660548Z","cvss":[{"version":"3.1","score":6.1,"vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N","level":"medium"}],"cwes":["CWE-79"],"updated_at":"2026-11-02T15:44:24.061177Z"},{"id":"GHSA-jq4p-mq33-w375","title":"Cross-site Scripting when rendering error messages in laminas-form","description":"### 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-\u003egetMessages();\n    if (! $messages) {\n        return;\n    }\n\n    $escaped  = [];\n    array_walk_recursive(\n        $messages,\n        static function (string $item) use (\u0026$escaped, $renderer): void {\n            $escaped[] = $renderer-\u003eescapeHtml($item);\n        }\n    };\n\n    $element-\u003esetMessages($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)","status":"published","published":"2022-01-28T23:08:29Z","modified":"2024-02-19T05:32:54.3682Z","cvss":[{"version":"3.1","score":6.1,"vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N","level":"medium"}],"cwes":["CWE-79"],"updated_at":"2026-11-02T15:46:50.687609Z"}]}}
