/

CVE-2026-43938

Severity:

HIGH RISK

(8.1)

Stored XSS in YetAnotherForum.NET Event Log Rendering

CVE-2026-43938

Deferred

Vulnerability type

Category:

Stored Cross-Site Scripting (XSS)

CWE:

CWE-79, CWE-80, CWE-116

Impact:

Stored XSS in administrative event log leading to potential admin session compromise

Severity:

HIGH RISK

(8.1)

CVSS version:

3.1

Catch this CVE while code is being written

Detect vulnerable code directly in pull requests, so CVEs are fixed before merge.

Summary

YetAnotherForum.NET contains a stored cross-site scripting issue where User-Agent header data is logged, deserialized, and then written into HTML without encoding in the admin event-log view.

If an attacker can cause a crafted User-Agent value to be logged, it may later execute as script in an administrator's browser when viewing the event log, enabling session theft or administrative account takeover.

Affected context

The vulnerability occurs in YetAnotherForum.NET's diagnostic logging and administrative event-log interface.

When an event such as an unhandled exception is logged, the DbLogger captures the incoming HTTP request's User-Agent header, stores it as JSON in the EventLog.Description column, and the admin EventLog page later reads and formats this data.

The issue is present when:

  • Event logging is enabled and writing request metadata to the database.
  • Administrators regularly view the Event Log page in the web UI.
  • User-Agent values are treated as data, but not encoded or sanitized before being emitted as HTML.

Exploit preconditions

  • Attack surface: Public or internal web endpoints of the YAF.NET forum that result in logged events (e.g., error paths, unexpected exceptions).
  • Required access: Ability to send HTTP requests to the application where the attacker controls the User-Agent header (no authentication necessarily required).
  • Trigger point: An event occurs that causes DbLogger to record the request, including the crafted User-Agent, into the EventLog.Description column.
  • Execution phase: An administrator later opens the Event Log page, which deserializes the JSON, interpolates the UserAgent into an HTML string, and renders it via @Html.Raw.
  • Why exploitation is possible: Untrusted request metadata is persisted and subsequently rendered into HTML without proper encoding or output contextualization, meeting the conditions for stored XSS.

Why this happens

The core bug is treating untrusted, user-controlled text (the User-Agent header) as safe HTML when displaying it in an administrative view.

At log time, the application serializes request metadata, including User-Agent, to JSON and stores it in the database. At display time, the admin EventLog handler deserializes this JSON, interpolates the raw UserAgent value into an HTML string, and passes it to the Razor view, which uses @Html.Raw to render it directly.

This pattern violates output encoding best practices and maps to:

  • CWE-79: Improper Neutralization of Input During Web Page Generation (Cross-site Scripting), because user-controlled data is injected into a web page without neutralization.
  • CWE-80: Improper Neutralization of Script-Related HTML Tags in a Web Page, as script-capable HTML markup is allowed to pass straight through.
  • CWE-116: Improper Encoding or Escaping of Output, since no context-appropriate encoding is applied before rendering.

Potential impact

  • An attacker-controlled script may execute in the context of an administrator's browser when they view the Event Log page.
  • Malicious JavaScript can potentially read cookies or local storage associated with the admin session (subject to HttpOnly and other flags).
  • The attacker could perform actions on behalf of the administrator (e.g., creating new admin users, changing configuration) using the admin's privileges.
  • The event log pages may become a persistent delivery channel for phishing or malware content within the internal admin interface.
  • In multi-admin environments, one compromised log entry could affect any administrator who views that log record.

General mitigation guidance

Mitigation should focus on strict output encoding and avoiding unsafe HTML rendering of log data:

  • Apply context-appropriate HTML encoding to all user-controlled fields (such as User-Agent) before inserting them into HTML templates, especially when using constructs like @Html.Raw.
  • Avoid constructing HTML strings by concatenating or interpolating raw values; instead, pass data as plain text to the view and let the templating engine encode by default.
  • Treat all request-derived metadata (headers, query parameters, form fields, cookies) as untrusted, even if they are not typically exposed in normal UI flows.
  • Consider storing log data as plain text or structured fields without embedding HTML markup, and render them using safe helpers that do not bypass encoding.
  • Use least-privilege concepts for administrative pages, and, where possible, separate high-risk diagnostic data from primary admin interfaces to reduce exposure.

How teams detect issues like this

Detection can leverage a combination of code review, automated analysis, and runtime testing:

  • Static analysis: Configure rules to flag usage of @Html.Raw, string concatenation into HTML, and any rendering of request headers or other user-controlled data without encoding.
  • Code review: During manual reviews, explicitly check logging and diagnostics features for places where stored user input is later rendered in web views; scrutinize helpers like FormatStackTrace() that transform log data into HTML.
  • Security unit/integration tests: Add tests that inject HTML/script payloads into headers like User-Agent and verify that the rendered admin pages display them as escaped text, not as executable code.
  • Policy enforcement: Establish secure coding guidelines that prohibit direct use of raw HTML rendering for untrusted data, and integrate linters or CI checks to prevent unsafe patterns from entering the codebase.

Sources

SourceLink
github.comgithub.com/YAFNET/YAFNET/security/advisories/GHSA-33gv-fc78-qgf5

Frequently asked

questions

Yes. An attacker only needs the ability to send HTTP requests to the application and control the User-Agent header. Once a triggering event causes the request to be logged, the payload is stored and later rendered in the admin interface.

The attacker does not need admin privileges to inject the payload; they just need to reach a code path that logs their request. However, script execution occurs only when an authenticated administrator opens the Event Log page in their browser.

Ensure that all user-controlled data is properly HTML-encoded before rendering, avoid using @Html.Raw on untrusted values, and eliminate any string-building logic that embeds raw request data into HTML. Treat logging output as plain text rather than HTML where possible.

Adopt a default-encode-everything stance, rely on the templating engine's automatic encoding instead of overriding it, add static analysis or linting rules for unsafe HTML rendering APIs, and include XSS-focused checks in code review and security testing for all new logging or admin UI features.

Find out what's already
exploitable in your codebase.