After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 778204 - (CVE-2017-6311) gdk-pixbuf-thumbnailer.c fails to set error before returning NULL (causing NULL dereference)
(CVE-2017-6311)
gdk-pixbuf-thumbnailer.c fails to set error before returning NULL (causing NU...
Status: RESOLVED FIXED
Product: gdk-pixbuf
Classification: Platform
Component: general
git master
Other All
: Normal normal
: ---
Assigned To: gdk-pixbuf-maint
gdk-pixbuf-maint
Depends on:
Blocks:
 
 
Reported: 2017-02-05 13:55 UTC by Ariel Zelivansky
Modified: 2018-04-17 07:08 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Garbage ico file that can be used to reproduce the issue (8 bytes, image/x-icon)
2017-02-05 13:55 UTC, Ariel Zelivansky
  Details
Fix NULL pointer deference (1.08 KB, patch)
2017-04-16 13:29 UTC, Martin Blanchard
none Details | Review
thumbnailer: Update skeleton to fix a possible crash (2.13 KB, patch)
2017-07-27 12:16 UTC, Bastien Nocera
none Details | Review
thumbnailer: Update skeleton to fix a possible crash (2.13 KB, patch)
2017-07-27 12:33 UTC, Bastien Nocera
committed Details | Review
ico: Return an error when the ICO didn't load (1.37 KB, patch)
2017-07-27 12:33 UTC, Bastien Nocera
committed Details | Review
tests: Add truncated (and broken) ICO file (760 bytes, patch)
2017-07-27 12:33 UTC, Bastien Nocera
committed Details | Review

Description Ariel Zelivansky 2017-02-05 13:55:26 UTC
Created attachment 344973 [details]
Garbage ico file that can be used to reproduce the issue

I found a bug that results in a segmentation fault. 

gnome-thumbnailer-skeleton.c:272 calls file_to_pixbuf. file_to_pixbuf (gdk-pixbuf-thumbnailer.c:209) calls _gdk_pixbuf_new_from_uri_at_scale, which calls gdk_pixbuf_loader_get_pixbuf (see gdk-pixbuf-thumbnailer:195).

gdk_pixbuf_loader_get_pixbuf may returns NULL, and it doesn't get a pointer to an error object to set an error. So when it returns NULL, back to, on file_to_pixbuf pixbuf will be NULL, and on line 312 printing error->message will result in a NULL deference (error->message will be 0x0 + 0x8).

I am leaving the fix for the development team since I am not sure if gdk_pixbuf_loader_get_pixbuf returning NULL is by design or it is actually an error. Perhaps the problem is not having an error set on io-ico.c.
Comment 1 Martin Blanchard 2017-04-16 13:29:09 UTC
Created attachment 349903 [details] [review]
Fix NULL pointer deference

gdk_pixbuf_loader_get_pixbuf returning NULL probably is by design. Thumbnailer crashing because of that certainly isn't. Attached patch should fix that.

But underlying problem should probably be fixed also: as you mentioned, io-ico.c should have failed before thumbnailer calls gdk_pixbuf_loader_get_pixbuf. I would suspect gdk_pixbuf__ico_image_load_increment to be failing without return FALSE...
Comment 2 Bastien Nocera 2017-07-27 12:16:05 UTC
Created attachment 356473 [details] [review]
thumbnailer: Update skeleton to fix a possible crash

If the loader returns a NULL pixbuf without returning an
error, the skeleton would crash trying to print the error.
Print that the thumbnailer is broken instead.
Comment 3 Bastien Nocera 2017-07-27 12:18:13 UTC
(In reply to Ariel Zelivansky from comment #0)
> I am leaving the fix for the development team since I am not sure if
> gdk_pixbuf_loader_get_pixbuf returning NULL is by design or it is actually
> an error. Perhaps the problem is not having an error set on io-ico.c.

Haha, totally:
 614         /* FIXME this thing needs to report errors if•
 615          * we have unused image data•
 616          */•
Comment 4 Bastien Nocera 2017-07-27 12:33:29 UTC
Created attachment 356474 [details] [review]
thumbnailer: Update skeleton to fix a possible crash

If the loader returns a NULL pixbuf without returning an
error, the skeleton would crash trying to print the error.
Print that the thumbnailer is broken instead.
Comment 5 Bastien Nocera 2017-07-27 12:33:35 UTC
Created attachment 356475 [details] [review]
ico: Return an error when the ICO didn't load

If we don't even read enough data to fill the header, return an
error. This doesn't cover everything that could go wrong with
the ICO incremental loader, but this is a good first throw.
Comment 6 Bastien Nocera 2017-07-27 12:33:42 UTC
Created attachment 356476 [details] [review]
tests: Add truncated (and broken) ICO file

The loader should return an error in that case.
Comment 7 Bastien Nocera 2017-07-27 12:37:32 UTC
How did this ever get a CVE? The thumbnailers are made to crash, this never was a DoS...

Attachment 356474 [details] pushed as 57362ed - thumbnailer: Update skeleton to fix a possible crash
Attachment 356475 [details] pushed as 7586553 - ico: Return an error when the ICO didn't load
Attachment 356476 [details] pushed as 67a02e1 - tests: Add truncated (and broken) ICO file
Comment 8 Waynem Ccollough 2018-04-17 07:08:17 UTC
Good job. Thanks for fixing this.

Jhon
https://mrkortingscode.nl/