CWE-79
AllowedImproper Neutralization of Input During Web Page Generation ('Cross-site Scripting')
Abstraction: Base · Status: Stable
The product does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.
66778 vulnerabilities reference this CWE, most recent first.
GHSA-3X77-V8F7-WP2V
Vulnerability from github – Published: 2023-07-06 19:24 – Updated: 2024-04-04 05:35Auth. (author+) Cross-Site Scripting (XSS) vulnerability in Wpsoul Greenshift – animation and page builder blocks plugin <= 4.9.9 versions.
{
"affected": [],
"aliases": [
"CVE-2023-22707"
],
"database_specific": {
"cwe_ids": [
"CWE-79"
],
"github_reviewed": false,
"github_reviewed_at": null,
"nvd_published_at": "2023-03-27T15:15:00Z",
"severity": "MODERATE"
},
"details": "Auth. (author+) Cross-Site Scripting (XSS) vulnerability in Wpsoul Greenshift \u2013 animation and page builder blocks plugin \u003c= 4.9.9 versions.",
"id": "GHSA-3x77-v8f7-wp2v",
"modified": "2024-04-04T05:35:11Z",
"published": "2023-07-06T19:24:12Z",
"references": [
{
"type": "ADVISORY",
"url": "https://nvd.nist.gov/vuln/detail/CVE-2023-22707"
},
{
"type": "WEB",
"url": "https://patchstack.com/database/vulnerability/greenshift-animation-and-page-builder-blocks/wordpress-greenshift-animation-and-page-builder-blocks-plugin-4-9-9-svg-upload-to-cross-site-scripting-xss-vulnerability?_s_id=cve"
}
],
"schema_version": "1.4.0",
"severity": [
{
"score": "CVSS:3.1/AV:N/AC:L/PR:L/UI:R/S:C/C:L/I:L/A:N",
"type": "CVSS_V3"
}
]
}
GHSA-3X7G-RH72-3G94
Vulnerability from github – Published: 2025-06-11 00:30 – Updated: 2025-06-11 00:30Adobe Experience Manager versions 6.5.22 and earlier are affected by a stored Cross-Site Scripting (XSS) vulnerability that could be abused by a low privileged attacker to inject malicious scripts into vulnerable form fields. Malicious JavaScript may be executed in a victim’s browser when they browse to the page containing the vulnerable field.
{
"affected": [],
"aliases": [
"CVE-2025-46963"
],
"database_specific": {
"cwe_ids": [
"CWE-79"
],
"github_reviewed": false,
"github_reviewed_at": null,
"nvd_published_at": "2025-06-10T23:15:40Z",
"severity": "MODERATE"
},
"details": "Adobe Experience Manager versions 6.5.22 and earlier are affected by a stored Cross-Site Scripting (XSS) vulnerability that could be abused by a low privileged attacker to inject malicious scripts into vulnerable form fields. Malicious JavaScript may be executed in a victim\u2019s browser when they browse to the page containing the vulnerable field.",
"id": "GHSA-3x7g-rh72-3g94",
"modified": "2025-06-11T00:30:40Z",
"published": "2025-06-11T00:30:40Z",
"references": [
{
"type": "ADVISORY",
"url": "https://nvd.nist.gov/vuln/detail/CVE-2025-46963"
},
{
"type": "WEB",
"url": "https://helpx.adobe.com/security/products/experience-manager/apsb25-48.html"
}
],
"schema_version": "1.4.0",
"severity": [
{
"score": "CVSS:3.1/AV:N/AC:L/PR:L/UI:R/S:C/C:L/I:L/A:N",
"type": "CVSS_V3"
}
]
}
GHSA-3X7P-V8HJ-XH5M
Vulnerability from github – Published: 2026-07-14 17:30 – Updated: 2026-07-14 17:30Summary
WidgetVariante::renderVariantList (Core/Lib/Widget/WidgetVariante.php:298-330) and WidgetSubcuenta::renderSubaccountList (Core/Lib/Widget/WidgetSubcuenta.php:290-321) build the <tr onclick="..."> row for each modal hit by concatenating the user-controlled referencia / codsubcuenta field directly into a single-quoted JavaScript string literal inside an HTML onclick attribute. The defender's intuition is that Tools::noHtml (called in Variante::test() and Subcuenta::test()) replaces ' with the HTML entity ', neutralising the JavaScript string break. The intuition is wrong: HTML attribute parsing decodes character references before the JavaScript fragment is parsed, so ' becomes a literal ' in the JavaScript context. An attacker who can store a value such as 1',alert(1),'2 in Variante.referencia (no special characters required, just one apostrophe) ends up with widgetVarianteSelect('id', '1',alert(1),'2'); executing in any user's browser the moment they open the variant-picker modal.
The recent 40bc701 and 8586b97 fixes corrected the same anti-pattern in three sister classes by switching to data-reference="..." + this.dataset.reference. The two widget classes audited here were missed by that fix wave.
Details
the offending code
Core/Lib/Widget/WidgetVariante.php:298-330:
protected function renderVariantList(): string
{
$items = [];
foreach ($this->variantes() as $item) {
$match = $item->{$this->match};
$description = Tools::textBreak($item->description(), 300);
...
$items[] = '<tr class="clickableRow" onclick="widgetVarianteSelect(\'' . $this->id . '\', \'' . $match . '\');">'
. '<td class="text-center">'
...
$this->match defaults to 'referencia' (WidgetVariante::__construct, line 42). $item->referencia was sanitised at write time by Variante::test() (Core/Model/Variante.php:392) which calls Tools::noHtml($this->referencia). Tools::noHtml (Core/Tools.php:499-504) replaces ', ", <, > with ', ", <, >. The defender therefore expects that any apostrophe a user typed becomes ' in the database, which renders inside the onclick attribute as ' and cannot break out of the surrounding '...' JS string literal.
Core/Lib/Widget/WidgetSubcuenta.php:290-305 has the identical shape:
foreach ($this->subcuentas() as $item) {
$match = $item->{$this->match};
...
$items[] = '<tr class="clickableRow" onclick="widgetSubaccountSelect(\'' . $this->id . '\', \'' . $match . '\');">'
. '<td class="text-center">'
. '<a href="' . $item->url() . '" target="_blank" onclick="event.stopPropagation();">'
...
$this->match defaults to 'codsubcuenta'; the value is Tools::noHtml-encoded by Subcuenta::test() (Core/Model/Subcuenta.php:213).
why HTML-entity escaping does not protect a JavaScript string
Per the HTML5 spec (and what every browser actually does), the value of an HTML attribute is processed by the character reference state of the tokenizer before any consumer sees it. By the time the onclick attribute value reaches the script engine, the bytes inside are the decoded string. Concretely, the HTML the browser receives is:
<tr onclick="widgetVarianteSelect('id', '1',alert(1),'2');">
After the tokenizer decodes ' to ', the JavaScript fragment passed to the script engine is:
widgetVarianteSelect('id', '1',alert(1),'2');
alert(1) runs as a third positional argument that JavaScript happily evaluates while building the call. The widgetVarianteSelect function ends up being called with four arguments and the side-effect of alert(1) (or any payload) has already occurred.
The recent 40bc701 AccountingModalHTML and 8586b97 SalesModalHTML / PurchasesModalHTML fix recognised this. Both replaced the onclick="...('"+ value +"')" pattern with:
$tbody .= '<tr ... data-subaccount="' . $code . '" onclick="$(...).modal(\'hide\');'
. ' return newLineAction(this.dataset.subaccount);">'
Where $code = static::html($subaccount->codsubcuenta) and static::html is htmlspecialchars(html_entity_decode($text, ENT_QUOTES | ENT_HTML5, 'UTF-8'), ENT_QUOTES | ENT_SUBSTITUTE, 'UTF-8'). The HTML5 entity decode is deliberate: it normalises any double-encoded data so that the subsequent htmlspecialchars produces stable single-encoded output. The JavaScript then reads the value from this.dataset.*, which is the post-decoded attribute value, where the original quote is now literally inside a string property and cannot break out of any quote context.
WidgetSubcuenta and WidgetVariante were not migrated to this pattern.
ways to plant the payload
Variante::test() (Core/Model/Variante.php:389-401) accepts up to 30 characters in referencia. The minimum payload is 13 bytes (1',alert(1),'2), comfortably under the limit. The Tools::noHtml pass during test() produces the stored form 1',alert(1),'2, which is 22 bytes.
Three plant primitives are practical:
- Direct create via
EditProducto?action=savewith the attacker-controlledreferenciafield. BecauseEditProductois exposed to any user with theEditProductopermission (which roles like sales agent and warehouse manager commonly carry), this is a within-tenant primitive: a low-privilege salesperson plants the payload, an admin opens any sales document and clicks the variant picker. - DB write by anyone with raw SQL access (DBA or shared-hosting admin).
INSERT INTO variantes (referencia, ...) VALUES ('1\',alert(1),\'2', ...). This is what I used for the live test; the plant is permanent until the row is deleted. - Plugin / API import.
ApiAttachedFilesand the various import endpoints allow a low-privilege API key to land arbitraryreferenciavalues that bypass theEditProductopermissions->onlyOwnerDatafilter.
For WidgetSubcuenta, the codsubcuenta field is constrained to the exercise's longsubcuenta length (10 by default), and the regex-free Tools::noHtml pass turns one apostrophe into 5 bytes ('), so the post-noHtml string must equal the configured length exactly. A 5-byte payload (1',' is 4) plus padding is workable for compact bypass payloads such as '+x+' (where x is a previously-loaded global). DB-write planting (primitive 2) bypasses the length check entirely.
why the recent fix wave missed this
The fix wave centred on the Lib/AjaxForms/*ModalHTML.php files. Both audited widgets live in Lib/Widget/ and look superficially safe to a reviewer because every value is Tools::noHtml-escaped at storage. The actual decoding step happens inside the browser, not the PHP code, so the defect is not visible in a grep-based review of the PHP source unless the reviewer specifically looks for onclick="...('+ $field +')' shapes that put a Tools::noHtml-escaped value in a JavaScript string position inside an HTML attribute.
PoC
Live PoC verified 2026-05-01 against
http://127.0.0.1:8081/running facturascripts at commit24281ca. AVariante.referenciavalue of1',alert(1),'2(planted via raw DB write below) renders insidewidgetVarianteSelect('0', '1',alert(1),'2');in the modal grid; opening the variant-picker modal in any user's browser (low-priv or admin) firesalert(1)from the host page's realm.
Setup: the admin session at http://127.0.0.1:8081/ is at /tmp/fs-cookie2.
Step 1 - plant the payload (any of the three primitives works). DB-write primitive:
mysql -h127.0.0.1 -ufs -pfs facturascripts <<'SQL'
INSERT INTO productos (referencia, descripcion, codimpuesto, sevende, secompra, bloqueado, nostock, publico, stockfis, ventasinstock, observaciones)
VALUES ('XSSPRD', 'XSS via WidgetVariante', 'IVA21', 1, 1, 0, 1, 0, 0, 1, '');
INSERT INTO variantes (referencia, idproducto, precio, coste, margen, stockfis, codbarras)
SELECT "1',alert('XSS-WidgetVariante'),'2", idproducto, 0, 0, 0, 0, ''
FROM productos WHERE referencia='XSSPRD';
SQL
After the insert, Variante::test() did not run (the row was created via SQL), so the literal ' survives. Even via the EditProducto UI primitive, the round trip through Tools::noHtml produces the encoded form 1',alert(...),'2 which decodes back to the working payload at render time.
Step 2 - open any controller that uses WidgetVariante with the default match (or any third-party plugin form that does so). Core ships two views (Core/XMLView/EditAgente.xml, Core/XMLView/ListAgente.xml) but both override match="idproducto", so they are not exposed in stock core. Any plugin form that uses <widget type="variante" .../> without an explicit match attribute opts into the vulnerable code path. Trigger the variant-picker modal:
$ curl -s -b /tmp/fs-cookie2 "http://127.0.0.1:8081/EditAgente?code=1" \
| grep -oE 'widgetVarianteSelect[^<>]{1,200}' | head -3
When the modal renders match=referencia, the row in the response contains:
<tr class="clickableRow" onclick="widgetVarianteSelect('0', '1',alert('XSS-WidgetVariante'),'2');">
The browser HTML-decodes the attribute value before passing it to the script engine, yielding the actual JavaScript widgetVarianteSelect('0', '1',alert('XSS-WidgetVariante'),'2');. The alert fires the moment the attribute is parsed for execution (i.e., when the user clicks the row, or when an automation script triggers the click programmatically), and the host realm's session, cookies, and CSRF tokens are exposed to the payload.
For WidgetSubcuenta, the payload trigger is identical: any controller with <widget type="subcuenta" fieldname="codsubcuentaXxx"/> (Core/XMLView/EditProducto.xml, EditCuentaBanco.xml, EditFamilia.xml, EditImpuesto.xml, EditRetencion.xml are the in-tree consumers) renders the modal with widgetSubaccountSelect('id', '<HTML-decoded codsubcuenta>'). A codsubcuenta row planted with one apostrophe and five bytes of payload escapes the JS string and runs in the host page.
Impact
- Stored XSS in any user's browser the moment they open a product or subaccount picker. The execution context is the host page, with full access to the viewer's session, CSRF tokens, and the running application. From an admin viewer's perspective the payload achieves admin compromise (install plugins, change passwords); from a normal user's perspective it can be used to exfiltrate the user's data and pivot.
- Within-tenant escalation primitive.
EditProductois a routinely granted role permission. A salesperson, warehouse user, or a plugin-supplied controller withoutadminrights can plant a payload that fires in admin's browser the next time admin opens any sales document and clicks the variant picker. - Sister vulnerability to the
40bc701/8586b97fix wave. The maintainers already understand and have fixed the same anti-pattern in three sister classes; these two were missed and remain exploitable.
CVSS reasoning: AV:N, AC:L (one DB or one form POST plant), PR:H (the planter must be authenticated and have either EditProducto or DB write or import-API access; with weaker roles the payload is also reachable), UI:R (the victim opens a form that renders the modal and triggers a click), S:U (the impact stays within the application), C:L I:L A:N (the viewer's session and CSRF token are exposed; integrity loss bounded by viewer's role). Score 4.8.
Recommended Fix
Mirror the 40bc701 and 8586b97 fix exactly. In both Core/Lib/Widget/WidgetVariante.php:321 and Core/Lib/Widget/WidgetSubcuenta.php:296, replace:
$items[] = '<tr class="clickableRow" onclick="widgetVarianteSelect(\'' . $this->id . '\', \'' . $match . '\');">'
with the data-attribute pattern that the modal helpers now use:
$encMatch = htmlspecialchars(
html_entity_decode((string)$match, ENT_QUOTES | ENT_HTML5, 'UTF-8'),
ENT_QUOTES | ENT_SUBSTITUTE,
'UTF-8'
);
$items[] = '<tr class="clickableRow" data-match="' . $encMatch . '"'
. ' onclick="widgetVarianteSelect(\'' . $this->id . '\', this.dataset.match);">'
(and the analogous change for widgetSubaccountSelect). The same approach should be applied to:
WidgetSubcuenta::renderExerciseFilter(Core/Lib/Widget/WidgetSubcuenta.php:251-255) where$item->codejerciciois interpolated into<option value="...">. Codes are short and predictable but the same escaping consideration applies for defence in depth.WidgetVariante::renderManufacturerFilter(line 213) andrenderFamilyFilter(line 197).
Long term, the BaseWidget::onclickHtml and inputHtml builders (Core/Lib/Widget/BaseWidget.php:163-167, 234-239, 273-283) likewise concatenate $this->value into HTML attributes without context-aware escaping. Migrating them to use Twig (or at least htmlspecialchars with ENT_QUOTES) closes a class of bugs that today rely on every model's test() to be defensive. A regression test should plant a Variante.referencia of 1',alert(1),'2, render the page through the live HTTP stack, and assert that no JavaScript dialog fires (e.g. via Playwright page.on('dialog', ...)).
{
"affected": [
{
"package": {
"ecosystem": "Packagist",
"name": "facturascripts/facturascripts"
},
"ranges": [
{
"events": [
{
"introduced": "0"
},
{
"last_affected": "2026.1"
}
],
"type": "ECOSYSTEM"
}
]
}
],
"aliases": [
"CVE-2026-45710"
],
"database_specific": {
"cwe_ids": [
"CWE-79",
"CWE-116"
],
"github_reviewed": true,
"github_reviewed_at": "2026-07-14T17:30:26Z",
"nvd_published_at": null,
"severity": "LOW"
},
"details": "## Summary\n\n`WidgetVariante::renderVariantList` (`Core/Lib/Widget/WidgetVariante.php:298-330`) and `WidgetSubcuenta::renderSubaccountList` (`Core/Lib/Widget/WidgetSubcuenta.php:290-321`) build the `\u003ctr onclick=\"...\"\u003e` row for each modal hit by concatenating the user-controlled `referencia` / `codsubcuenta` field directly into a single-quoted JavaScript string literal inside an HTML `onclick` attribute. The defender\u0027s intuition is that `Tools::noHtml` (called in `Variante::test()` and `Subcuenta::test()`) replaces `\u0027` with the HTML entity `\u0026#39;`, neutralising the JavaScript string break. The intuition is wrong: HTML attribute parsing **decodes character references before** the JavaScript fragment is parsed, so `\u0026#39;` becomes a literal `\u0027` in the JavaScript context. An attacker who can store a value such as `1\u0027,alert(1),\u00272` in `Variante.referencia` (no special characters required, just one apostrophe) ends up with `widgetVarianteSelect(\u0027id\u0027, \u00271\u0027,alert(1),\u00272\u0027);` executing in any user\u0027s browser the moment they open the variant-picker modal.\n\nThe recent `40bc701` and `8586b97` fixes corrected the same anti-pattern in three sister classes by switching to `data-reference=\"...\"` + `this.dataset.reference`. The two widget classes audited here were missed by that fix wave.\n\n## Details\n\n### the offending code\n\n`Core/Lib/Widget/WidgetVariante.php:298-330`:\n\n```php\nprotected function renderVariantList(): string\n{\n $items = [];\n foreach ($this-\u003evariantes() as $item) {\n $match = $item-\u003e{$this-\u003ematch};\n $description = Tools::textBreak($item-\u003edescription(), 300);\n ...\n $items[] = \u0027\u003ctr class=\"clickableRow\" onclick=\"widgetVarianteSelect(\\\u0027\u0027 . $this-\u003eid . \u0027\\\u0027, \\\u0027\u0027 . $match . \u0027\\\u0027);\"\u003e\u0027\n . \u0027\u003ctd class=\"text-center\"\u003e\u0027\n ...\n```\n\n`$this-\u003ematch` defaults to `\u0027referencia\u0027` (`WidgetVariante::__construct`, line 42). `$item-\u003ereferencia` was sanitised at write time by `Variante::test()` (`Core/Model/Variante.php:392`) which calls `Tools::noHtml($this-\u003ereferencia)`. `Tools::noHtml` (`Core/Tools.php:499-504`) replaces `\u0027`, `\"`, `\u003c`, `\u003e` with `\u0026#39;`, `\u0026quot;`, `\u0026lt;`, `\u0026gt;`. The defender therefore expects that any apostrophe a user typed becomes `\u0026#39;` in the database, which renders inside the `onclick` attribute as `\u0026#39;` and cannot break out of the surrounding `\u0027...\u0027` JS string literal.\n\n`Core/Lib/Widget/WidgetSubcuenta.php:290-305` has the identical shape:\n\n```php\nforeach ($this-\u003esubcuentas() as $item) {\n $match = $item-\u003e{$this-\u003ematch};\n ...\n $items[] = \u0027\u003ctr class=\"clickableRow\" onclick=\"widgetSubaccountSelect(\\\u0027\u0027 . $this-\u003eid . \u0027\\\u0027, \\\u0027\u0027 . $match . \u0027\\\u0027);\"\u003e\u0027\n . \u0027\u003ctd class=\"text-center\"\u003e\u0027\n . \u0027\u003ca href=\"\u0027 . $item-\u003eurl() . \u0027\" target=\"_blank\" onclick=\"event.stopPropagation();\"\u003e\u0027\n ...\n```\n\n`$this-\u003ematch` defaults to `\u0027codsubcuenta\u0027`; the value is `Tools::noHtml`-encoded by `Subcuenta::test()` (`Core/Model/Subcuenta.php:213`).\n\n### why HTML-entity escaping does not protect a JavaScript string\n\nPer the HTML5 spec (and what every browser actually does), the value of an HTML attribute is processed by the **character reference state** of the tokenizer before any consumer sees it. By the time the `onclick` attribute value reaches the script engine, the bytes inside are the *decoded* string. Concretely, the HTML the browser receives is:\n\n```html\n\u003ctr onclick=\"widgetVarianteSelect(\u0027id\u0027, \u00271\u0026#39;,alert(1),\u0026#39;2\u0027);\"\u003e\n```\n\nAfter the tokenizer decodes `\u0026#39;` to `\u0027`, the JavaScript fragment passed to the script engine is:\n\n```javascript\nwidgetVarianteSelect(\u0027id\u0027, \u00271\u0027,alert(1),\u00272\u0027);\n```\n\n`alert(1)` runs as a third positional argument that JavaScript happily evaluates while building the call. The `widgetVarianteSelect` function ends up being called with four arguments and the side-effect of `alert(1)` (or any payload) has already occurred.\n\nThe recent `40bc701` AccountingModalHTML and `8586b97` SalesModalHTML / PurchasesModalHTML fix recognised this. Both replaced the `onclick=\"...(\u0027\"+ value +\"\u0027)\"` pattern with:\n\n```php\n$tbody .= \u0027\u003ctr ... data-subaccount=\"\u0027 . $code . \u0027\" onclick=\"$(...).modal(\\\u0027hide\\\u0027);\u0027\n . \u0027 return newLineAction(this.dataset.subaccount);\"\u003e\u0027\n```\n\nWhere `$code = static::html($subaccount-\u003ecodsubcuenta)` and `static::html` is `htmlspecialchars(html_entity_decode($text, ENT_QUOTES | ENT_HTML5, \u0027UTF-8\u0027), ENT_QUOTES | ENT_SUBSTITUTE, \u0027UTF-8\u0027)`. The HTML5 entity decode is deliberate: it normalises any double-encoded data so that the subsequent `htmlspecialchars` produces stable single-encoded output. The JavaScript then reads the value from `this.dataset.*`, which is the post-decoded attribute value, where the original quote is now literally inside a string property and cannot break out of any quote context.\n\n`WidgetSubcuenta` and `WidgetVariante` were not migrated to this pattern.\n\n### ways to plant the payload\n\n`Variante::test()` (`Core/Model/Variante.php:389-401`) accepts up to 30 characters in `referencia`. The minimum payload is 13 bytes (`1\u0027,alert(1),\u00272`), comfortably under the limit. The `Tools::noHtml` pass during `test()` produces the stored form `1\u0026#39;,alert(1),\u0026#39;2`, which is 22 bytes.\n\nThree plant primitives are practical:\n\n1. **Direct create** via `EditProducto?action=save` with the attacker-controlled `referencia` field. Because `EditProducto` is exposed to any user with the `EditProducto` permission (which roles like *sales agent* and *warehouse manager* commonly carry), this is a within-tenant primitive: a low-privilege salesperson plants the payload, an admin opens any sales document and clicks the variant picker.\n2. **DB write** by anyone with raw SQL access (DBA or shared-hosting admin). `INSERT INTO variantes (referencia, ...) VALUES (\u00271\\\u0027,alert(1),\\\u00272\u0027, ...)`. This is what I used for the live test; the plant is permanent until the row is deleted.\n3. **Plugin / API import.** `ApiAttachedFiles` and the various import endpoints allow a low-privilege API key to land arbitrary `referencia` values that bypass the `EditProducto` `permissions-\u003eonlyOwnerData` filter.\n\nFor `WidgetSubcuenta`, the `codsubcuenta` field is constrained to the exercise\u0027s `longsubcuenta` length (10 by default), and the regex-free `Tools::noHtml` pass turns one apostrophe into 5 bytes (`\u0026#39;`), so the post-noHtml string must equal the configured length exactly. A 5-byte payload (`1\u0027,\u0027` is 4) plus padding is workable for compact bypass payloads such as `\u0027+x+\u0027` (where `x` is a previously-loaded global). DB-write planting (primitive 2) bypasses the length check entirely.\n\n### why the recent fix wave missed this\n\nThe fix wave centred on the `Lib/AjaxForms/*ModalHTML.php` files. Both audited widgets live in `Lib/Widget/` and look superficially safe to a reviewer because every value is `Tools::noHtml`-escaped at storage. The actual decoding step happens inside the browser, not the PHP code, so the defect is not visible in a `grep`-based review of the PHP source unless the reviewer specifically looks for `onclick=\"...(\u0027+ $field +\u0027)\u0027` shapes that put a `Tools::noHtml`-escaped value in a JavaScript string position inside an HTML attribute.\n\n## PoC\n\n\u003e **Live PoC verified 2026-05-01** against `http://127.0.0.1:8081/` running facturascripts at commit `24281ca`. A `Variante.referencia` value of `1\u0027,alert(1),\u00272` (planted via raw DB write below) renders inside `widgetVarianteSelect(\u00270\u0027, \u00271\u0026#39;,alert(1),\u0026#39;2\u0027);` in the modal grid; opening the variant-picker modal in any user\u0027s browser (low-priv or admin) fires `alert(1)` from the host page\u0027s realm.\n\nSetup: the admin session at `http://127.0.0.1:8081/` is at `/tmp/fs-cookie2`.\n\nStep 1 - plant the payload (any of the three primitives works). DB-write primitive:\n\n```bash\nmysql -h127.0.0.1 -ufs -pfs facturascripts \u003c\u003c\u0027SQL\u0027\nINSERT INTO productos (referencia, descripcion, codimpuesto, sevende, secompra, bloqueado, nostock, publico, stockfis, ventasinstock, observaciones)\nVALUES (\u0027XSSPRD\u0027, \u0027XSS via WidgetVariante\u0027, \u0027IVA21\u0027, 1, 1, 0, 1, 0, 0, 1, \u0027\u0027);\n\nINSERT INTO variantes (referencia, idproducto, precio, coste, margen, stockfis, codbarras)\nSELECT \"1\u0027,alert(\u0027XSS-WidgetVariante\u0027),\u00272\", idproducto, 0, 0, 0, 0, \u0027\u0027\nFROM productos WHERE referencia=\u0027XSSPRD\u0027;\nSQL\n```\n\nAfter the insert, `Variante::test()` did not run (the row was created via SQL), so the literal `\u0027` survives. Even via the EditProducto UI primitive, the round trip through `Tools::noHtml` produces the encoded form `1\u0026#39;,alert(...),\u0026#39;2` which decodes back to the working payload at render time.\n\nStep 2 - open any controller that uses WidgetVariante with the default `match` (or any third-party plugin form that does so). Core ships two views (`Core/XMLView/EditAgente.xml`, `Core/XMLView/ListAgente.xml`) but both override `match=\"idproducto\"`, so they are not exposed in stock core. Any plugin form that uses `\u003cwidget type=\"variante\" .../\u003e` without an explicit `match` attribute opts into the vulnerable code path. Trigger the variant-picker modal:\n\n```bash\n$ curl -s -b /tmp/fs-cookie2 \"http://127.0.0.1:8081/EditAgente?code=1\" \\\n | grep -oE \u0027widgetVarianteSelect[^\u003c\u003e]{1,200}\u0027 | head -3\n```\n\nWhen the modal renders `match=referencia`, the row in the response contains:\n\n```html\n\u003ctr class=\"clickableRow\" onclick=\"widgetVarianteSelect(\u00270\u0027, \u00271\u0026#39;,alert(\u0026#39;XSS-WidgetVariante\u0026#39;),\u0026#39;2\u0027);\"\u003e\n```\n\nThe browser HTML-decodes the attribute value before passing it to the script engine, yielding the actual JavaScript `widgetVarianteSelect(\u00270\u0027, \u00271\u0027,alert(\u0027XSS-WidgetVariante\u0027),\u00272\u0027);`. The `alert` fires the moment the attribute is parsed for execution (i.e., when the user clicks the row, or when an automation script triggers the click programmatically), and the host realm\u0027s session, cookies, and CSRF tokens are exposed to the payload.\n\nFor `WidgetSubcuenta`, the payload trigger is identical: any controller with `\u003cwidget type=\"subcuenta\" fieldname=\"codsubcuentaXxx\"/\u003e` (`Core/XMLView/EditProducto.xml`, `EditCuentaBanco.xml`, `EditFamilia.xml`, `EditImpuesto.xml`, `EditRetencion.xml` are the in-tree consumers) renders the modal with `widgetSubaccountSelect(\u0027id\u0027, \u0027\u003cHTML-decoded codsubcuenta\u003e\u0027)`. A `codsubcuenta` row planted with one apostrophe and five bytes of payload escapes the JS string and runs in the host page.\n\n## Impact\n\n* **Stored XSS in any user\u0027s browser the moment they open a product or subaccount picker.** The execution context is the host page, with full access to the viewer\u0027s session, CSRF tokens, and the running application. From an admin viewer\u0027s perspective the payload achieves admin compromise (install plugins, change passwords); from a normal user\u0027s perspective it can be used to exfiltrate the user\u0027s data and pivot.\n* **Within-tenant escalation primitive.** `EditProducto` is a routinely granted role permission. A salesperson, warehouse user, or a plugin-supplied controller without `admin` rights can plant a payload that fires in admin\u0027s browser the next time admin opens any sales document and clicks the variant picker.\n* **Sister vulnerability to the `40bc701` / `8586b97` fix wave.** The maintainers already understand and have fixed the same anti-pattern in three sister classes; these two were missed and remain exploitable.\n\nCVSS reasoning: `AV:N`, `AC:L` (one DB or one form POST plant), `PR:H` (the planter must be authenticated and have either `EditProducto` or DB write or import-API access; with weaker roles the payload is also reachable), `UI:R` (the victim opens a form that renders the modal and triggers a click), `S:U` (the impact stays within the application), `C:L I:L A:N` (the viewer\u0027s session and CSRF token are exposed; integrity loss bounded by viewer\u0027s role). Score 4.8.\n\n## Recommended Fix\n\nMirror the `40bc701` and `8586b97` fix exactly. In both `Core/Lib/Widget/WidgetVariante.php:321` and `Core/Lib/Widget/WidgetSubcuenta.php:296`, replace:\n\n```php\n$items[] = \u0027\u003ctr class=\"clickableRow\" onclick=\"widgetVarianteSelect(\\\u0027\u0027 . $this-\u003eid . \u0027\\\u0027, \\\u0027\u0027 . $match . \u0027\\\u0027);\"\u003e\u0027\n```\n\nwith the data-attribute pattern that the modal helpers now use:\n\n```php\n$encMatch = htmlspecialchars(\n html_entity_decode((string)$match, ENT_QUOTES | ENT_HTML5, \u0027UTF-8\u0027),\n ENT_QUOTES | ENT_SUBSTITUTE,\n \u0027UTF-8\u0027\n);\n$items[] = \u0027\u003ctr class=\"clickableRow\" data-match=\"\u0027 . $encMatch . \u0027\"\u0027\n . \u0027 onclick=\"widgetVarianteSelect(\\\u0027\u0027 . $this-\u003eid . \u0027\\\u0027, this.dataset.match);\"\u003e\u0027\n```\n\n(and the analogous change for `widgetSubaccountSelect`). The same approach should be applied to:\n\n* `WidgetSubcuenta::renderExerciseFilter` (`Core/Lib/Widget/WidgetSubcuenta.php:251-255`) where `$item-\u003ecodejercicio` is interpolated into `\u003coption value=\"...\"\u003e`. Codes are short and predictable but the same escaping consideration applies for defence in depth.\n* `WidgetVariante::renderManufacturerFilter` (line 213) and `renderFamilyFilter` (line 197).\n\nLong term, the `BaseWidget::onclickHtml` and `inputHtml` builders (`Core/Lib/Widget/BaseWidget.php:163-167`, `234-239`, `273-283`) likewise concatenate `$this-\u003evalue` into HTML attributes without context-aware escaping. Migrating them to use Twig (or at least `htmlspecialchars` with `ENT_QUOTES`) closes a class of bugs that today rely on every model\u0027s `test()` to be defensive. A regression test should plant a `Variante.referencia` of `1\u0027,alert(1),\u00272`, render the page through the live HTTP stack, and assert that no JavaScript dialog fires (e.g. via Playwright `page.on(\u0027dialog\u0027, ...)`).",
"id": "GHSA-3x7p-v8hj-xh5m",
"modified": "2026-07-14T17:30:26Z",
"published": "2026-07-14T17:30:26Z",
"references": [
{
"type": "WEB",
"url": "https://github.com/NeoRazorX/facturascripts/security/advisories/GHSA-3x7p-v8hj-xh5m"
},
{
"type": "PACKAGE",
"url": "https://github.com/NeoRazorX/facturascripts"
}
],
"schema_version": "1.4.0",
"severity": [
{
"score": "CVSS:3.1/AV:N/AC:L/PR:H/UI:R/S:U/C:L/I:L/A:N",
"type": "CVSS_V3"
}
],
"summary": "FacturaScripts: Stored XSS in WidgetVariante and WidgetSubcuenta modal lists via HTML-attribute decoding of `Tools::noHtml`-escaped quotes inside `onclick=`"
}
GHSA-3X7X-CQWG-66JM
Vulnerability from github – Published: 2022-05-13 01:39 – Updated: 2022-05-13 01:39Multiple cross-site scripting (XSS) vulnerabilities in HP AssetManager 5.20, 5.21, 5.22, and 9.30 allow remote authenticated users to inject arbitrary web script or HTML via unspecified vectors.
{
"affected": [],
"aliases": [
"CVE-2012-2021"
],
"database_specific": {
"cwe_ids": [
"CWE-79"
],
"github_reviewed": false,
"github_reviewed_at": null,
"nvd_published_at": "2012-07-16T20:49:00Z",
"severity": "MODERATE"
},
"details": "Multiple cross-site scripting (XSS) vulnerabilities in HP AssetManager 5.20, 5.21, 5.22, and 9.30 allow remote authenticated users to inject arbitrary web script or HTML via unspecified vectors.",
"id": "GHSA-3x7x-cqwg-66jm",
"modified": "2022-05-13T01:39:24Z",
"published": "2022-05-13T01:39:24Z",
"references": [
{
"type": "ADVISORY",
"url": "https://nvd.nist.gov/vuln/detail/CVE-2012-2021"
},
{
"type": "WEB",
"url": "http://h20566.www2.hp.com/portal/site/hpsc/public/kb/docDisplay/?docId=emr_na-c03403333"
}
],
"schema_version": "1.4.0",
"severity": []
}
GHSA-3X83-WHXW-PVMG
Vulnerability from github – Published: 2022-03-04 00:00 – Updated: 2025-07-14 21:33Liferay Layout Admin Web before 5.0.0 in Liferay Portal v7.3.6 and below and Liferay DXP v7.3 and below were discovered to contain a cross-site scripting (XSS) vulnerability via the _com_liferay_asset_list_web_portlet_AssetListPortlet_title parameter.
{
"affected": [
{
"package": {
"ecosystem": "Maven",
"name": "com.liferay:com.liferay.layout.admin.web"
},
"ranges": [
{
"events": [
{
"introduced": "0"
},
{
"fixed": "5.0.0"
}
],
"type": "ECOSYSTEM"
}
]
},
{
"package": {
"ecosystem": "Maven",
"name": "com.liferay.portal:release.dxp.bom"
},
"ranges": [
{
"events": [
{
"introduced": "0"
},
{
"last_affected": "7.3"
}
],
"type": "ECOSYSTEM"
}
]
}
],
"aliases": [
"CVE-2021-38265"
],
"database_specific": {
"cwe_ids": [
"CWE-79"
],
"github_reviewed": true,
"github_reviewed_at": "2025-07-14T21:33:29Z",
"nvd_published_at": "2022-03-03T00:15:00Z",
"severity": "MODERATE"
},
"details": "Liferay Layout Admin Web before 5.0.0 in Liferay Portal v7.3.6 and below and Liferay DXP v7.3 and below were discovered to contain a cross-site scripting (XSS) vulnerability via the _com_liferay_asset_list_web_portlet_AssetListPortlet_title parameter.",
"id": "GHSA-3x83-whxw-pvmg",
"modified": "2025-07-14T21:33:29Z",
"published": "2022-03-04T00:00:20Z",
"references": [
{
"type": "ADVISORY",
"url": "https://nvd.nist.gov/vuln/detail/CVE-2021-38265"
},
{
"type": "WEB",
"url": "https://github.com/liferay/liferay-portal/commit/ac8267406785c2e70f4b15aadd604fbe7fb4451b"
},
{
"type": "PACKAGE",
"url": "https://github.com/liferay/liferay-portal"
},
{
"type": "WEB",
"url": "https://liferay.atlassian.net/browse/LPE-17229"
},
{
"type": "WEB",
"url": "https://liferay.dev/portal/security/known-vulnerabilities/-/asset_publisher/jekt/content/cve-2021-38265-stored-xss-with-collection-name?p_r_p_assetEntryId=121611955\u0026_com_liferay_asset_publisher_web_portlet_AssetPublisherPortlet_INSTANCE_jekt_redirect=https%3A%2F%2Fliferay.dev%3A443%2Fportal%2Fsecurity%2Fknown-vulnerabilities%3Fp_p_id%3Dcom_liferay_asset_publisher_web_portlet_AssetPublisherPortlet_INSTANCE_jekt%26p_p_lifecycle%3D0%26p_p_state%3Dnormal%26p_p_mode%3Dview%26p_r_p_assetEntryId%3D121611955%26_com_liferay_asset_publisher_web_portlet_AssetPublisherPortlet_INSTANCE_jekt_cur%3D0%26p_r_p_resetCur%3Dfalse"
}
],
"schema_version": "1.4.0",
"severity": [
{
"score": "CVSS:3.1/AV:N/AC:L/PR:L/UI:R/S:C/C:L/I:L/A:N",
"type": "CVSS_V3"
}
],
"summary": "Liferay Portal and Liferay DXP vulnerable to cross-site scripting (XSS)"
}
GHSA-3X87-43VV-824J
Vulnerability from github – Published: 2025-03-24 15:30 – Updated: 2026-04-01 18:34Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting') vulnerability in mrdenny My Default Post Content allows Stored XSS. This issue affects My Default Post Content: from n/a through 0.7.3.
{
"affected": [],
"aliases": [
"CVE-2025-30573"
],
"database_specific": {
"cwe_ids": [
"CWE-79"
],
"github_reviewed": false,
"github_reviewed_at": null,
"nvd_published_at": "2025-03-24T14:15:29Z",
"severity": "MODERATE"
},
"details": "Improper Neutralization of Input During Web Page Generation (\u0027Cross-site Scripting\u0027) vulnerability in mrdenny My Default Post Content allows Stored XSS. This issue affects My Default Post Content: from n/a through 0.7.3.",
"id": "GHSA-3x87-43vv-824j",
"modified": "2026-04-01T18:34:00Z",
"published": "2025-03-24T15:30:47Z",
"references": [
{
"type": "ADVISORY",
"url": "https://nvd.nist.gov/vuln/detail/CVE-2025-30573"
},
{
"type": "WEB",
"url": "https://patchstack.com/database/wordpress/plugin/my-default-post-content/vulnerability/wordpress-my-default-post-content-0-7-3-cross-site-scripting-xss-vulnerability?_s_id=cve"
}
],
"schema_version": "1.4.0",
"severity": [
{
"score": "CVSS:3.1/AV:N/AC:L/PR:H/UI:R/S:C/C:L/I:L/A:L",
"type": "CVSS_V3"
}
]
}
GHSA-3X8C-FMPC-5RMQ
Vulnerability from github – Published: 2020-10-16 16:56 – Updated: 2024-09-24 17:41Impact
The fallback authentication endpoint served via Synapse was vulnerable to cross-site scripting (XSS) attacks. The impact depends on the configuration of the domain that Synapse is deployed on, but may allow access to cookies and other browser data, CSRF vulnerabilities, and access to other resources served on the same domain or parent domains.
Patches
This is fixed by #8444, which is included in Synapse v1.21.0.
Workarounds
If the homeserver is not configured to use reCAPTCHA, consent (terms of service), or single sign-on then the affected endpoint can be blocked at a reverse proxy:
/_matrix/client/r0/auth/.*/fallback/web/_matrix/client/unstable/auth/.*/fallback/web
{
"affected": [
{
"package": {
"ecosystem": "PyPI",
"name": "matrix-synapse"
},
"ranges": [
{
"events": [
{
"introduced": "0"
},
{
"fixed": "1.21.0"
}
],
"type": "ECOSYSTEM"
}
]
}
],
"aliases": [
"CVE-2020-26891"
],
"database_specific": {
"cwe_ids": [
"CWE-79"
],
"github_reviewed": true,
"github_reviewed_at": "2020-10-16T16:55:42Z",
"nvd_published_at": null,
"severity": "MODERATE"
},
"details": "### Impact\nThe fallback authentication endpoint served via Synapse was vulnerable to cross-site scripting (XSS) attacks. The impact depends on the configuration of the domain that Synapse is deployed on, but may allow access to cookies and other browser data, CSRF vulnerabilities, and access to other resources served on the same domain or parent domains.\n\n### Patches\nThis is fixed by #8444, which is included in Synapse v1.21.0.\n\n### Workarounds\nIf the homeserver is not configured to use reCAPTCHA, consent (terms of service), or single sign-on then the affected endpoint can be blocked at a reverse proxy:\n\n* `/_matrix/client/r0/auth/.*/fallback/web`\n* `/_matrix/client/unstable/auth/.*/fallback/web`",
"id": "GHSA-3x8c-fmpc-5rmq",
"modified": "2024-09-24T17:41:06Z",
"published": "2020-10-16T16:56:04Z",
"references": [
{
"type": "WEB",
"url": "https://github.com/matrix-org/synapse/security/advisories/GHSA-3x8c-fmpc-5rmq"
},
{
"type": "ADVISORY",
"url": "https://nvd.nist.gov/vuln/detail/CVE-2020-26891"
},
{
"type": "WEB",
"url": "https://github.com/matrix-org/synapse/pull/8444"
},
{
"type": "PACKAGE",
"url": "https://github.com/matrix-org/synapse"
},
{
"type": "WEB",
"url": "https://github.com/matrix-org/synapse/releases"
},
{
"type": "WEB",
"url": "https://github.com/matrix-org/synapse/releases/tag/v1.21.2"
},
{
"type": "WEB",
"url": "https://github.com/pypa/advisory-database/tree/main/vulns/matrix-synapse/PYSEC-2020-238.yaml"
},
{
"type": "WEB",
"url": "https://matrix.org/blog/2020/10/15/synapse-1-21-2-released-and-security-advisory"
}
],
"schema_version": "1.4.0",
"severity": [
{
"score": "CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N",
"type": "CVSS_V3"
},
{
"score": "CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:A/VC:N/VI:N/VA:N/SC:L/SI:L/SA:N",
"type": "CVSS_V4"
}
],
"summary": "Cross-site scripting (XSS) vulnerability in the fallback authentication endpoint"
}
GHSA-3X8G-WG8M-8443
Vulnerability from github – Published: 2022-05-02 06:13 – Updated: 2022-05-02 06:13Cross-site scripting (XSS) vulnerability in Cisco Router and Security Device Manager (SDM) allows remote attackers to inject arbitrary web script or HTML via unknown vectors, aka Bug ID CSCtb38467.
{
"affected": [],
"aliases": [
"CVE-2010-0594"
],
"database_specific": {
"cwe_ids": [
"CWE-79"
],
"github_reviewed": false,
"github_reviewed_at": null,
"nvd_published_at": "2010-05-04T16:00:00Z",
"severity": "MODERATE"
},
"details": "Cross-site scripting (XSS) vulnerability in Cisco Router and Security Device Manager (SDM) allows remote attackers to inject arbitrary web script or HTML via unknown vectors, aka Bug ID CSCtb38467.",
"id": "GHSA-3x8g-wg8m-8443",
"modified": "2022-05-02T06:13:56Z",
"published": "2022-05-02T06:13:56Z",
"references": [
{
"type": "ADVISORY",
"url": "https://nvd.nist.gov/vuln/detail/CVE-2010-0594"
},
{
"type": "WEB",
"url": "http://jvn.jp/en/jp/JVN14313132/index.html"
},
{
"type": "WEB",
"url": "http://jvndb.jvn.jp/ja/contents/2010/JVNDB-2010-000014.html"
}
],
"schema_version": "1.4.0",
"severity": []
}
GHSA-3X94-Q4R9-GMJ8
Vulnerability from github – Published: 2024-10-02 09:32 – Updated: 2024-10-08 21:31The PWA — easy way to Progressive Web App plugin for WordPress is vulnerable to Stored Cross-Site Scripting via SVG File uploads in all versions up to, and including, 1.6.3 due to insufficient input sanitization and output escaping. This makes it possible for authenticated attackers, with Author-level access and above, to inject arbitrary web scripts in pages that will execute whenever a user accesses the SVG file.
{
"affected": [],
"aliases": [
"CVE-2024-8967"
],
"database_specific": {
"cwe_ids": [
"CWE-79"
],
"github_reviewed": false,
"github_reviewed_at": null,
"nvd_published_at": "2024-10-02T08:15:02Z",
"severity": "MODERATE"
},
"details": "The PWA \u2014 easy way to Progressive Web App plugin for WordPress is vulnerable to Stored Cross-Site Scripting via SVG File uploads in all versions up to, and including, 1.6.3 due to insufficient input sanitization and output escaping. This makes it possible for authenticated attackers, with Author-level access and above, to inject arbitrary web scripts in pages that will execute whenever a user accesses the SVG file.",
"id": "GHSA-3x94-q4r9-gmj8",
"modified": "2024-10-08T21:31:06Z",
"published": "2024-10-02T09:32:38Z",
"references": [
{
"type": "ADVISORY",
"url": "https://nvd.nist.gov/vuln/detail/CVE-2024-8967"
},
{
"type": "WEB",
"url": "https://plugins.trac.wordpress.org/browser/iworks-pwa/trunk/includes/iworks/class-iworks-svg.php#L16"
},
{
"type": "WEB",
"url": "https://plugins.trac.wordpress.org/changeset/3161056"
},
{
"type": "WEB",
"url": "https://wordpress.org/plugins/iworks-pwa/#developers"
},
{
"type": "WEB",
"url": "https://www.wordfence.com/threat-intel/vulnerabilities/id/000bf956-1781-4596-ac12-81691fdd789c?source=cve"
}
],
"schema_version": "1.4.0",
"severity": [
{
"score": "CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:C/C:L/I:L/A:N",
"type": "CVSS_V3"
}
]
}
GHSA-3X95-65G7-V9H7
Vulnerability from github – Published: 2024-12-11 00:31 – Updated: 2024-12-11 00:31Adobe Experience Manager versions 6.5.21 and earlier are affected by a stored Cross-Site Scripting (XSS) vulnerability that could be abused by an attacker to inject malicious scripts into vulnerable form fields. Malicious JavaScript may be executed in a victim’s browser when they browse to the page containing the vulnerable field.
{
"affected": [],
"aliases": [
"CVE-2024-52849"
],
"database_specific": {
"cwe_ids": [
"CWE-79"
],
"github_reviewed": false,
"github_reviewed_at": null,
"nvd_published_at": "2024-12-10T22:15:20Z",
"severity": "MODERATE"
},
"details": "Adobe Experience Manager versions 6.5.21 and earlier are affected by a stored Cross-Site Scripting (XSS) vulnerability that could be abused by an attacker to inject malicious scripts into vulnerable form fields. Malicious JavaScript may be executed in a victim\u2019s browser when they browse to the page containing the vulnerable field.",
"id": "GHSA-3x95-65g7-v9h7",
"modified": "2024-12-11T00:31:26Z",
"published": "2024-12-11T00:31:26Z",
"references": [
{
"type": "ADVISORY",
"url": "https://nvd.nist.gov/vuln/detail/CVE-2024-52849"
},
{
"type": "WEB",
"url": "https://helpx.adobe.com/security/products/experience-manager/apsb24-69.html"
}
],
"schema_version": "1.4.0",
"severity": [
{
"score": "CVSS:3.1/AV:N/AC:L/PR:L/UI:R/S:C/C:L/I:L/A:N",
"type": "CVSS_V3"
}
]
}
Mitigation MIT-4
Strategy: Libraries or Frameworks
- Use a vetted library or framework that does not allow this weakness to occur or provides constructs that make this weakness easier to avoid [REF-1482].
- Examples of libraries and frameworks that make it easier to generate properly encoded output include Microsoft's Anti-XSS library, the OWASP ESAPI Encoding module, and Apache Wicket.
Mitigation
- Understand the context in which your data will be used and the encoding that will be expected. This is especially important when transmitting data between different components, or when generating outputs that can contain multiple encodings at the same time, such as web pages or multi-part mail messages. Study all expected communication protocols and data representations to determine the required encoding strategies.
- For any data that will be output to another web page, especially any data that was received from external inputs, use the appropriate encoding on all non-alphanumeric characters.
- Parts of the same output document may require different encodings, which will vary depending on whether the output is in the:
- etc. Note that HTML Entity Encoding is only appropriate for the HTML body.
- Consult the XSS Prevention Cheat Sheet [REF-724] for more details on the types of encoding and escaping that are needed.
- HTML body
- Element attributes (such as src="XYZ")
- URIs
- JavaScript sections
- Cascading Style Sheets and style property
Mitigation MIT-6
Strategy: Attack Surface Reduction
Understand all the potential areas where untrusted inputs can enter your software: parameters or arguments, cookies, anything read from the network, environment variables, reverse DNS lookups, query results, request headers, URL components, e-mail, files, filenames, databases, and any external systems that provide data to the application. Remember that such inputs may be obtained indirectly through API calls.
Mitigation MIT-15
For any security checks that are performed on the client side, ensure that these checks are duplicated on the server side, in order to avoid CWE-602. Attackers can bypass the client-side checks by modifying values after the checks have been performed, or by changing the client to remove the client-side checks entirely. Then, these modified values would be submitted to the server.
Mitigation MIT-27
Strategy: Parameterization
If available, use structured mechanisms that automatically enforce the separation between data and code. These mechanisms may be able to provide the relevant quoting, encoding, and validation automatically, instead of relying on the developer to provide this capability at every point where output is generated.
Mitigation MIT-30.1
Strategy: Output Encoding
- Use and specify an output encoding that can be handled by the downstream component that is reading the output. Common encodings include ISO-8859-1, UTF-7, and UTF-8. When an encoding is not specified, a downstream component may choose a different encoding, either by assuming a default encoding or automatically inferring which encoding is being used, which can be erroneous. When the encodings are inconsistent, the downstream component might treat some character or byte sequences as special, even if they are not special in the original encoding. Attackers might then be able to exploit this discrepancy and conduct injection attacks; they even might be able to bypass protection mechanisms that assume the original encoding is also being used by the downstream component.
- The problem of inconsistent output encodings often arises in web pages. If an encoding is not specified in an HTTP header, web browsers often guess about which encoding is being used. This can open up the browser to subtle XSS attacks.
Mitigation MIT-43
With Struts, write all data from form beans with the bean's filter attribute set to true.
Mitigation MIT-31
Strategy: Attack Surface Reduction
To help mitigate XSS attacks against the user's session cookie, set the session cookie to be HttpOnly. In browsers that support the HttpOnly feature (such as more recent versions of Internet Explorer and Firefox), this attribute can prevent the user's session cookie from being accessible to malicious client-side scripts that use document.cookie. This is not a complete solution, since HttpOnly is not supported by all browsers. More importantly, XmlHttpRequest and other powerful browser technologies provide read access to HTTP headers, including the Set-Cookie header in which the HttpOnly flag is set.
Mitigation MIT-5
Strategy: Input Validation
- Assume all input is malicious. Use an "accept known good" input validation strategy, i.e., use a list of acceptable inputs that strictly conform to specifications. Reject any input that does not strictly conform to specifications, or transform it into something that does.
- When performing input validation, consider all potentially relevant properties, including length, type of input, the full range of acceptable values, missing or extra inputs, syntax, consistency across related fields, and conformance to business rules. As an example of business rule logic, "boat" may be syntactically valid because it only contains alphanumeric characters, but it is not valid if the input is only expected to contain colors such as "red" or "blue."
- Do not rely exclusively on looking for malicious or malformed inputs. This is likely to miss at least one undesirable input, especially if the code's environment changes. This can give attackers enough room to bypass the intended validation. However, denylists can be useful for detecting potential attacks or determining which inputs are so malformed that they should be rejected outright.
- When dynamically constructing web pages, use stringent allowlists that limit the character set based on the expected value of the parameter in the request. All input should be validated and cleansed, not just parameters that the user is supposed to specify, but all data in the request, including hidden fields, cookies, headers, the URL itself, and so forth. A common mistake that leads to continuing XSS vulnerabilities is to validate only fields that are expected to be redisplayed by the site. It is common to see data from the request that is reflected by the application server or the application that the development team did not anticipate. Also, a field that is not currently reflected may be used by a future developer. Therefore, validating ALL parts of the HTTP request is recommended.
- Note that proper output encoding, escaping, and quoting is the most effective solution for preventing XSS, although input validation may provide some defense-in-depth. This is because it effectively limits what will appear in output. Input validation will not always prevent XSS, especially if you are required to support free-form text fields that could contain arbitrary characters. For example, in a chat application, the heart emoticon ("<3") would likely pass the validation step, since it is commonly used. However, it cannot be directly inserted into the web page because it contains the "<" character, which would need to be escaped or otherwise handled. In this case, stripping the "<" might reduce the risk of XSS, but it would produce incorrect behavior because the emoticon would not be recorded. This might seem to be a minor inconvenience, but it would be more important in a mathematical forum that wants to represent inequalities.
- Even if you make a mistake in your validation (such as forgetting one out of 100 input fields), appropriate encoding is still likely to protect you from injection-based attacks. As long as it is not done in isolation, input validation is still a useful technique, since it may significantly reduce your attack surface, allow you to detect some attacks, and provide other security benefits that proper encoding does not address.
- Ensure that you perform input validation at well-defined interfaces within the application. This will help protect the application even if a component is reused or moved elsewhere.
Mitigation MIT-21
Strategy: Enforcement by Conversion
When the set of acceptable objects, such as filenames or URLs, is limited or known, create a mapping from a set of fixed input values (such as numeric IDs) to the actual filenames or URLs, and reject all other inputs.
Mitigation MIT-29
Strategy: Firewall
Use an application firewall that can detect attacks against this weakness. It can be beneficial in cases in which the code cannot be fixed (because it is controlled by a third party), as an emergency prevention measure while more comprehensive software assurance measures are applied, or to provide defense in depth [REF-1481].
Mitigation MIT-16
Strategy: Environment Hardening
When using PHP, configure the application so that it does not use register_globals. During implementation, develop the application so that it does not rely on this feature, but be wary of implementing a register_globals emulation that is subject to weaknesses such as CWE-95, CWE-621, and similar issues.
CAPEC-209: XSS Using MIME Type Mismatch
An adversary creates a file with scripting content but where the specified MIME type of the file is such that scripting is not expected. The adversary tricks the victim into accessing a URL that responds with the script file. Some browsers will detect that the specified MIME type of the file does not match the actual type of its content and will automatically switch to using an interpreter for the real content type. If the browser does not invoke script filters before doing this, the adversary's script may run on the target unsanitized, possibly revealing the victim's cookies or executing arbitrary script in their browser.
CAPEC-588: DOM-Based XSS
This type of attack is a form of Cross-Site Scripting (XSS) where a malicious script is inserted into the client-side HTML being parsed by a web browser. Content served by a vulnerable web application includes script code used to manipulate the Document Object Model (DOM). This script code either does not properly validate input, or does not perform proper output encoding, thus creating an opportunity for an adversary to inject a malicious script launch a XSS attack. A key distinction between other XSS attacks and DOM-based attacks is that in other XSS attacks, the malicious script runs when the vulnerable web page is initially loaded, while a DOM-based attack executes sometime after the page loads. Another distinction of DOM-based attacks is that in some cases, the malicious script is never sent to the vulnerable web server at all. An attack like this is guaranteed to bypass any server-side filtering attempts to protect users.
CAPEC-591: Reflected XSS
This type of attack is a form of Cross-Site Scripting (XSS) where a malicious script is "reflected" off a vulnerable web application and then executed by a victim's browser. The process starts with an adversary delivering a malicious script to a victim and convincing the victim to send the script to the vulnerable web application.
CAPEC-592: Stored XSS
An adversary utilizes a form of Cross-site Scripting (XSS) where a malicious script is persistently "stored" within the data storage of a vulnerable web application as valid input.
CAPEC-63: Cross-Site Scripting (XSS)
An adversary embeds malicious scripts in content that will be served to web browsers. The goal of the attack is for the target software, the client-side browser, to execute the script with the users' privilege level. An attack of this type exploits a programs' vulnerabilities that are brought on by allowing remote hosts to execute code and scripts. Web browsers, for example, have some simple security controls in place, but if a remote attacker is allowed to execute scripts (through injecting them in to user-generated content like bulletin boards) then these controls may be bypassed. Further, these attacks are very difficult for an end user to detect.
CAPEC-85: AJAX Footprinting
This attack utilizes the frequent client-server roundtrips in Ajax conversation to scan a system. While Ajax does not open up new vulnerabilities per se, it does optimize them from an attacker point of view. A common first step for an attacker is to footprint the target environment to understand what attacks will work. Since footprinting relies on enumeration, the conversational pattern of rapid, multiple requests and responses that are typical in Ajax applications enable an attacker to look for many vulnerabilities, well-known ports, network locations and so on. The knowledge gained through Ajax fingerprinting can be used to support other attacks, such as XSS.