New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 634259 link

Starred by 1 user

Issue metadata

Status: Verified
Owner:
Closed: Apr 2017
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Linux
Pri: 2
Type: Bug-Regression



Sign in to add a comment

Integer-overflow in CFX_BilinearMatrix::Transform

Project Member Reported by ClusterFuzz, Aug 4 2016

Issue description

Detailed report: https://cluster-fuzz.appspot.com/testcase?key=6254362718633984

Fuzzer: tokenfuzz_pdf_curated
Job Type: linux_ubsan_chrome
Platform Id: linux

Crash Type: Integer-overflow
Crash Address: 
Crash State:
  CFX_BilinearMatrix::Transform
  CFX_ImageTransformer::Continue
  CFX_DIBSource::TransformTo
  
Regressed: https://cluster-fuzz.appspot.com/revisions?job=linux_ubsan_chrome&range=379730:379778

Minimized Testcase (106.92 Kb): https://cluster-fuzz.appspot.com/download/AMIfv96Tvdslv9GV-kPtYCsjGu0afW_8wS5NyN6-ORbq7vR76S0MlJPD-91cvsu8P6Hc_4Trq6ASzzvaHDhDu1teRo-FlB7RKBsCkLscRb3ZBAPsF36Zdo6pnEQIdwxguY8aK6fAgMtZ1XQOPWSpZNYnLE2fKlJEnYA1LrMwCmCZx49ya9EWoMg?testcase_id=6254362718633984

Filer: ranjitkan

See https://dev.chromium.org/Home/chromium-security/bugs/reproducing-clusterfuzz-bugs for more information.
 
Components: Tools>Test>FindIt>CorrectResult
Labels: -Pri-1 -Type-Bug M-54 Findit-for-crash Te-Logged Pri-2 Type-Bug-Regression
Owner: dsinclair@chromium.org
Status: Assigned (was: Untriaged)
Author: Dan Sinclair
Project: chromium-pdfium
Changelist: https://pdfium.googlesource.com/pdfium.git/+/764ec513eecbebd12781bcc96ce81ed5e736ee92
Time: Mon Mar 14 13:35:12 2016 -0400
The CL last changed line 164 of file fx_dib_transform.cpp, which is stack frame 0.

@Dan Sinclair: Request you to please take a look into it. Please help us to reassign if not with respect to your change.

Thanks.!
Cc: och...@chromium.org
How can I test this locally, there doesn't seem to be a build target for the given fuzzer? The file seems to be OK with pdfium_test.
A ubsan build of chrome? There doesn't seem to be a pdf_curated fuzzer target to build.
Components: Internals>Plugins>PDF
Try building UBSAN pdfium_test inside a Chromium checkout and see if that can repro the bug. If not, you'll need a full UBSAN build of chrome.
Status: Started (was: Assigned)
Cc: caryclark@chromium.org
The image transformer's huge numbers comes from this part of the PDF:

/FontMatrix [
    0.0111111
    13314
    0
    -0.0111111
    0
    0
  ]

which is part of 

%% Original object ID: 62 0
46 0 obj

(around line 7367 as disassembled by qpdf)

In particular, matrix.b is scaled by the font size

/R17 10.8122 Tf

and then by the glyph's image matrix:

q 24 0 0 -65 9 5 cm    # around line 9024

By the time CFX_ImageTransformer is called, m_pMatrix.b has ballooned to -3454886.25

This sets stretch_width to 3454887  (fx_dib_transformer.cpp, line 385)

which causes m_dest2stretch.a to be set to 1198261.63

The bilerp wants to transform a bitmap 4 pixels wide and 3454895 pixels high.
Since the implementation for the matrix is integral, and the matrix contains
(306754976, 314265856) for matrix.a and matrix.b the resulting multiplication
needs 51 bits to represent the answer.

One solution for now would be to preflight the worst multiplication (e.g.

max((int64_t) m_result.Width() * result2stretch_fix.a, 
    (int64_t) m_result.Height() * result2stretch_fix.b) ... etc

and see if the intermediates fit within 30 bits.

 
That sounds similar to what the patch is doing now, I'm just using our safe math libraries to check the calculations.

I've arbitrarily decided that if the calculation fails to use 0 as the result.
Would you be open to doing the checking outside the loop instead of inside the loop?
Ah, I see. I though you were saying to do the calculations inside Transform, but you're saying move them out to CFX_ImageTransformer::Continue.

Moving them out would be fine.
Project Member

Comment 12 by sheriffbot@chromium.org, Nov 22 2016

Labels: -Restrict-View-EditIssue
Removing EditIssue view restrictions from ClusterFuzz filed bugs. If you believe that this issue should still be restricted, please reapply the label.

For more details visit https://www.chromium.org/issue-tracking/autotriage - Your friendly Sheriffbot
Project Member

Comment 13 by ClusterFuzz, Apr 27 2017

ClusterFuzz has detected this issue as fixed in range 467403:467472.

Detailed report: https://clusterfuzz.com/testcase?key=6254362718633984

Fuzzer: tokenfuzz_pdf_curated
Job Type: linux_ubsan_chrome
Platform Id: linux

Crash Type: Integer-overflow
Crash Address: 
Crash State:
  CFX_BilinearMatrix::Transform
  CFX_ImageTransformer::Continue
  CFX_DIBSource::TransformTo
  
Sanitizer: undefined (UBSAN)

Regressed: https://clusterfuzz.com/revisions?job=linux_ubsan_chrome&range=379730:379778
Fixed: https://clusterfuzz.com/revisions?job=linux_ubsan_chrome&range=467403:467472

Reproducer Testcase: https://clusterfuzz.com/download?testcase_id=6254362718633984


See https://dev.chromium.org/Home/chromium-security/bugs/reproducing-clusterfuzz-bugs for more information.

If you suspect that the result above is incorrect, try re-doing that job on the test case report page.
Project Member

Comment 14 by ClusterFuzz, Apr 27 2017

Labels: ClusterFuzz-Verified
Status: Verified (was: Started)
ClusterFuzz testcase 6254362718633984 is verified as fixed, so closing issue.

If this is incorrect, please add ClusterFuzz-Wrong label and re-open the issue.

Sign in to add a comment