CVE-2022-23598: Cross-site Scripting when rendering error messages in laminas-form

Published Jan 28, 2022
·
Updated

Impact

When 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.

Patches

The following versions were issued to mitigate the vulnerability:

- 2.17.1 - 3.0.2 - 3.1.1

Workarounds

At the top of a view script where you call the formElementErrors() view helper, place the following code:

php use Laminas\Form\ElementInterface; use Laminas\View\PhpRenderer;

$escapeMessages = function (ElementInterface $formOrElement, PhpRenderer $renderer): void { $messages = $element->getMessages(); if (! $messages) { return; }

$escaped = []; arraywalkrecursive( $messages, static function (string $item) use (&$escaped, $renderer): void { $escaped[] = $renderer->escapeHtml($item); } };

$element->setMessages($escaped); };

Before calling formElementErrors() with a form, fieldset, or element, call the above closure as follows

php // Usage with a form // $this is the view renderer $escapeMessages($form, $this);

// Usage with a fieldset // $this is the view renderer $escapeMessages($fieldset, $this);

// Usage with a form element // $this is the view renderer $escapeMessages($element, $this);

For more information

If you have any questions or comments about this advisory:

Open an issue Email us at security@getlaminas.org

Other sources

Cross-site Scripting when rendering error messages in laminas-form

— Packagist

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.

Affected Software

11 affected componentsFixes available
getlaminas laminas-form<2.17.1
getlaminas laminas-form>=3.0.0<3.0.2
getlaminas laminas-form=3.1.0
Fedoraproject Fedora=34
Fedoraproject Fedora=35
composer/laminas/laminas-form<2.17.1
2.17.1
composer/laminas/laminas-form>=3.0.0, <3.0.2
3.0.2
composer/laminas/laminas-form>=3.1.0, <3.1.1
3.1.1
composer/laminas/laminas-form<2.17.1
2.17.1
composer/laminas/laminas-form>=3.0.0<3.0.2
3.0.2
composer/laminas/laminas-form>=3.1.0<3.1.1
3.1.1

Remediation

Recommended actions to resolve this vulnerability, in priority order.

  1. Upgrade

    Upgrade composer/laminas/laminas-form to a version that resolves this vulnerability.

    Fixed in 2.17.1
  2. Upgrade

    Upgrade composer/laminas/laminas-form to a version that resolves this vulnerability.

    Fixed in 3.0.2
  3. Upgrade

    Upgrade composer/laminas/laminas-form to a version that resolves this vulnerability.

    Fixed in 3.1.1
  4. Upgrade

    Upgrade laminas/laminas-form to a version that resolves this vulnerability.

    Fixed in 2.17.1
  5. Upgrade

    Upgrade laminas/laminas-form to a version that resolves this vulnerability.

    Fixed in 3.0.2
  6. Upgrade

    Upgrade laminas/laminas-form to a version that resolves this vulnerability.

    Fixed in 3.1.1
  7. Compensating control

    Until upgrading, manually escape validation error messages before calling the formElementErrors() view helper by applying the provided escapeHtml-based workaround to the form, fieldset, or form element.

Event History

Jan 28, 2022
CVE Published
via MITRE·10:00 PM
Data Sourced
via MITRE·10:00 PM
DescriptionSeverityWeakness
Data Sourced
via NVD·10:15 PM
RemedyDescriptionSeverityWeaknessAffected Software
Advisory Published
via GitHub·11:08 PM
Data Sourced
via GitHub·11:08 PM
DescriptionSeverityWeaknessAffected Software
Data Sourced
via Packagist·11:08 PM
DescriptionSeverityAffected Software

Frequently Asked Questions

1

What is CVE-2022-23598?

CVE-2022-23598 is a vulnerability in the laminas-form package that allows rendered validation error messages to contain the submitted value.

2

How can I exploit CVE-2022-23598?

As a user, you cannot directly exploit CVE-2022-23598, but an attacker could potentially use the vulnerability to gain information about the submitted values in validation error messages.

3

What is the severity of CVE-2022-23598?

The severity of CVE-2022-23598 is medium, with a CVSS score of 6.1.

4

What software versions are affected by CVE-2022-23598?

Versions up to and including 2.17.1 of Getlaminas Laminas-form, versions 3.0.0 to 3.0.2 of Getlaminas Laminas-form, and version 3.1.0 of Getlaminas Laminas-form are affected. Also, Fedora 34 and Fedora 35 are affected.

5

How do I fix CVE-2022-23598?

To fix CVE-2022-23598, update to version 3.1.1 or later of Getlaminas Laminas-form package.

Contact

SecAlerts Pty Ltd.
132 Wickham Terrace
Fortitude Valley,
QLD 4006, Australia
info@secalerts.co
By using SecAlerts services, you agree to our services end-user license agreement. This website is safeguarded by reCAPTCHA and governed by the Google Privacy Policy and Terms of Service. All names, logos, and brands of products are owned by their respective owners, and any usage of these names, logos, and brands for identification purposes only does not imply endorsement. If you possess any content that requires removal, please get in touch with us.
© 2026 SecAlerts Pty Ltd.
ABN: 70 645 966 203, ACN: 645 966 203