Skip to content
Memory corruption Disclosed report CVE-2015-7205

Underflow in RTPReceiverVideo::ParseRtpPacket causes memory-safety bug and information leak

q1 Follow

Originally disclosed on Mozilla

  • Fixed in 19 days
  • Paid in 19 days
  • Disclosed after 19 days
Text
RTPReceiverVideo::ParseRtpPacket (media\webrtc\trunk\webrtc\modules\rtp_rtcp\source\rtp_receiver_video.cc) will underflow if an incoming packet is malformed such that its padding length is greater than its payload length. This underflow then causes ParseRtpPacket to pass to its callback function (which eventualy passes it to a video decoder) a buffer length that exceeds the buffer's actual length. The receiver's decoder then reads that buffer and displays the contents as video (which usually, but not always, appears as trash). If the receiver happens to be sharing the tab containing the decoded video with another user via Firefox Hello, the other user will receive the video, thus leaking private information to the other user.

The bug is still present in the current trunk: http://hg.mozilla.org/mozilla-central/file/96377bdbcdf3/media/webrtc/trunk/webrtc/modules/rtp_rtcp/source/rtp_receiver_video.cc ; http://hg.mozilla.org/mozilla-central/file/96377bdbcdf3/media/webrtc/trunk/webrtc/modules/rtp_rtcp/source/rtp_utility.cc .


Details
-------

The bug is in RTPReceiverVideo::ParseRtpPacket lines 72-3, which don't check for underflow:

72:   const uint16_t payload_data_length =
73:       payload_length - rtp_header->header.paddingLength;

Equivalently, the bug could be considered to be in RtpHeaderParser::Parse (media\webrtc\trunk\webrtc\modules\rtp_rtcp\source\rtp_utility.cc), which doesn't verify that the padding fits within the packet, or even in RtpDepacketizer::Parse and its overriding functions (ditto).

(BTW, there is also a similar underflow in RtpReceiverImpl::IncomingRtpPacket line 201, but it appears to be harmless because the result appears to be used only for statistics).


A (rather involved) debugger-based proof-of-concept goes like this:

1. Start FF 41.0 x86 debug build with -profilemanager -no-remote. Call this session the "sender". Create a new profile ("sender profile"), run FF with it, and attach a debugger to it.

2. Patch the sender's code in RTPSender::CreateRTPHeader (media\webrtc\trunk\webrtc\modules\rtp_rtcp\source\rtp_sender.cc) line 1103 to initialize |header [0]| to 0xa0 instead of 0x80 (this sets the P ("padding") bit in the header, which causes RtpHeaderParser::Parse to interpret the last byte of the packet as a count of padding bytes, and to assign it to |header.paddingLength|).

3. Patch the sender's code in RTPSenderVideo::Send (media\webrtc\trunk\webrtc\modules\rtp_rtcp\source\rtp_sender_video.cc) lines 358-64 to use 0x20 for the outgoing packet length instead of |payload_bytes_in_packet|. To do this, replace the sequence

   movzx edx, word ptr [ebp-620h]   ; 0f b7 95 e0 f9 ff ff
   push  edx                        ; 52

with

   push  20h                        ; 6a 20
   nop                              ; 90
   nop                              ; 90
   nop                              ; 90
   nop                              ; 90
   nop                              ; 90
   nop                              ; 90
   
4. Patch out the ASSERT in CreateBoxShadow (gfx\thebes\gfxBlur.cpp in 445) to avoid an unrelated spurious crash due to https://bugzilla.mozilla.org/show_bug.cgi?id=1181028 and similar bugs.

5. Let execution proceed and detach the debugger from the sender.

6. Play a long video in the sender.

7. Start FF 41.0 x86 debug build with -profilemanager -no-remote. Call this session the "receiver". Create a new profile ("receiver profile"), run FF with it, and attach a debugger to it.

8. Create an FF Hello conversation in the sender. Copy the link and open it in the receiver.

9. When the conversation is connected, share the sender's tabs.

10. Watch the video trash in the receiver's tab until the receiver crashes with a read access violation.

11. Trace back the stack into ViEReceiver::OnReceivedPayloadData and note that |payload_size| is about 0xffxx. Note also that one or more pages in the range [|payload_data|, |payload_data+payload_size-1] are inaccessible, and that the crash read-access violation address is in this range.

12. Trace back the stack into RtpReceiverVideo::ParseRtpPacket and examine |payload_data_length| on line 72. Notice that it's about 0xffxx. Examine |payload_length| and notice it's 0x20, and examine |rtp_header->header.paddingLength| and notice it's > 0x20.

13. You can show that the receiver leaks information to another user by restarting the receiver and re-establishing the Hello session. Then start a third FF session with -profilemanager -no-remote, start another Hello session between the receiver and the third session, and share the receiver's tab with the third session. Notice how the trash displayed in the receiver's tab is also displayed in the third session's window.


Typically the receiver displays garbage for a few seconds to a few minutes, then crashes with a read access violation, sometimes in ViEReceiver::OnReceivedPayloadData where it calls vcm_->IncomingPacket, sometimes near the end of VCMJitterBuffer::GetFrame, sometimes elsewhere.

The original report as published on Mozilla's Bugzilla, by q1. Images and videos are our own copies; raw HTML is shown as text. View it on Mozilla's Bugzilla.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

What is known

A high-severity memory corruption bug in WebRTC: Networking. Mozilla made it public on 20 November 2015 as CVE-2015-7205.

About Memory corruption

Native code reads or writes memory it should not: overflows, use-after-free, type confusion. The core of browser, kernel and parser bugs.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

What is Memory corruption?

Native code reads or writes memory it should not: overflows, use-after-free, type confusion. The core of browser, kernel and parser bugs.

More by q1

View all

71 more disclosed reports, best first.

More from Mozilla

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Memory corruption

The lesson behind this report.

Native code reads or writes memory it should not: overflows, use-after-free, type confusion. The core of browser, kernel and parser bugs.