CVSS2
Attack Vector
NETWORK
Attack Complexity
MEDIUM
Authentication
NONE
Confidentiality Impact
NONE
Integrity Impact
PARTIAL
Availability Impact
NONE
AV:N/AC:M/Au:N/C:N/I:P/A:N
CVSS3
Attack Vector
NETWORK
Attack Complexity
LOW
Privileges Required
NONE
User Interaction
REQUIRED
Scope
CHANGED
Confidentiality Impact
LOW
Integrity Impact
LOW
Availability Impact
NONE
CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N
EPSS
Percentile
60.0%
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.
The following versions were issued to mitigate the vulnerability:
At the top of a view script where you call the formElementErrors()
view helper, place the following code:
use Laminas\Form\ElementInterface;
use Laminas\View\PhpRenderer;
$escapeMessages = function (ElementInterface $formOrElement, PhpRenderer $renderer): void {
$messages = $element->getMessages();
if (! $messages) {
return;
}
$escaped = [];
array_walk_recursive(
$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
// 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);
If you have any questions or comments about this advisory:
Vendor | Product | Version | CPE |
---|---|---|---|
laminas | laminas-form | * | cpe:2.3:a:laminas:laminas-form:*:*:*:*:*:*:*:* |
getlaminas.org/security/advisory/LP-2022-01
github.com/advisories/GHSA-jq4p-mq33-w375
github.com/laminas/laminas-form/commit/43005a3ec4c2292d4f825273768d9b884acbca37
github.com/laminas/laminas-form/releases/tag/2.17.1
github.com/laminas/laminas-form/security/advisories/GHSA-jq4p-mq33-w375
lists.fedoraproject.org/archives/list/[email protected]/message/CFF6WJ5I7PSEBRF6I753WKE2BXFBGQXE/
lists.fedoraproject.org/archives/list/[email protected]/message/SLNABVK26CE4PFL57VLY242FW3QY4CPC/
nvd.nist.gov/vuln/detail/CVE-2022-23598
CVSS2
Attack Vector
NETWORK
Attack Complexity
MEDIUM
Authentication
NONE
Confidentiality Impact
NONE
Integrity Impact
PARTIAL
Availability Impact
NONE
AV:N/AC:M/Au:N/C:N/I:P/A:N
CVSS3
Attack Vector
NETWORK
Attack Complexity
LOW
Privileges Required
NONE
User Interaction
REQUIRED
Scope
CHANGED
Confidentiality Impact
LOW
Integrity Impact
LOW
Availability Impact
NONE
CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N
EPSS
Percentile
60.0%