CWE-1385 Variant Incomplete

Missing Origin Validation in WebSockets

This vulnerability occurs when a WebSocket connection is established without verifying the origin of incoming messages, allowing potentially malicious data from untrusted sources.

Definition

What is CWE-1385?

This vulnerability occurs when a WebSocket connection is established without verifying the origin of incoming messages, allowing potentially malicious data from untrusted sources.
WebSockets enable persistent, two-way communication between a client and server, which is ideal for real-time features. Unlike standard HTTP requests, these connections stay open and are not automatically restricted by browser security policies like the Same-Origin Policy (SOP) or Cross-Origin Resource Sharing (CORS). This means a WebSocket can receive messages from any origin unless the server explicitly validates where the connection is coming from. Without proper origin checks, attackers can exploit these open channels to launch powerful Cross-Site Request Forgery (CSRF) attacks or send malicious data. To prevent this, developers must implement server-side validation for every WebSocket connection request, ensuring it originates from a trusted and expected domain before allowing communication to proceed.
Auswirkungen in der Praxis

Real-world CVEs caused by CWE-1385

  • web console for SIEM product does not check Origin header, allowing Cross Site WebSocket Hijacking (CSWH)

  • Chain: gaming client attempts to validate the Origin header, but only uses a substring, allowing Cross-Site WebSocket hijacking by forcing requests from an origin whose hostname is a substring of the valid origin.

  • WebSocket server does not check the origin of requests, allowing attackers to steal developer's code using a ws://127.0.0.1:3123/ connection.

  • WebSocket server does not check the origin of requests, allowing attackers to steal developer's code using a ws://127.0.0.1/ connection to a randomized port number.

  • WebSocket server does not check the origin of requests, allowing attackers to steal developer's code using a ws://127.0.0.1:8080/ connection.

Wie Angreifer es ausnutzen

Angreiferpfad Schritt für Schritt

  1. 1

    Identifiziere einen Codepfad, der nicht vertrauenswürdige Eingaben ohne Validierung verarbeitet.

  2. 2

    Erzeuge eine Payload, die das unsichere Verhalten auslöst — Injection, Traversal, Overflow oder Logik-Missbrauch.

  3. 3

    Liefere die Payload über einen normalen Request aus und beobachte die Reaktion der Anwendung.

  4. 4

    Iteriere, bis die Antwort Daten preisgibt, Angreifer-Code ausführt oder Berechtigungen eskaliert.

Verwundbares Codebeispiel

Vulnerable pseudo

MITRE hat kein Codebeispiel für diese CWE veröffentlicht. Das untenstehende Muster ist illustrativ — kanonische Referenzen findest du unter Ressourcen.

Verwundbar pseudo
// Example pattern — see MITRE for the canonical references.
function handleRequest(input) {
  // Untrusted input flows directly into the sensitive sink.
  return executeUnsafe(input);
}
Sicheres Codebeispiel

Secure pseudo

Sicher pseudo
// Validate, sanitize, or use a safe API before reaching the sink.
function handleRequest(input) {
  const safe = validateAndEscape(input);
  return executeWithGuards(safe);
}
What changed: the unsafe sink is replaced (or the input is validated/escaped) so the same payload no longer triggers the weakness.
Präventions-Checkliste

How to prevent CWE-1385

  • Implementation Enable CORS-like access restrictions by verifying the 'Origin' header during the WebSocket handshake.
  • Implementation Use a randomized CSRF token to verify requests.
  • Implementation Use TLS to securely communicate using 'wss' (WebSocket Secure) instead of 'ws'.
  • Architecture and Design / Implementation Require user authentication prior to the WebSocket connection being established. For example, the WS library in Node has a 'verifyClient' function.
  • Implementation Leverage rate limiting to prevent against DoS. Use of the leaky bucket algorithm can help with this.
  • Implementation Use a library that provides restriction of the payload size. For example, WS library for Node includes 'maxPayloadoption' that can be set.
  • Implementation Treat data/input as untrusted in both directions and apply the same data/input sanitization as XSS, SQLi, etc.
Erkennungssignale

How to detect CWE-1385

SAST High

Führe statische Analyse (SAST) auf der Codebasis aus und suche im Datenfluss nach dem unsicheren Muster.

DAST Moderate

Führe dynamische Application-Security-Tests gegen den Live-Endpoint aus.

Runtime Moderate

Beobachte Runtime-Logs auf ungewöhnliche Exception-Traces, fehlerhafte Eingaben oder Versuche, Autorisierung zu umgehen.

Code review Moderate

Code Review: Markiere jeden neuen Code, der Eingaben von dieser Oberfläche ohne validierte Framework-Helper verarbeitet.

Plexicus Auto-Fix

Plexicus erkennt CWE-1385 automatisch und öffnet in unter 60 Sekunden einen Fix-PR.

Codex Remedium scannt jeden Commit, identifiziert genau diese Schwachstelle und liefert einen reviewer-ready Pull Request mit dem Patch. Keine Tickets. Keine Hand-offs.

Häufig gestellte Fragen

Frequently asked questions

Was ist CWE-1385?

This vulnerability occurs when a WebSocket connection is established without verifying the origin of incoming messages, allowing potentially malicious data from untrusted sources.

Wie gravierend ist CWE-1385?

MITRE hat für diese Schwachstelle keine Exploit-Wahrscheinlichkeit veröffentlicht. Behandle sie als mittlere Auswirkung, bis dein Threat Model anderes belegt.

Welche Sprachen oder Plattformen sind von CWE-1385 betroffen?

MITRE lists the following affected platforms: Web Server.

Wie kann ich CWE-1385 verhindern?

Enable CORS-like access restrictions by verifying the 'Origin' header during the WebSocket handshake. Use a randomized CSRF token to verify requests.

Wie erkennt und behebt Plexicus CWE-1385?

Die SAST-Engine von Plexicus erkennt die Datenfluss-Signatur von CWE-1385 bei jedem Commit. Bei einem Treffer öffnet unser Codex-Remedium-Agent einen Fix-PR mit korrigiertem Code, Tests und einer einzeiligen Zusammenfassung für den Reviewer.

Wo erfahre ich mehr über CWE-1385?

MITRE veröffentlicht die kanonische Definition unter https://cwe.mitre.org/data/definitions/1385.html. Für ergänzende Hinweise kannst du auch die OWASP- und NIST-Dokumentation heranziehen.

Bereit, wenn du es bist

Schluss mit dem Bezahlen pro Entwickler.
Schließ den Kreislauf.

Plexicus ist die KI-native ASPM, die scannt, filtert, fixt, pentestet und erklärt — autonom. Unbegrenzte Entwickler, unbegrenzte Repos, Fair-Use-KI-Aktionen. Echter kostenloser Tarif, €269/mo jährlich, wenn du bereit bist.