Bug 94303 - desktop-file-validate: heap-based buffer overflow in validate.c while processing crafted file
Summary: desktop-file-validate: heap-based buffer overflow in validate.c while process...
Status: RESOLVED FIXED
Alias: None
Product: desktop-file-utils
Classification: Unclassified
Component: general (show other bugs)
Version: unspecified
Hardware: Other All
: medium normal
Assignee: Hans Petter Jansson
QA Contact:
URL:
Whiteboard:
Keywords:
: 90784 (view as bug list)
Depends on:
Blocks:
 
Reported: 2016-02-26 08:41 UTC by Agostino Sarubbo
Modified: 2016-06-19 21:17 UTC (History)
1 user (show)

See Also:
i915 platform:
i915 features:


Attachments
ASan output (11.68 KB, text/plain)
2016-02-26 08:41 UTC, Agostino Sarubbo
Details
crafted file (1.58 KB, text/plain)
2016-02-26 08:41 UTC, Agostino Sarubbo
Details
0001-validate-Fix-buffer-over-read-on-incomplete-escape-s.patch (1.03 KB, patch)
2016-02-29 00:55 UTC, Hans Petter Jansson
Details | Splinter Review

Description Agostino Sarubbo 2016-02-26 08:41:09 UTC
Created attachment 121975 [details]
ASan output

Hello,

a crafted .desktop file is able to cause an heap-based buffer overflow.

You can see it if you compile with address sanitizer.

I'm attaching the asan output and the crafted file.
Comment 1 Agostino Sarubbo 2016-02-26 08:41:34 UTC
Created attachment 121976 [details]
crafted file
Comment 2 Agostino Sarubbo 2016-02-26 08:44:20 UTC
I'm reporting the issue as-is. Feel free to get in touch with your security team and/or mitre if you think it can be considered a security issue and it needs to have a CVE assigned.
Comment 3 Hans Petter Jansson 2016-02-26 13:39:28 UTC
Thank you. I'm looking into a fix for this.
Comment 4 Hans Petter Jansson 2016-02-29 00:55:18 UTC
Created attachment 122020 [details] [review]
0001-validate-Fix-buffer-over-read-on-incomplete-escape-s.patch

Fix; verified with valgrind and pushed to master.
Comment 5 Hans Petter Jansson 2016-02-29 02:03:18 UTC
Feel free to correct me, but I doubt this bug warrants a CVE ID.

It's a buffer over-read, and out-of-bounds data is not copied into another buffer or returned via pointer. The control flow is not affected beyond skipping over the '\0' and reading up to the first unescaped '\0' or until a memory access violation occurs.

Furthermore, I'm not aware of situations where even a valid .desktop file from an untrusted source would be safe to use. If you were crafting a malicious file, you could put something much more exciting in the Exec=... field.

The extent of the vulnerability from a crafted file seems to be:

- Make desktop-file-validate crash.
- Make desktop-file-install crash.
- If it doesn't crash, a value terminating in an invalid escape sequence ("\\\0") could pass validation.

This is obviously still bad, so I'll make a release shortly with the fix.
Comment 6 Hans Petter Jansson 2016-05-12 18:53:10 UTC
*** Bug 90784 has been marked as a duplicate of this bug. ***
Comment 7 Hans Petter Jansson 2016-06-19 21:17:44 UTC
Fixed in desktop-file-utils 0.23, which was just released. Thanks!


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.