/

CVE-2026-40911

Severity:

CRITICAL RISK

(10.0)

Code Injection in AVideo YPTSocket WebSocket Plugin

CVE-2026-40911

Analyzed

Vulnerability type

Category:

Code Injection

CWE:

CWE-94

Impact:

Arbitrary JavaScript Execution / Universal Cross-Site Scripting

Severity:

CRITICAL RISK

(10.0)

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

The YPTSocket plugin in WWBN AVideo relays attacker-supplied JSON fields directly into client-side eval() calls, enabling arbitrary JavaScript execution in users' browsers.

Because anonymous tokens are minted and accepted without meaningful revalidation, an unauthenticated attacker can broadcast malicious scripts to all connected clients, potentially taking over accounts and performing privileged actions.

Affected context

The vulnerability occurs in deployments of WWBN AVideo (version 29.0 and prior) that:

  • Enable and use the YPTSocket plugin's WebSocket server
  • Maintain active browser sessions connected to the site (including administrators and privileged users)
  • Accept JSON messages from clients and relay them to all connected peers

Under these conditions, untrusted message fields are propagated to every connected client and processed with eval() in the context of the AVideo origin, turning the messaging channel into a broadcast code-execution vector.

Exploit preconditions

  • Attack surface: Browser clients connected to the AVideo site via the YPTSocket WebSocket.
  • Required access: Network-level ability to reach the WebSocket endpoint; no authenticated account is required because tokens are minted for anonymous visitors and only decrypted, not revalidated.
  • Trigger point: Sending a crafted JSON message to the WebSocket server where the msg.autoEvalCodeOnHTML or callback fields contain attacker-controlled JavaScript.
  • Why exploitation is possible:
  • The WebSocket backend relays msg and callback from attacker messages to all connected clients without sanitization or filtering.
  • The client-side plugin/YPTSocket/script.js file uses eval() on json.msg.autoEvalCodeOnHTML (around line 568) and on json.callback (around line 95).
  • Token handling does not enforce strong authentication or revalidation, allowing unauthenticated attackers to participate in the channel and inject arbitrary script.

Why this happens

This issue stems from unsafe code evaluation in the client-side plugin combined with insufficient trust boundaries on WebSocket messages.

The YPTSocket JavaScript code calls eval() directly on fields sourced from the WebSocket payload, treating arbitrary, attacker-controlled JSON fields as executable JavaScript.

On the server side, incoming JSON is rebroadcast to all clients without normalization, sanitization, or origin checks, so data from any participant is implicitly trusted by every recipient.

This pattern maps to CWE-94: Improper Control of Generation of Code ('Code Injection'), where untrusted data is incorporated into dynamically evaluated code.

The absence of strict authentication, authorization, and token revalidation on the WebSocket layer further erodes the trust barrier, allowing unauthenticated message senders to influence privileged clients.

Potential impact

  • Execution of arbitrary JavaScript in the browser of every connected user, including administrators.
  • Theft of session cookies, access tokens, or other authentication artifacts accessible to JavaScript.
  • Forced performance of privileged actions on behalf of administrators (e.g., creating or deleting content, modifying configuration, or managing users).
  • Installation of persistent browser-side payloads such as malicious scripts injected into user-facing pages.
  • Lateral movement through reuse of stolen administrator sessions to reconfigure the platform or reach additional systems.
  • Phishing, content defacement, or delivery of further malware to end users via the compromised web interface.

General mitigation guidance

Effective mitigation focuses on removing dynamic code execution paths and tightening trust boundaries for real-time messaging:

  • Replace eval():
  • Avoid eval() and similar dynamic evaluation APIs entirely in the WebSocket client.
  • Use explicit dispatch tables or switch statements to map message types to predefined handler functions.
  • Treat message fields as data only; never interpret them as code or JavaScript expressions.
  • Constrain message formats:
  • Define a strict JSON schema for WebSocket messages and reject any fields that do not conform.
  • Parse incoming messages into strongly-typed structures, and process only known, safe attributes.
  • Sanitize and encode untrusted data:
  • When displaying message content, use safe DOM APIs that treat inputs as text, not HTML or script.
  • Apply contextual output encoding when data must be inserted into the DOM to prevent script injection.
  • Strengthen authentication and authorization on sockets:
  • Tie WebSocket connections to authenticated user sessions with short-lived, verifiable tokens.
  • Revalidate tokens and permissions server-side before accepting or broadcasting client messages.
  • Consider segregating broadcast channels by role or room to avoid universal impact from a single client.
  • Apply least privilege on client capabilities:
  • Limit which clients are allowed to send control or callback-related messages.
  • Avoid giving anonymous or low-privilege users the ability to trigger actions affecting all clients.

These measures turn the WebSocket channel into a controlled messaging medium rather than a vehicle for remote code execution.

How teams detect issues like this

Detection can leverage both code-centric and behavior-centric approaches:

  • Static analysis and linters:
  • Configure rules to flag uses of eval(), Function(), or similar dynamic evaluation APIs in client JavaScript.
  • Add patterns that specifically detect dynamic evaluation of data sourced from network APIs or WebSocket messages.
  • Code review practices:
  • During review, scrutinize any logic that:
  • Parses JSON from sockets or HTTP APIs and then executes or injects it into the DOM.
  • Uses generic "callback" or "script" fields as strings to be run in the browser.
  • Ensure reviewers verify that message schemas are defined and enforced at both server and client.
  • Security testing and fuzzing:
  • Perform application-level penetration tests targeting WebSocket endpoints with crafted JSON messages.
  • Use browser-based testing tools to identify DOM and script injection through real-time channels.
  • Runtime monitoring:
  • Instrument logging to capture unexpected message types or fields on the WebSocket server.
  • Use Content Security Policy (CSP) reports to detect inline script execution or eval() usage at runtime where possible.
  • Automated tooling:
  • Integrate SAST or dependency analysis tools into CI pipelines to detect dangerous API usage and known insecure patterns in plugins.

Combining these techniques helps organizations detect both this specific issue and similar code injection risks in future changes.

Sources

SourceLink
github.comgithub.com/WWBN/AVideo/commit/c08694bf6264eb4decceb78c711baee2609b4efd
github.comgithub.com/WWBN/AVideo/security/advisories/GHSA-gph2-j4c9-vhhr

Frequently asked

questions

Yes. As long as an attacker can reach the AVideo instance's WebSocket endpoint, they can participate as an anonymous client, send crafted JSON messages, and trigger arbitrary JavaScript execution in the browsers of all connected users.

No. The design mints tokens for anonymous visitors and only decrypts them for use, without robust revalidation or permission checks. This means an attacker does not need a registered account to inject malicious messages into the WebSocket channel.

The most robust fix is to eliminate dynamic code evaluation: remove eval() calls and similar APIs from the client, treat all WebSocket data as plain data, and route messages through explicit, predefined handlers. Pair this with strict JSON schemas and server-side validation so that unrecognized or malformed messages are discarded.

Avoid designing protocols that carry executable code; instead, send structured data and interpret it in fixed logic. Enforce strong authentication and authorization for real-time communication channels, use static analysis to block new uses of eval-like APIs, and ensure code reviews explicitly examine any feature that processes untrusted input from WebSockets or other live messaging systems.

Find out what's already
exploitable in your codebase.