Facebook Google Plus Twitter LinkedIn YouTube RSS Menu Search Resource - BlogResource - WebinarResource - ReportResource - Eventicons_066 icons_067icons_068icons_069icons_070

Denial of Service Vulnerability in Dropbox's JPEG Compression Tool, Lepton

Low

Synopsis

CVSS Vector: AV:L/AC:L/PR:L/UI:R/S:U/C:N/I:N/A:H (5.0/4.9)

Until quite recently, the cloud storage provider, Dropbox, made use of a novel algorithm for losslessly compressing JPEG image files called "lepton". This allowed them to store those images in a way that utilized approximately 22% less disk space, in aggregate.

The tool, which Dropbox has released as open source, is robustly designed with security in mind. Untrusted data, for the most part, is handled by separate subprocesses, which are "run within seccomp to disable all system calls except read and write of already-open file descriptors." This is enough to severely curtail the scope of any attempted remote code execution attacks, and seems like an eminently sensible design decision for a tool designed to handle vast quantities of untrusted user-controlled data. 

The bug in question, however, is a simple denial of service vulnerability. It is possible to craft a JPEG file that will throw Lepton's seccomp-enclosed compression verification step -- which ensures that the file has been compressed losslessly by attempting to decompress it again and compare it with the original -- into an infinite loop. The master process hangs indefinitely while it waits for this verification process to run to completion. 

The critical lines of code appear to be in the function encode_eobrun() in src/lepton/jpgcoder.cc:


5349:int encode_eobrun( abitwriter* huffw, huffCodes* actbl, unsigned int* eobrun )
5350-{
5351-    unsigned short n;
5352-    unsigned int  s;
5353-    int hc;
5354-
5355-
5356-    if ( (*eobrun) > 0 ) {
5357-        while ( (*eobrun) > actbl->max_eobrun ) {
5358-            huffw->write( actbl->cval[ 0xE0 ], actbl->clen[ 0xE0 ] );
5359-            huffw->write( E_ENVLI( 14, 32767 ), 14 );
5360-            (*eobrun) -= actbl->max_eobrun;
5361-        }
5362-        s = uint16bit_length((*eobrun));
5363-        dev_assert(s && "actbl->max_eobrun needs to be > 0");
5364-        if (s) s--;
5365-        n = E_ENVLI( s, (*eobrun) );
5366-        hc = ( s << 4 );
5367-        huffw->write( actbl->cval[ hc ], actbl->clen[ hc ] );
5368-        huffw->write( n, s );
5369-        (*eobrun) = 0;
5370-    }
5371-
5372-
5373-    return 0;
5374-}

Note that the struct field actbl->max_eobrun is checked only after the while loop! And it turns out to be possible to craft a JPEG file that Lepton will compress into a faulty LEP file, which when processed again by Lepton will fail to populate the max_eobrun field of the actbl struct, leaving it at 0. Since this block of code is designed to loop until *eobrun is zero, and each iteration, in this case, subtracts zero from *eobrun, the value referenced by *eobrun never reaches zero and the loop never ends. This gives us our denial of service vulnerability. 

Deprecation Notice

90 days ago, we reported this issue to Dropbox, and they have since responded by deprecating the Lepton tool and archiving the tool's open source github repository at <https://github.com/dropbox/lepton>, citing this particular DoS vulnerability in their deprecation notice, as shown in the git diff between the current HEAD of the master branch and the commit where we discovered this vulnerability (429fe880d331b49a5be08b4d8dc762cbada6d4ca):

$ git diff origin master Δ README.md ───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── ─────┐ • 1: │ ─────┘

⚠️  Deprecation Notice for the Dropbox Lepton project

Dear Lepton users and developers,

Thank you so much for using and contributing to Lepton over the years! We’ve recently realized that we no longer have sufficient resources to adequately support this project. This includes providing timely fixes to bugs and vulnerabilities such as those that were [recently reported to us](https://github.com/dropbox/lepton/issues/158). While we did ensure that the reported vulnerabilities don’t affect our internal use of Lepton, we unfortunately don’t have the capacity to properly fix these and future issu→ If you would like to continue using Lepton, please check out various forks of the project (or start your own!) or alternatively consider switching to other lossless compression methods such as [Brotli](https://dropbox.tech/infrastructure/lossless-compression-with-brotli) or to modern image formats such as [WebP](https://en.wikipedia.org/wiki/WebP) or [JPEG XL](https://en.wikipedia.org/wiki/JPEG_XL).

# Lepton Lepton is a tool and file format for losslessly compressing JPEGs by an average of 22%.

Proof of Concept

The attached JPEG file is sufficient to trigger the denial of service vulnerability in the current, now-archived version of Lepton.

This image probably won't render in your browser, but it's good enough to fool Lepton.

Solution

Dropbox is reportedly no longer using Lepton to compress JPEG images on their backend. The source code of the Lepton compression tool is still available to the public, but Dropbox has issued an official deprecation notice, advising against its use, recommending users to instead consider other lossless compression methods such as Brotli.

Disclosure Timeline

August 18, 2022: First attempt to contact Dropbox and reach their security team
August 25, 2022: Vulnerability disclosed to Dropbox
August 25, 2022: Dropbox acknowledges the issue, requests additional information
August 25, 2022: Tenable provides additional information to Dropbox, including proof of concept and suggested fix
September 20, 2022: Dropbox informs Tenable of their failure to adequately patch or mitigate the bug
November 18, 2022: Dropbox adds a notice deprecating Lepton to their public Github repository
November 21, 2022: Tenable publishes advisory

All information within TRA advisories is provided “as is”, without warranty of any kind, including the implied warranties of merchantability and fitness for a particular purpose, and with no guarantee of completeness, accuracy, or timeliness. Individuals and organizations are responsible for assessing the impact of any actual or potential security vulnerability.

Tenable takes product security very seriously. If you believe you have found a vulnerability in one of our products, we ask that you please work with us to quickly resolve it in order to protect customers. Tenable believes in responding quickly to such reports, maintaining communication with researchers, and providing a solution in short order.

For more details on submitting vulnerability information, please see our Vulnerability Reporting Guidelines page.

If you have questions or corrections about this advisory, please email [email protected]

Risk Information

CVE ID: CVE-2022-4104
Tenable Advisory ID: TRA-2022-35
Credit:
Olivia Lucca Fraser
CVSSv2 Base / Temporal Score:
5.0/4.9
CVSSv3 Vector:
AV:L/AC:L/PR:L/UI:R/S:U/C:N/I:N/A:H
Affected Products:
Lepton
Risk Factor:
Low

Advisory Timeline

Monday, November 21, 2022: Advisory Published