-
Notifications
You must be signed in to change notification settings - Fork 79
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Invalid memory address dereference in sbr_process_channel (in libfaad/sbr_dec.c:375) #32
Comments
Reproducible on the latest master. I'm taking a look at it. This was assigned CVE-2018-20360. |
This is a complicated problem. I'll try to summarize my current understanding of the issue: The first frame has 15 channels, each channel has exactly one output channel. The second frame still has 15 channels, but the first frame channel suddenly uses parametric stereo (PS). As a result, there are now 16 output channels, and the first frame channel has now two outputs. This is handled by the following code, in
Frame channel 1 has two outputs, so we set Now, there is a problem. At the end of
This means that, once we have arrived to frame channel 14, Because frame channel 1 has two output channels, output channel 14 actually belongs to frame channel 13. Frame channel 14's output channel is output channel 15. This channel is not allocated. Why? We don't allocate output channel 15 because We did allocation while processing the first frame, which only had 15 output channels. In short:
|
@fabiangreffrath I'd like to hear your thoughts about this, but I don't think I'll have time to really fix this. I don't even know whether this situation is legal or not. I'd just remove this "feature" which is broken anyways.
Second alternative could be:
|
The question is how often this feature is used and thus how many actual tracks are affected by this. Anyway, it is always better to return cleanly when encountering this than pretending to support it and then falling on the face. I like the second approach more, because it does at least something, but I'll leave it up to you which one to use for a PR. |
Parametric Stereo (PS) can arrive at any moment in input files. PS changes the number of output channels and therefore requires more allocated memory in various structures from hDecoder. The current faad2 code attempts to perform allocation surgery in hDecoder to recover from this. This works well when there is only one frame channel, else it creates large number of memory corruption issues. If there is more than one input channel, return cleanly with error code. It would be nice to handle this, but this is likely to be a lot of work and is beyond the scope of a security fix. This commit addresses CVE-2018-20360 and CVE-2018-20199 (fixes knik0#32, fixes knik0#24).
This breaks with legitimate PS streams where the channel number is "unknown" before PS. (fr_channels == 0) |
Maybe this is the missing hint @hlef ? |
This commit also affects DAB+ channels with PS: Opendigitalradio/dablin#61 It takes some frames (e.g. 20) until |
Yes, because DMB is exclusively PS based. I'm working on a real fix. |
See #51 which should be sufficient. |
Hi, i found a issue in Freeware Advanced Audio Decoder 2 (FAAD2) 2.8.8. It crashed in function sbr_process_channel .the details are below(ASAN):
POC FILE:https://github.com/fantasy7082/image_test/blob/master/012-invalid-def-sbr_dec_375
The text was updated successfully, but these errors were encountered: