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

Issue 668073 link

Starred by 1 user

Issue metadata

Status: Verified
Owner:
ex-Googler
Closed: Mar 2017
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Linux
Pri: 2
Type: Bug



Sign in to add a comment

Integer-overflow in sqlite3VdbeExec

Project Member Reported by ClusterFuzz, Nov 23 2016

Issue description

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

Fuzzer: libfuzzer_sqlite3_ossfuzz_fuzzer
Job Type: libfuzzer_chrome_ubsan
Platform Id: linux

Crash Type: Integer-overflow
Crash Address: 
Crash State:
  sqlite3VdbeExec
  sqlite3Step
  sqlite3_step
  
Regressed: https://cluster-fuzz.appspot.com/revisions?job=libfuzzer_chrome_ubsan&range=433990:434098

Minimized Testcase (0.04 Kb):
Download: https://cluster-fuzz.appspot.com/download/AMIfv97Z11QscON8oshVkjGU6yjbHCZIMBYsyGamgR6QbbGlfoxi1srw5wtZzYsDslu8JMqu189hIfa46gsO8yn-A23R-T0lbDV62yVu4ax0UZQCiOJmy_EDtIhSJKvV6uK0QZdkfD7mnD1-gSP4EwzyyXhBM3biAg?testcase_id=4612307046105088
SELECT?LIMIT (1)-1,~2E51--N� decimal(1,1)�|


Issue filed automatically.

See https://chromium.googlesource.com/chromium/src/+/master/testing/libfuzzer/reproducing.md for more information.
 
Components: UI>Localization
Labels: Test-Predator-Wrong M-57
Owner: mmoroz@chromium.org
Status: Assigned (was: Untriaged)
Author: mmoroz
Project: chromium
Changelist: https://chromium.googlesource.com/chromium/src/+/656b55356751d12fd8c643f927691275ef10dded
Time: Tue Nov 22 22:04:43 2016
The CL last changed line 75 of file ossfuzz.c, which is stack frame 4.

Comment 2 by mmoroz@chromium.org, Nov 28 2016

Cc: mmoroz@chromium.org kcc@chromium.org aizatsky@chromium.org
Owner: sh...@chromium.org
Glad to see new bugs found with another fuzz target. Passing it over to sqlite3 OWNER shess@.

Comment 3 by sh...@chromium.org, Nov 28 2016

Interesting.  A cleaner minimization is something like:
   SELECT 0 LIMIT 0,~1E20
The 1E20 just needs to be a real number greater than 2^63-1, which ~ (bitwise not) will convert to integer, which will convert to 64-bit maxint before flipping the bits, leaving the -9223372036854775808 for the number of rows to return (in the comma syntax, it's LIMIT ofs,limit).  As of our release (checking trunk presently), the implementation checks the limit value for 0, but not for negative, so when it attempts to count down, the bad thing happens.

Note that -- is a SQL comment initiator.  Due to the "-9223372036854775808 - 1" text, I was completely believing it was a post-decrement, which confused me for a bit.

Comment 4 by sh...@chromium.org, Nov 28 2016

This still happens on trunk.  Also, it's not strictly degenerate, LIMIT with a negative value works like no limit, intentionally.  So:

CREATE TABLE t(x);
WITH RECURSIVE c(x) AS (VALUES(1) UNION ALL SELECT x+1 FROM c WHERE x<10) INSERT INTO t SELECT x FROM c;
SELECT * FROM t LIMIT 0, -9223372036854775798;
-- No UB to here.
SELECT * FROM t LIMIT 0, -9223372036854775800;
-- Sees UB between results 9 and 10.

Is there a way to gateway this into the ossfuzz tracker?  I saw that drh was responsive in there.  Or should I leave it in this tracker and add drh?
I have created ubsan build for SQLite in ossfuzz. It should either find it
soon or we'll upload this manually.

Oliver, can you create the job on CF?

Comment 6 by och...@chromium.org, Nov 29 2016

Done.
Project Member

Comment 7 by ClusterFuzz, Mar 21 2017

Project Member

Comment 8 by ClusterFuzz, Mar 21 2017

Labels: ClusterFuzz-Verified
Status: Verified (was: Assigned)
ClusterFuzz testcase 4612307046105088 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