Potential overflow in CalcBufferSize can cause memory-safety bug
- Fixed in 3 months
- Paid in 2 months
- Disclosed after 3 months
CalcBufferSize (media\webrtc\trunk\webrtc\common_video\libyuv\webrtc_libyuv.cc) does not detect overflow. If it is possible for its arguments to be large enough to cause overflow, its caller(s) could allocate buffers too small to contain the available data, causing reading/writing of memory to which they have no right.
I tentatively have ruled out overflow for some uses of CalcBufferSize, but not all. The ones that appear OK are:
1. VP8 streams, for which the width and height are limited to 0x3fff by ParseVP8FrameSize [1]. 0x3fff is too small to cause CalcBufferSize to overflow;
2. VP9 streams, for which the width and height appear to be limited by resize_context_buffers [2] to DECODE_WIDTH_LIMIT and DECODE_HEIGHT_LIMIT, which are, respectively, 4000 (decimal) and 3000 (decimal) on all supported platforms;
I have not determined whether there are any limits on the frame size for I420 streams, nor whether there might be other stream types for which CalcBufferSize is called.
Details
-------
There are no overflow checks in CalcBufferSize:
69: int CalcBufferSize(VideoType type, int width, int height) {
70: int buffer_size = 0;
71: switch (type) {
72: case kI420:
73: case kNV12:
74: case kNV21:
75: case kIYUV:
76: case kYV12: {
77: int half_width = (width + 1) >> 1;
78: int half_height = (height + 1) >> 1;
79: buffer_size = width * height + half_width * half_height * 2;
80: break;
81: }
82: case kARGB4444:
83: case kRGB565:
84: case kARGB1555:
85: case kYUY2:
86: case kUYVY:
87: buffer_size = width * height * 2;
88: break;
89: case kRGB24:
90: buffer_size = width * height * 3;
91: break;
92: case kBGRA:
93: case kARGB:
94: buffer_size = width * height * 4;
95: break;
96: default:
97: assert(false);
98: return -1;
99: }
100: return buffer_size;
101:}
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 low-severity security bug in WebRTC: Audio/Video. Mozilla made it public on 15 January 2016.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.