Skip to main content
Menu
Advisories

Unauthenticated Stored XSS in the Contact module

GHSA-662Q-V5RM-78GMPublished Updated GitHub

Description

A stored-XSS vulnerability in the Contact module allows any unauthenticated user to inject malicious Javascript.

Details

NukeViet's central input filter (NukeViet\Core\Request::filterTags), applied to virtually all POST data, is a denylist HTML sanitizer. Its most important rule strips any attribute whose name matches /^on/i (event handlers). This rule is bypassable through an HTML parser differential: the filter tokenizes a tag's attributes by splitting on ASCII space (0x20) only, whereas browsers also separate attributes on /. By inserting a / immediately before an event-handler name, the attacker makes the filter read the attribute name as /onerror — which does not start with on, so the denylist misses it — while the browser parses it as onerror and fires it.

The payload survives the entire filter chain unmodified and is stored and served raw (no output encoding) into the administration panel, which sends no Content-Security-Policy:

INPUT  : <img src=x /onerror=alert(document.domain)>
STORED : <img src="x" /onerror="alert(document.domain)" />
ADMIN  : <td colspan="2"><img src="x" /onerror="alert(document.domain)" /></td>

Because the handler executes in the same origin as the admin panel, an unauthenticated attacker who submits a crafted contact message obtains arbitrary JavaScript execution in the session of any administrator who opens it — enabling administrator account takeover.

PoC

Minimal payload

<img src=x /onerror=alert(document.domain)>

alert(document.domain) displays the site's real origin (e.g. the target host), proving same-origin execution.

Manual reproduction (fresh 4.6.00 install, default config)

  1. As an anonymous visitor open /contact/; set the message field to the payload above.
  2. Solve the CAPTCHA and submit (form returns status: ok).
  3. Log in to the admin panel; open Admin → Contact and view the message (admin/index.php?nv=contact&op=view&id=<id>).
  4. onerror fires on view; alert() shows the panel's own origin.

Impact

An unauthenticated attacker achieves arbitrary JavaScript execution in the same origin as the NukeViet admin panel, running in the session of any administrator who views the malicious contact message. Possible attacks:

  1. Super admin account persistence
  2. RCE via admin functions

Mitigation

  1. Tokenize attributes the way the HTML spec does. In filterTags(), treat / (and all HTML whitespace: tab, LF, FF, CR, space) as attribute separators, so /onerror is parsed as the token onerror and caught by the existing denylist. Equivalently, strip leading / and other non-name characters from the attribute name before the ^on test.
  2. Do not preserve non-conforming attribute names. Reject/normalize any attribute whose name is not [A-Za-z][A-Za-z0-9-]* after normalization, rather than emitting /onerror verbatim.
  3. Prefer an allowlist of attributes over the ^on denylist; drop anything not explicitly permitted for the element.

Affected versions

References

GitHub · nukeviet/nukeviet