From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id D49184A369 for ; Sat, 29 Jun 2024 23:28:18 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 82A4568D72E; Sun, 30 Jun 2024 02:28:15 +0300 (EEST) Received: from relay8-d.mail.gandi.net (relay8-d.mail.gandi.net [217.70.183.201]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id F3F2568D359 for ; Sun, 30 Jun 2024 02:28:08 +0300 (EEST) Received: by mail.gandi.net (Postfix) with ESMTPSA id E77EC1BF205 for ; Sat, 29 Jun 2024 23:28:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=niedermayer.cc; s=gm1; t=1719703688; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=FEHkUZ1zTxp4eD8JzKcbBYF9d5zAzc6NjPTVSkUlEwM=; b=JNaE/D629O/6jqbso9gT4YZSOY1lhuBFNyt3BQcdr9c+dNBIrhHZZnlTiAAjoYPWW22Wmh YQ6YfhTv47UIdWu/LL7iJ63PXTmEELbBJscaMtrqOXckrLlPfOOqkx6BjaKaeklUqfgTxo lsu8iVPVj17YfwRSZqFtkgV7WABMAqvTOBqEzuPc/mVOPS37vx1fZ1cWlN20YCs55BbRE7 A3iP5feiGrxlelCRu/PzXjTAuJTkbup3DJ0PvvN7D8LHDVdMtIol6qlMLPozlG+tD1rk6b 9kEsGH2/ik54rp7yFNidAIlG+akHVzssXqs5iESbC70YPfbYHotyFsv13nR/AA== Date: Sun, 30 Jun 2024 01:28:06 +0200 From: Michael Niedermayer To: FFmpeg development discussions and patches Message-ID: <20240629232806.GA4991@pb2> References: <20240322230818.18997-1-michael@niedermayer.cc> <171152515798.7287.8979021106267679923@lain.khirnov.net> <20240327232702.GM6420@pb2> <20240625192546.GG4991@pb2> <171934367519.21847.12248145136761974723@lain.khirnov.net> <20240626235012.GV4991@pb2> <171947118914.21847.15118547358198017606@lain.khirnov.net> MIME-Version: 1.0 In-Reply-To: <171947118914.21847.15118547358198017606@lain.khirnov.net> X-GND-Sasl: michael@niedermayer.cc Subject: Re: [FFmpeg-devel] [PATCH 1/3] avformat/cafdec: sanity check channels and bps X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Content-Type: multipart/mixed; boundary="===============1395005772218490155==" Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: --===============1395005772218490155== Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="U/fatWn3w9i48dtV" Content-Disposition: inline --U/fatWn3w9i48dtV Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Thu, Jun 27, 2024 at 08:53:09AM +0200, Anton Khirnov wrote: > Quoting Michael Niedermayer (2024-06-27 01:50:12) > > On Tue, Jun 25, 2024 at 09:27:55PM +0200, Anton Khirnov wrote: > > > Quoting Michael Niedermayer (2024-06-25 21:25:46) > > > > On Thu, Mar 28, 2024 at 12:27:02AM +0100, Michael Niedermayer wrote: > > > > > On Wed, Mar 27, 2024 at 08:39:17AM +0100, Anton Khirnov wrote: > > > > > > Quoting Michael Niedermayer (2024-03-23 00:08:16) > > > > > > > Fixes: Timeout > > > > > > > Fixes: 67044/clusterfuzz-testcase-minimized-ffmpeg_dem_CAF_fu= zzer-5791144363491328 > > > > > > >=20 > > > > > > > Found-by: continuous fuzzing process https://github.com/googl= e/oss-fuzz/tree/master/projects/ffmpeg > > > > > > > Signed-off-by: Michael Niedermayer > > > > > > > --- > > > > > > > libavformat/cafdec.c | 5 +++++ > > > > > > > 1 file changed, 5 insertions(+) > > > > > > >=20 > > > > > > > diff --git a/libavformat/cafdec.c b/libavformat/cafdec.c > > > > > > > index 426c56b9bd..334077efb5 100644 > > > > > > > --- a/libavformat/cafdec.c > > > > > > > +++ b/libavformat/cafdec.c > > > > > > > @@ -33,6 +33,7 @@ > > > > > > > #include "isom.h" > > > > > > > #include "mov_chan.h" > > > > > > > #include "libavcodec/flac.h" > > > > > > > +#include "libavcodec/internal.h" > > > > > > > #include "libavutil/intreadwrite.h" > > > > > > > #include "libavutil/intfloat.h" > > > > > > > #include "libavutil/dict.h" > > > > > > > @@ -87,6 +88,10 @@ static int read_desc_chunk(AVFormatContext= *s) > > > > > > > st->codecpar->ch_layout.nb_channels =3D avio_rb32(pb); > > > > > > > st->codecpar->bits_per_coded_sample =3D avio_rb32(pb); > > > > > > > =20 > > > > > > > + if (st->codecpar->ch_layout.nb_channels > FF_SANE_NB_CHA= NNELS || > > > > > >=20 > > > > > > I dislike this. > > > > >=20 > > > > > I dislike it too > > > >=20 > > > > so what do we do about this ? > > >=20 > > > About what? What is the actual problem that needs addressed? > >=20 > > 67044/clusterfuzz-testcase-minimized-ffmpeg_dem_CAF_fuzzer-579114436349= 1328 > >=20 > >=20 > > >=20 > > > > any objections to apply this ? > > >=20 > > > yes, FF_SANE_NB_CHANNELS is a hack that should be removed, not spread > >=20 > > a maximum number for each theoretically unlimited parameter is desirable >=20 > I disagree. >=20 > > This can be a user setable value or a compile time value when such is p= referred. > >=20 > > We can take this to the TC if you want. > >=20 > > The same way as the number of files or number of bytes used by some cac= he > > needs limits, >=20 > Those limits are implemented at the OS level, not by individual > programs. random pick, man ccache --max-files=3DN --max-size=3DSIZE > And they are runtime-configurable. I would favor runtime-configurable as well >=20 > > so do channels, and number of pixels. >=20 > Does not follow. For a file with length n "bits" it is understood and expected that there wi= ll be O(n) processing needed. having O(2^n) is not "expected" if you have a loop going over channels, pixels, or another "unlimited" prop= erty you can create very small files that require the maximum memory and process= ing allowed by the OS for the process Thats a DOS attack >=20 > > One can remove them but users and companies concious about security and > > efficiency with untrusted input in an (semi-) automated environment wil= l likely > > choose the codebase providing such features. >=20 > [citation needed] >=20 > My main objection to this approach is that you're addressing a symptom > (fuzzer timeout) rather than the actual problem (some code scaling > inappropriately with input size), and it's completely unclear where that > actual problem even is, as cafdec does not seem to be doing anything > with the channel count. That suggests the problem is really in some > other code and you're just papering over it. ive rerun the testcase and depending on settings it either hits OOM in av_channel_layout_custom_init() or it will timeout in av_channel_layout_describe_bprint libavutil/channel_layout.c:627:17 The file has 33 million channels. Now if for some reason none of the above would hit a timeout and instead the decoder would decode 33 million channels of silence maybe because it had a 1 byte packet and error concealment produced a silent packet to fill the space. Still the same issue exists only a limit on the channel number avoids this. Surely improving all the code that is slow with millions of channels is a good idea but even the most efficient code to produce a frame with arbitrary # million channels in it will lead to a DOS attack opertunity thx [...] --=20 Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Whats the most studid thing your enemy could do ? Blow himself up Whats the most studid thing you could do ? Give up your rights and freedom because your enemy blew himself up. --U/fatWn3w9i48dtV Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iF0EABEKAB0WIQSf8hKLFH72cwut8TNhHseHBAsPqwUCZoCYfwAKCRBhHseHBAsP q7siAKCGqgkBvIZznf38xtXpV+wsRisTOQCbBW4hBOFA3QCXtwcfZaDUbR2Vz6Y= =ANMB -----END PGP SIGNATURE----- --U/fatWn3w9i48dtV-- --===============1395005772218490155== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe". --===============1395005772218490155==--