Executar análise estática (SAST) na base de código à procura do padrão inseguro no fluxo de dados.
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.
What is CWE-1385?
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.
Trajeto do atacante passo a passo
- 1
Identificar um caminho de código que trata input não confiável sem validação.
- 2
Criar um payload que explora o comportamento inseguro — injeção, traversal, overflow ou abuso de lógica.
- 3
Entregar o payload através de um pedido normal e observar a reação da aplicação.
- 4
Iterar até que a resposta exponha dados, execute código do atacante ou escale privilégios.
Vulnerable pseudo
A MITRE não publicou um exemplo de código para este CWE. O padrão abaixo é ilustrativo — consulte os Recursos para referências canónicas.
// Example pattern — see MITRE for the canonical references.
function handleRequest(input) {
// Untrusted input flows directly into the sensitive sink.
return executeUnsafe(input);
} Secure pseudo
// Validate, sanitize, or use a safe API before reaching the sink.
function handleRequest(input) {
const safe = validateAndEscape(input);
return executeWithGuards(safe);
} 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.
How to detect CWE-1385
Executar testes dinâmicos de segurança de aplicações (DAST) contra o endpoint em execução.
Monitorizar os registos em tempo de execução para traços de exceção invulgares, input malformado ou tentativas de contornar a autorização.
Revisão de código: sinalizar qualquer novo código que trate input desta superfície sem usar os ajudantes validados do framework.
O Plexicus deteta automaticamente o CWE-1385 e abre um PR de correção em menos de 60 segundos.
O Codex Remedium analisa cada commit, identifica esta fraqueza exata e entrega um pull request pronto para revisão com o patch. Sem tickets. Sem transferências.
Frequently asked questions
O que é o 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.
Qual a gravidade do CWE-1385?
A MITRE não publicou uma classificação de probabilidade de exploração para esta fraqueza. Trate-a como impacto médio até o seu modelo de ameaças provar o contrário.
Que linguagens ou plataformas são afetadas pelo CWE-1385?
MITRE lists the following affected platforms: Web Server.
Como posso prevenir o CWE-1385?
Enable CORS-like access restrictions by verifying the 'Origin' header during the WebSocket handshake. Use a randomized CSRF token to verify requests.
Como é que o Plexicus deteta e corrige o CWE-1385?
O motor SAST do Plexicus correlaciona a assinatura de fluxo de dados do CWE-1385 em cada commit. Quando é encontrada uma correspondência, o nosso agente Codex Remedium abre um PR de correção com o código corrigido, testes e um resumo de uma linha para o revisor.
Onde posso saber mais sobre o CWE-1385?
A MITRE publica a definição canónica em https://cwe.mitre.org/data/definitions/1385.html. Pode também consultar a documentação da OWASP e do NIST para orientações adjacentes.
Weaknesses related to CWE-1385
Origin Validation Error
This vulnerability occurs when an application fails to properly confirm the true origin of incoming data or communication, allowing…
Improper Verification of Source of a Communication Channel
This vulnerability occurs when an application accepts incoming communication requests without properly checking where they originate from,…
Further reading
- MITRE — CWE-1385 oficial https://cwe.mitre.org/data/definitions/1385.html
- Cross-Site WebSocket Hijacking (CSWSH) https://christian-schneider.net/blog/cross-site-websocket-hijacking/
- WebSockets not Bound by SOP and CORS? Does this mean... https://blog.securityevaluators.com/websockets-not-bound-by-cors-does-this-mean-2e7819374acc
- How to secure your WebSocket connections https://www.freecodecamp.org/news/how-to-secure-your-websocket-connections-d0be0996c556/
- Cross-Site WebSocket Hijacking (CSWSH) https://medium.com/swlh/hacking-websocket-25d3cba6a4b9
- Testing for WebSockets security vulnerabilities https://portswigger.net/web-security/websockets
Pare de pagar por desenvolvedor.
Comece a fechar o ciclo.
O Plexicus é o ASPM nativo de IA que verifica, filtra, corrige, pentesta e explica — de forma autónoma. Programadores ilimitados, repos ilimitados, ações de IA de utilização justa. Nível gratuito real, €269/mo anual quando estiver pronto.