Repository navigation
fix(deps): bump knex to 3.2.9 for the search_path SQL injection (rewrite/main) - #1025
chappie-daemon wants to merge 1 commit into
Conversation
AIKIDO-2026-10469: knex 0.0.1-3.2.8 interpolates values passed to searchPath for the Postgres dialect into generated SQL without validating or escaping them. This branch still declares knex 2.4.2 and still imports it at runtime (src/database/client.ts, src/clean-db.ts, src/cli/commands/invite.ts, crates/nostream-storage/tests/capture/gen-storage-parity.mjs), so it carries the same vulnerable dependency as the default branch. 3.2.9 is the smallest published version containing the fix (#6411) and the version the advisory names. The repo never sets searchPath: grep -rn "search_path" src/ finds no match, so the vulnerable path is not reachable here. The bump is still taken, because the vulnerable dependency should not ship. knex 3.0.0 drops Node < 16 (the repo requires >=24.14.1) and 3.2.0 tightens the RawBinding type, which surfaced one compile error in benchmark-queries.ts: an assertion to unknown no longer satisfies RawBinding. Dropping the assertion is the fix - toSQL().bindings is already the accepted type and the emitted JavaScript is byte-identical with and without it.
🦋 Changeset detectedLatest commit: 93d996d The changes in this PR will be included in the next version bump. This PR includes changesets to release 0 packagesWhen changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the
|
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
[Medium impact] The PR appears safe to merge; no actionable defects were found.
|
Coverage Report for CI Build 41318259154Coverage decreased (-0.006%) to 73.973%Details
Uncovered ChangesNo uncovered changes found. Coverage RegressionsNo coverage regressions found. Coverage Stats💛 - Coveralls |
The same bump as #1024, applied to this branch because
rewrite/mainstill declares"knex": "2.4.2"and still imports it at runtime.AIKIDO-2026-10469: knex 0.0.1–3.2.8 interpolates values passed to
searchPathfor the Postgres dialect into generated SQL without validating or escaping them, so a value an attacker influences becomes an injected identifier.Why this branch needs it
knex is not dormant here:
The TypeScript server and its
test:unitsuite still run inchecks.yml, and the parity generator loads knex to apply the captured migrations.Version chosen: 3.2.9
The smallest published version containing the fix — #6411, "escape double quotes in searchPath to prevent SQL injection" — and the version the advisory names. 3.2.10 and 3.3.0 add nothing for this advisory.
Breaking changes read from the release notes:
>=24.14.1); typing fixes for raw bindings and mixed modules.RawBindingtightened, "types no longer allow knex to be called without tablename",firston 0 matches documented, migration lifecycle hooks.RETURNINGfix andDELETE … LIMITfor MySQL. Neither applies here.The one code change
src/scripts/benchmark-queries.tspassedbindings as readonly unknown[]todb.raw(); an assertion tounknownno longer satisfiesRawBinding. The assertion is dropped becausetoSQL().bindingsis already the accepted type — this removes an assertion rather than adding one:const { rows } = await db.raw<{ rows: { 'QUERY PLAN': ExplainResult[] }[] }>( `EXPLAIN (ANALYZE, BUFFERS, VERBOSE, FORMAT JSON) ${sql}`, - bindings as readonly unknown[], + bindings, )Compile-time only: the emitted JavaScript is byte-identical with and without the assertion —
sha256sum dist/src/scripts/benchmark-queries.jsisdf144e2b…df1ddain both builds.search_path: not usedNo match anywhere in the repository outside
node_modules. The vulnerable path is not reachable here; the bump removes a vulnerable dependency rather than closing a reachable hole.Verification
Exits 0 with no output. Resolved dependency:
The
docker:test:integrationsuite needs a real Postgres and is covered by CI's integration job.Note on the lockfile
knex 3.2.9 declares an optional peer on
pg-query-stream ^4.14.0; this repo pins 4.3.0 directly, so pnpm resolves the peer to 4.3.0. The peer is optional (used only by knex's.stream()), the lockfile installs cleanly with--frozen-lockfile, and nothing here calls it. Bumpingpg-query-streamis out of scope for a security bump.Changeset
.changeset/knex-3-2-9-security.md, in this branch's empty-front-matter form.