Skip to content
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

Fixes from Google Android team for jpgd.cpp security vulnerabilities (incl. CVE-2017-0700) #10

Merged
merged 2 commits into from
Mar 6, 2020

Conversation

akien-mga
Copy link
Contributor

@akien-mga akien-mga commented Jul 30, 2019

See godotengine/godot#30952 and libgdx/libgdx#5737 for context.

Google Android used to maintain a libgdx fork, and committed some security fixes in libgdx's bundled jpgd.cpp, which were seemingly not contributed back upstream either here or to libgdx. Godot also uses jpgd.cpp so is affected likewise.

I reviewed the Google Android libgdx codebase and cherry-picked the two commits related to jpgd.cpp: https://android.googlesource.com/platform/external/libgdx/+log/refs/heads/nougat-mr2.3-release

The second commit was apparently the fix (or one of the fixes?) for CVE-2017-0700.
PoC: https://github.com/ele7enxxh/poc-exp/tree/master/CVE-2017-0700

Note that I cherry-picked these commits without modification, nor reviewing whether they do things the right way. I tested that second commit properly fixes the above linked PoC:

$ git checkout master
$ g++ test.cpp jpgd.cpp
$ ./a.out ~/tmp/CVE-2017-0700.jpg 
Segmentation fault (core dumped)

$ git checkout google-security-fixes
$ g++ test.cpp jpgd.cpp
$ ./a.out ~/tmp/CVE-2017-0700.jpg 
a.out: jpgd.cpp:1673: void jpgd::jpeg_decoder::load_next_row(): Assertion `m_comp_quant[component_id] < JPGD_MAX_QUANT_TABLES' failed.
Aborted (core dumped)

CC @richgel999 as I've noticed you don't "watch" your old repos imported from Google Code.

XSJoJo and others added 2 commits July 30, 2019 12:13
Change-Id: I19028233d2ce79ef08947f00d2ecba20312579cc
Fixes: 32769670
(cherry picked from commit 28d83109cba8e1949032c78465649ba21db2d22e)

---

(cherry picked from commit 890381c983b6eca60a435ebf5a4bdbd7a32660f0)
https://android.googlesource.com/platform/external/libgdx/+/890381c983b6eca60a435ebf5a4bdbd7a32660f0

Adapted from libgdx fork back to upstream jpeg-compressor repo.

Co-authored-by: Rémi Verschelde <remi@godotengine.org>
Test: PoC
Bug: 35639138
Change-Id: I7fc4385d7f446ecfbc7dbd350e4c9bac6db0c9f0
(cherry picked from commit 117c2d5b213b42b8cb2bedc45b6139a8f4516712)

---

(cherry picked from commit 57b37792a815621274e529df9bfa1d39efb55b1b)
https://android.googlesource.com/platform/external/libgdx/+/57b37792a815621274e529df9bfa1d39efb55b1b

Adapted from libgdx fork back to upstream jpeg-compressor repo.

According to godotengine/godot#30952,
this commit fixes CVE-2017-0700, which was documented as Android
vulnerability but was actually fixed in libgdx's copy of jpgd.cpp.

PoC: https://github.com/ele7enxxh/poc-exp/tree/master/CVE-2017-0700

Co-authored-by: Rémi Verschelde <remi@godotengine.org>
akien-mga added a commit to akien-mga/godot that referenced this pull request Jul 30, 2019
akien-mga added a commit to godotengine/godot that referenced this pull request Aug 21, 2019
Squashed version of richgel999/jpeg-compressor#10
with the line endings fixed (DOS to Unix).

See richgel999/jpeg-compressor#10 and #30952
for details. Relates to CVE-2017-0700.

Fixes #30952.

(cherry picked from commit 5c33327)
myhalibobo pushed a commit to myhalibobo/godot that referenced this pull request Sep 3, 2019
akien-mga added a commit to akien-mga/godot that referenced this pull request Sep 24, 2019
Squashed version of richgel999/jpeg-compressor#10
with the line endings fixed (DOS to Unix).

See richgel999/jpeg-compressor#10 and godotengine#30952
for details. Relates to CVE-2017-0700.

Fixes godotengine#30952.

(cherry picked from commit 5c33327)
pchasco pushed a commit to pchasco/godot that referenced this pull request Oct 23, 2019
@richgel999 richgel999 merged commit 2201592 into richgel999:master Mar 6, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants