Description
The software uses a WebSocket, but it does not properly verify that the source of data or communication is valid.
Modes of Introduction:
– Architecture and Design
Related Weaknesses
Consequences
Confidentiality, Integrity, Availability, Non-Repudiation, Access Control: Varies by Context, Gain Privileges or Assume Identity, Bypass Protection Mechanism, Read Application Data, Modify Application Data, DoS: Crash, Exit, or Restart
The consequences will vary depending on the nature of the functionality that is vulnerable to CSRF. An attacker could effectively perform any operations as the victim. If the victim is an administrator or privileged user, the consequences may include obtaining complete control over the web application – deleting or stealing data, uninstalling the product, or using it to launch other attacks against all of the product’s users. Because the attacker has the identity of the victim, the scope of the CSRF is limited only by the victim’s privileges.
Potential Mitigations
Phase: Implementation
Description:
Enable CORS-like access restrictions by verifying the ‘Origin’ header during the WebSocket handshake.
Phase: Implementation
Description:
Use a randomized CSRF token to verify requests.
Phase: Implementation
Description:
Use TLS to securely communicate using ‘wss’ (WebSocket Secure) instead of ‘ws’.
Phase: Architecture and Design, Implementation
Description:
Require user authentication prior to the WebSocket connection being established. For example, the WS library in Node has a ‘verifyClient’ function.
Phase: Implementation
Effectiveness: Defense in Depth
Description:
Leverage rate limiting to prevent against DoS. Use of the leaky bucket algorithm can help with this.
Phase: Implementation
Effectiveness: Defense in Depth
Description:
Use a library that provides restriction of the payload size. For example, WS library for Node includes ‘maxPayloadoption’ that can be set.
Phase: Implementation
Description:
Treat data/input as untrusted in both directions and apply the same data/input sanitization as XSS, SQLi, etc.
CVE References
- CVE-2020-25095
- web console for SIEM product does not check Origin header, allowing Cross Site WebSocket Hijacking (CSWH)
- CVE-2018-6651
- 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.
- CVE-2018-14730
- 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.
- CVE-2018-14731
- 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.
- CVE-2018-14732
- 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.
More Stories
The Most Dangerous Vulnerabilities in Apache Tomcat and How to Protect Against Them
Apache Tomcat is an open-source web server and servlet container that is widely used in enterprise environments to run Java...
ZDI-CAN-18333: A Critical Zero-Day Vulnerability in Microsoft Windows
Zero-day vulnerabilities are a serious threat to cybersecurity, as they can be exploited by malicious actors to gain unauthorized access...
CWE-669 – Incorrect Resource Transfer Between Spheres
Description The product does not properly transfer a resource/behavior to another sphere, or improperly imports a resource/behavior from another sphere,...
CWE-67 – Improper Handling of Windows Device Names
Description The software constructs pathnames from user input, but it does not handle or incorrectly handles a pathname containing a...
CWE-670 – Always-Incorrect Control Flow Implementation
Description The code contains a control flow path that does not reflect the algorithm that the path is intended to...
CWE-671 – Lack of Administrator Control over Security
Description The product uses security features in a way that prevents the product's administrator from tailoring security settings to reflect...