Asterisk vulnerable to RTP Bleed
- Vulnerable version: Asterisk 11.4.0 to 14.6.1 (fix incomplete)
- References: AST-2017-005, AST-2017-008, CVE-2017-14099
- Advisory URL: https://github.com/EnableSecurity/advisories/tree/master/ES2017-04-asterisk-rtp-bleed
When Asterisk is configured with the
strictrtp=yes (on by default) options, it is vulnerable to an attack which we call RTP Bleed. Further information about the attack can be found at https://rtpbleed.com.
Abuse of this attack allows malicious users to inject and receive RTP streams of ongoing calls without needing to be positioned as man-in-the-middle. As a result, in the case of an RTP stream containing audio media, attackers can inject their own audio and receive audio being proxied through the Asterisk server.
How to reproduce the issue
The vulnerability can be exploited when a call is taking place and the RTP is being proxied. To exploit this issue, an attacker needs to send RTP packets to the Asterisk server on one of the ports allocated to receive RTP. When the target is vulnerable, the RTP proxy responds back to the attacker with RTP packets relayed from the other party. The payload of the RTP packets can then be decoded into audio.
Solutions and recommendations
We have the following recommendations:
- It is recommended to apply the fix issued by Asterisk which limits the window of vulnerability to the first few milliseconds.
- When possible the
nat=yesoption should be avoided.
- To protect against RTP injection the media streams should be encrypted (and authenticated) with SRTP.
- A configuration option for SIP peers should be added that allows to prioritize RTP packets coming from the IP address learned through SIP signalling during the initial probation period.
Note that as for the time of writing, the official Asterisk fix is vulnerable to a race condition. An attacker may continuously spray an Asterisk server with RTP packets. This allows the attacker to send RTP within those first few packets and still exploit this vulnerability.
The first Asterisk fix did not properly validate very short RTCP packets (e.g. 4 octets, see rtcpnatscan to reproduce the problem) resulting in an out of bounds read disabling SSRC matching. This made Asterisk vulnerable to RTCP hijacking of ongoing calls. An attacker can extract RTCP sender reports containing the SSRCs of both RTP endpoints.
A patch for this is available at (https://raw.githubusercontent.com/kapejod/rtpnatscan/master/patches/asterisk/too-short-rtcp-bugfix.diff)
Asterisk issued an official advisory and patch for this second vulnerability. More details can be found at http://downloads.asterisk.org/pub/security/AST-2017-008.html
- Kamailio World 2017: Listening By Speaking - Security Attacks On Media Servers And RTP Relays
- 27C3: Having fun with RTP by Kapejod
- Official patches: AST-2017-005, AST-2017-008
About Enable Security
Enable Security provides Information Security services, including Penetration Testing, Research and Development, to help protect client networks and applications against online attackers.
The information in the advisory is believed to be accurate at the time of publishing based on currently available information. Use of the information constitutes acceptance for use in an AS IS condition. There are no warranties with regard to this information. Neither the author nor the publisher accepts any liability for any direct, indirect, or consequential loss or damage arising from use of, or reliance on, this information.