Skip to content

Commit 62daad7

Browse files
marcobambiniclaude
andcommitted
Bump version to 1.2.0
Promotes the Unreleased section to 1.2.0 and records this branch's ten fixes under it. That section's lead paragraph had to go: it said the extension was unchanged from 1.1.0 and that a build produced the same binaries, which was true while Unreleased held only benchmark and README work, and is not true of a release carrying three out-of-bounds writes. Those three are called out under Security with how each is reached, because this file is what the release tag publishes to the website and what somebody reads to decide whether to upgrade. Package.swift is deliberately untouched. Its URL and checksum name a release artifact that does not exist yet, and CI rewrites both once the tag publishes one, in the commit it marks as an automated update. Bumping the URL by hand now would leave Swift consumers pointing at 1.2.0 with 1.1.2's checksum. (Deliberately not quoting CI's sentinel string here: main.yml gates every job on the head commit message not containing it, and the whole build skipped when it did.) Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
1 parent 40bc5b5 commit 62daad7

2 files changed

Lines changed: 63 additions & 4 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 62 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,12 @@ All notable changes to this project will be documented in this file.
44

55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
66

7-
## [Unreleased]
7+
## [1.2.0] - 2026-11-01
88

9-
Documentation and tooling only — the extension itself is unchanged from 1.1.0, so a build
10-
from this revision produces the same binaries.
9+
A read-through of the sources, followed by a security review of all of `src/`, turned up
10+
ten bugs. Three of them write outside their buffers and are reachable from ordinary SQL,
11+
so upgrading is recommended for anyone whose application lets untrusted input reach a
12+
connection with the extension loaded. No API changed and no index needs rebuilding.
1113

1214
### Changed
1315

@@ -32,6 +34,63 @@ from this revision produces the same binaries.
3234
faster** than the exact scan — it does beat brute force. What holds is the comparison
3335
that mattered: `INT8` is 4x faster again at twice the index size, so TurboQuant's
3436
argument is memory rather than throughput.
37+
- **A `NULL` key in `_sqliteai_vector` crashed the next `vector_init()`.** That table is
38+
an ordinary writable one, and `PRIMARY KEY` on a rowid table does not imply `NOT NULL`,
39+
so the key went to `strcmp()` unchecked. Such rows are now skipped.
40+
- **A failed `vector_quantize()` left the extension describing an index that no longer
41+
existed.** The quantization type, bit width, scale and offset are written into the table
42+
context before the pass that can still fail, and the savepoint rolls the shadow table
43+
back without them. Scans then read the chunks at the wrong stride and reported made-up
44+
rowids and distances with no error at all. Those fields, and the TurboQuant cache, are
45+
now restored along with the rollback.
46+
- **A quant chunk claiming zero vectors was read past the end of its blob.** Zero is the
47+
streaming scans' "load the next chunk" sentinel, so such a chunk slipped past the length
48+
check beside it, which degenerates to `bytes < 0`, and one fabricated row came back.
49+
Every count test now rejects it, and `vector_quantize_preload()` catches it at load time
50+
rather than leaving it to query time.
51+
- **`vector_as_*()` ignored its optional dimension argument for BLOB input**, though it is
52+
documented as a stricter check and the `BIT` and JSON paths already enforced it. A
53+
wrong-sized vector was stored and then skipped in silence by every scan, so it never
54+
appeared in a result.
55+
- **`max_memory=0` could not be set, and an unparseable value was dropped silently.** Zero
56+
is the one value the quantizer reads as "use whatever memory the index needs", but the
57+
parser used a `0` return to signal failure, so the two were indistinguishable. A bad
58+
`max_memory` is now reported like every other invalid option.
59+
- **The `INT8` and `UINT8` cosine kernels accumulated in 32 bits** in the scalar and SSE2
60+
backends, wrapping around past roughly 133k and 66k dimensions; NEON, AVX2 and AVX-512
61+
already used 64-bit accumulators. SSE2 now also computes `sqrt(a)*sqrt(b)` like every
62+
other backend instead of `sqrtf(a*b)`, which could overflow in `float`, so all five
63+
compute the same cosine.
64+
65+
### Security
66+
67+
- **Out-of-bounds write from a large `k`.** The top-k arrays were allocated with
68+
`sqlite3_malloc()`, whose parameter is an `int`, from a `size_t` byte count. `k` comes
69+
straight from the query, so `k=536870913` asked for `0x100000008` bytes, got 8, and the
70+
`memset` that follows overran them. Both allocations now go through
71+
`sqlite3_malloc64()`, so an absurd `k` is a clean `SQLITE_NOMEM`. Manifests as a crash:
72+
the length is not controllable and the value written is zero.
73+
- **Heap buffer overflow in JSON vector parsing.** `vector_from_json()` sized its buffer
74+
and bounded its writes from two different numbers — the buffer from
75+
`sqlite3_malloc((int)alloc)`, which truncated a `size_t`, and the bound from the
76+
untruncated `alloc`. A JSON array with 2^30 commas got an 8-byte buffer and a bound of
77+
1073741825 elements, and the parse loop wrote `float`s of the caller's choosing straight
78+
past it; the comma count sizes the buffer to the byte, which makes this a precise write
79+
primitive rather than a crash. Reachable through any `vector_as_*()` and through the TEXT
80+
query-vector argument of both scans. It took a TEXT value of about a gigabyte, so a host
81+
built with `SQLITE_MAX_LENGTH >= 1073741824` — the limit that applies is the host's,
82+
since this ships as a loadable extension. There is now a single capacity in 64 bits: the
83+
allocation uses `sqlite3_malloc64()` and the loop checks against that same number.
84+
- **Null write from an unbounded `dimension`.** The declared dimension was only checked
85+
for being positive, so it reached `INT_MAX` and overflowed the size arithmetic
86+
downstream. `(dim/2)*12` in the TurboQuant rotation plan wraps negative past 357913941,
87+
which skipped the allocation of the plan's coordinate arrays and still reported the plan
88+
as valid; `vector_init` with `dimension=400000000` followed by a TurboQuant
89+
`vector_quantize` then crashed the process on an empty table, since the plan is built
90+
before any row is read. Dimensions are now bounded at 2^24 where they are parsed, which
91+
is upstream of every one of those computations — and of the signed-overflow `dim + 7`
92+
expressions in the packing helpers. A dimension above `INT_MAX` is also rejected rather
93+
than wrapped: `4294967300` used to come through as the dimension 4.
3594

3695
## [1.1.0] - 2026-08-24
3796

‎src/sqlite-vector.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
extern "C" {
2525
#endif
2626

27-
#define SQLITE_VECTOR_VERSION "1.1.2"
27+
#define SQLITE_VECTOR_VERSION "1.2.0"
2828

2929
SQLITE_VECTOR_API int sqlite3_vector_init (sqlite3 *db, char **pzErrMsg, const sqlite3_api_routines *pApi);
3030

0 commit comments

Comments
 (0)