Skip to content

Latest commit

 

History

History
68 lines (55 loc) · 7.94 KB

attack-surface.md

File metadata and controls

68 lines (55 loc) · 7.94 KB

Attack Surface Analysis for ossrs/srs

  • Description: Attackers craft specially designed, invalid RTMP packets to trigger vulnerabilities in SRS's RTMP parsing and processing code.
  • SRS Contribution: SRS's core function is to parse and process RTMP streams; its RTMP handling logic is a direct target.
  • Example: An attacker sends an RTMP packet with an overly large chunk size field, aiming to cause a buffer overflow in SRS's memory allocation routines.
  • Impact: Denial of Service (DoS), Remote Code Execution (RCE).
  • Risk Severity: Critical (if RCE is possible), High (for DoS).
  • Mitigation Strategies:
    • Developers: Implement robust input validation and sanitization for all RTMP packet fields. Use memory-safe programming techniques (e.g., bounds checking, safe string handling). Employ fuzz testing specifically targeting the RTMP parsing logic. Consider using a memory-safe language or runtime protections.
    • Users: Keep SRS updated to the latest version. Monitor server logs for unusual RTMP activity. (Network filtering is helpful but doesn't address the direct SRS vulnerability).
  • Description: Attackers inject malicious commands or parameters into RTMP commands, HTTP-FLV requests, or WebRTC SDP offers/answers, exploiting vulnerabilities in how SRS internally handles these inputs before potentially passing them to hooks or other components. This focuses on the direct handling within SRS, not just the presence of hooks.
  • SRS Contribution: SRS must parse and process these commands and data; the internal handling logic is the direct vulnerability.
  • Example: An attacker injects a specially crafted string into an RTMP connect command's application name parameter that, even before any hook is called, causes an internal buffer overflow within SRS's string handling.
  • Impact: Unauthorized access to streams (if authentication is bypassed internally), server configuration modification (if internal settings are affected), RCE (if internal processing leads to code execution), DoS.
  • Risk Severity: Critical (if RCE is possible), High (for unauthorized access/modification).
  • Mitigation Strategies:
    • Developers: Strictly validate and sanitize all user-supplied input within RTMP commands, HTTP parameters, and SDP data at the point of parsing and internal use. Avoid using user-supplied data directly in any internal logic that could lead to unintended behavior. Implement strict input length limits.
    • Users: Keep SRS updated. (While hook script security is important, this item focuses on vulnerabilities before hooks are even involved).
  • Description: Attackers bypass SRS's internal authentication mechanisms for RTMP, the HTTP API, or WebRTC, gaining unauthorized access. This focuses on flaws in SRS's own authentication code, not just misconfigured hooks.
  • SRS Contribution: SRS implements authentication; flaws in this implementation are direct vulnerabilities.
  • Example: A logic error in SRS's RTMP authentication code allows an attacker to skip a crucial validation step, granting access without valid credentials. Or, a vulnerability in the HTTP API's authentication handling allows bypassing the password check.
  • Impact: Unauthorized access to streams, server control (via API), data breaches.
  • Risk Severity: Critical (for API access), High (for stream access).
  • Mitigation Strategies:
    • Developers: Implement strong authentication mechanisms with secure password hashing and storage within the core SRS code. Use well-vetted authentication libraries. Thoroughly test authentication logic, including edge cases and bypass attempts. Ensure that authentication checks are performed before any potentially dangerous actions.
    • Users: Keep SRS updated. (While strong passwords are important, this focuses on vulnerabilities in SRS's own authentication handling).
  • Description: Attackers flood SRS with connection requests, stream requests, or data, overwhelming server resources and causing a denial of service. This focuses on SRS's ability to handle these requests, not just the presence of limits.
  • SRS Contribution: SRS's primary function is to handle connections and streams; its efficiency and robustness in handling these are directly related to its vulnerability.
  • Example: An attacker initiates thousands of simultaneous RTMP connection attempts, and even with connection limits configured, a vulnerability in SRS's connection handling code causes excessive memory allocation, leading to a crash.
  • Impact: Denial of Service (DoS).
  • Risk Severity: High.
  • Mitigation Strategies:
    • Developers: Optimize code for performance and resource efficiency in handling connections and streams. Implement robust error handling and resource management. Ensure that resource limits are effectively enforced by the core code, not just configured.
    • Users: Keep SRS updated. (While configuration limits are important, this focuses on SRS's inherent ability to handle load).
  • Description: Attackers exploit vulnerabilities specific to the SRT or WebRTC protocols within SRS's implementation of DTLS, SRTP, ICE, etc.
  • SRS Contribution: SRS implements these protocols; vulnerabilities in its implementation are direct attack vectors.
  • Example: An attacker exploits a vulnerability in SRS's DTLS handshake implementation to perform a denial-of-service attack against WebRTC clients. This is a flaw in SRS's code, not just a misconfiguration.
  • Impact: DoS, eavesdropping, data modification, man-in-the-middle attacks.
  • Risk Severity: High to Critical.
  • Mitigation Strategies:
    • Developers: Follow best practices for secure implementation of these protocols. Use well-vetted libraries for DTLS, SRTP, and ICE. Stay up-to-date with security advisories related to these protocols. Perform thorough security testing, including fuzzing and penetration testing, specifically targeting the protocol implementations.
    • Users: Keep SRS updated.
  • Description: Vulnerabilities in libraries that SRS depends on (e.g., ST, libsrt, OpenSSL) are exploited, directly affecting SRS's operation.
  • SRS Contribution: SRS relies on these libraries; their vulnerabilities become part of SRS's direct attack surface.
  • Example: A vulnerability in libsrt allows an attacker to cause a denial of service by sending malformed SRT packets, crashing SRS.
  • Impact: Varies depending on the vulnerability, but can range from DoS to RCE.
  • Risk Severity: Varies (Critical to High), depending on the specific vulnerability.
  • Mitigation Strategies:
    • Developers: Regularly update dependencies to the latest secure versions. Monitor security advisories for all dependencies. Consider using dependency scanning tools to identify vulnerable libraries.
    • Users: Keep SRS updated to the latest version, as updates often include security fixes for dependencies.