Where
-Infinity
0
Severity
6.1
XSS
AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N

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

1 / 3
Source: GitHub
First published (updated )

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