{"id":"CVE-2026-49259","aliases":[],"url":"https://o3.security/vulnerability/CVE-2026-49259","summary":"NukeViet: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')","details":"## Summary\n\nA stored cross-site scripting (XSS) vulnerability exists in NukeViet CMS versions 4.x through 4.5.08. A low-privileged authenticated user can store a JavaScript payload in their profile's display name fields. The payload executes in the browser of any visitor — including administrators — who clicks the **Reply** (\"Answer\") link on a comment posted by that user.\n\n## Affected Component\n\nThe `{COMMENT.post_name}` template variable is interpolated without JavaScript-context escaping into an inline `onclick` handler in both comment block positions:\n\n- `themes/default/modules/comment/comment.tpl` line 27 (top-level comments)\n- `themes/default/modules/comment/comment.tpl` line 64 (nested/reply comments)\n\n```html\nonclick=\"nv_commment_feedback(event, {COMMENT.cid}, '{COMMENT.post_name}')\"\n```\n\n## Root Cause\n\nThe `first_name` and `last_name` profile fields are sanitized with HTML numeric character references (`'` → `&#039;`, `(` → `&#40;`, `)` → `&#41;`, `/` → `&#x002F;`) via `Request::_get_title()` with `$specialchars = true`. This encoding is correct for plain HTML attribute and element contexts, but **insufficient for a JavaScript string literal embedded inside an HTML attribute**.\n\nBrowsers decode HTML entities in attribute values **before** the JavaScript engine parses the string. As a result, `&#039;` is decoded back to `'`, which terminates the JS string early and allows the remainder of the value to be executed as JavaScript.\n\nThe combined display name (`nv_show_name_user(first_name, last_name)`) is what reaches the template, giving an attacker up to ~200 encoded characters across both fields — sufficient for any practical payload.\n\n## Proof of Concept\n\nSet `first_name` to the following value in profile settings (`/index.php?nv=users&op=editinfo`), then post any comment:\n\n```text\na');alert(document.domain);//\n```\n\nThe value is stored as `a&#039;&#41;;alert&#40;document.domain&#41;;&#x002F;&#x002F;`.\n\nWhen a visitor clicks the Reply link on the comment, the browser renders:\n\n```js\nnv_commment_feedback(event, 1, 'a');alert(document.domain);// Tester')\n```\n\ncausing `alert(document.domain)` to execute in the visitor's browser context.\n\nA data-exfiltration variant (split across both name fields) navigates the victim's browser to an attacker-controlled URL carrying `document.cookie` as a query parameter. End-to-end verification was performed using a local listener.\n\n## Exploitation Conditions (default configuration)\n\n| Condition | Default value | Effect |\n|---|---|---|\n| `captcha_area_comm` | `1` | No CAPTCHA for logged-in users — payload delivery requires no CAPTCHA solve |\n| `auto_postcomm` | enabled | Comments are published immediately without moderation |\n| `active_editinfo_censor` | `0` | Profile edits take effect immediately without admin review |\n| CSP `script-src` | `'unsafe-inline'` | Inline `onclick` handlers execute normally |\n\nAny registered member can set the payload and post a comment with no additional steps.\n\nIf `captcha_area_comm` is set to `0`, the `name` field of anonymous comments (`modules/comment/funcs/post.php`) is processed by the same `get_title(..., 1)` call, making exploitation possible without authentication.\n\n## Impact\n\nAn attacker with a regular user account can execute arbitrary JavaScript in the browser of any visitor who interacts with the Reply button on their comment, including site administrators.\n\nPractical consequences include:\n\n- **Privilege escalation via admin session hijacking** — forging administrative actions (content modification, account manipulation) in the context of an authenticated admin.\n- **Credential phishing** — injecting a fake login form into the page.\n- **Data exfiltration** — reading page content and non-`HttpOnly` cookies.\n\n> Note: NukeViet session cookies carry the `HttpOnly` flag, so they are not directly readable via `document.cookie`; however, the above attack vectors remain fully viable.\n\n## Remediation\n\n**Preferred fix:** Remove `post_name` from the inline handler entirely. Pass only `cid` to `nv_commment_feedback` and have the function retrieve the display name from the already-rendered DOM (e.g., the adjacent `<strong class=\"cm_item\">` element).\n\n**Alternative fix:** If the value must be passed inline, encode it with `json_encode($post_name)` (PHP) so that the output is a properly escaped JavaScript string literal, not an HTML-entity-encoded one. HTML numeric character references must not be relied upon for JavaScript string escaping.\n\nAs a general note, the result of `get_title(..., $specialchars=true)` is safe for HTML element content and quoted HTML attribute values, but **unsafe when placed inside a JavaScript string literal within an attribute**. Other locations in the codebase using the same pattern should be audited.\n\n## Resources\n\n- OWASP: Cross Site Scripting Prevention — Rule 2: Attribute Encoding is Not Sufficient for JS Contexts\n- CWE-79: Improper Neutralization of Input During Web Page Generation\n- CWE-116: Improper Encoding or Escaping of Output","published":"2026-07-13T17:22:26Z","modified":"2026-07-13T17:41:46.435798Z","cvss":{"score":8.7,"severity":"HIGH","vector":"CVSS:3.1/AV:N/AC:L/PR:L/UI:R/S:C/C:H/I:H/A:N"},"epss":null,"cisaKev":null,"exploitsKnown":null,"affectedPackages":[{"ecosystem":"Packagist","name":"nukeviet/nukeviet","fixedVersion":"4.6.00"}],"fix":null,"references":[{"type":"WEB","url":"https://github.com/nukeviet/nukeviet/security/advisories/GHSA-w2w5-w2pw-r929"},{"type":"PACKAGE","url":"https://github.com/nukeviet/nukeviet"}],"provenance":{"sources":["OSV.dev","FIRST.org (EPSS)"],"lastVerified":"2026-07-13T17:41:46.435798Z"}}