Read Time:2 Minute, 12 Second

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

CWE-346

 

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.