Skip to content

deps: cherry-pick e807d4e379 from SQLite#63525

Merged
nodejs-github-bot merged 1 commit into
nodejs:mainfrom
junius-sec:sqlite-changeset-null-pk
May 28, 2026
Merged

deps: cherry-pick e807d4e379 from SQLite#63525
nodejs-github-bot merged 1 commit into
nodejs:mainfrom
junius-sec:sqlite-changeset-null-pk

Conversation

@junius-sec
Copy link
Copy Markdown
Contributor

@junius-sec junius-sec commented May 23, 2026

Backport the SQLite session extension fix for malformed changesets that omit
old values for primary-key columns. The upstream fix avoids passing NULL to
sessionBindValue() while applying UPDATE changesets.

This adds a regression test for DatabaseSync#applyChangeset() to verify that
the malformed changeset returns SQLITE_CORRUPT instead of crashing.

Refs: https://sqlite.org/src/info/e807d4e3798efd53
Refs: https://hackerone.com/reports/3736889
Refs: sqlite/sqlite@b869ed6

Tested on Linux x64:

$ python3 configure.py --without-npm --without-lief
$ make -j16
$ python3 tools/test.py --mode=release test/parallel/test-sqlite-session.js
All tests passed.

@nodejs-github-bot
Copy link
Copy Markdown
Collaborator

Review requested:

  • @nodejs/security-wg
  • @nodejs/sqlite

@nodejs-github-bot nodejs-github-bot added dependencies Pull requests that update a dependency file. needs-ci PRs that need a full CI run. sqlite Issues and PRs related to the SQLite subsystem. labels May 23, 2026
Copy link
Copy Markdown
Contributor

@louwers louwers left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should just stick to the regular SQLite release cadence I think.

@junius-sec
Copy link
Copy Markdown
Contributor Author

junius-sec commented May 23, 2026

Thanks for reviewing, @louwers.

I opened this PR because the disclosed HackerOne thread suggested that the
upstream fix could be cherry-picked publicly for the next regular releases and
that opening the PR could allow changelog credit.

If the project prefers to wait for the regular SQLite release cadence instead,
I’m happy to defer to that.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm agnostic towards merging, but we definitely shouldn't be regression testing on sqlite3's behalf, as it'll cause havoc with shared builds.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed, thanks. I pushed an update to skip this regression test when Node is
built with shared SQLite, so it only runs against the bundled SQLite copy that
this PR patches.

If you would prefer not to carry this SQLite regression test in Node at all,
I’m happy to remove it.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should be removed, yes. We're not aiming to test the behaviour of sqlite3, just our binding.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it wasn't for the fact that the fix that makes the process not crash hasn't been in a SQLite release yet, the added test would not raise any eyebrow, we can find similar tests in e.g.

name: 'Error',
message: 'bad parameter or other API misuse',
errcode: 21,
code: 'ERR_SQLITE_ERROR'

IMO it's not a blocking concern

Backport the SQLite session extension fix for corrupt changesets that
omit old values for primary-key columns. This avoids passing NULL to
sessionBindValue() while applying UPDATE changesets.

Refs: https://sqlite.org/src/info/e807d4e3798efd53
Signed-off-by: junius-sec <sksch323@naver.com>
@junius-sec junius-sec force-pushed the sqlite-changeset-null-pk branch from 0844bba to f0cdb8e Compare May 23, 2026 23:33
@codecov
Copy link
Copy Markdown

codecov Bot commented May 27, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.32%. Comparing base (debe2ed) to head (f0cdb8e).
⚠️ Report is 143 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #63525      +/-   ##
==========================================
+ Coverage   90.05%   90.32%   +0.27%     
==========================================
  Files         714      730      +16     
  Lines      225742   234205    +8463     
  Branches    42727    43919    +1192     
==========================================
+ Hits       203285   211555    +8270     
- Misses      14234    14373     +139     
- Partials     8223     8277      +54     

see 116 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@nodejs-github-bot
Copy link
Copy Markdown
Collaborator

@aduh95 aduh95 added the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label May 27, 2026
@atlowChemi
Copy link
Copy Markdown
Member

@aduh95 @junius-sec Why are we manually patching instead of the regular automated updates? how would this affect future automated updates?

@aduh95
Copy link
Copy Markdown
Contributor

aduh95 commented May 27, 2026

Without this patch, the process crashes with an uncatchable error, which is IMO bad enough. It will not affect future automated updates, next update will as always overwrite the entire directory. Floating patches that have landed upstream is not out of the ordinary

@junius-sec
Copy link
Copy Markdown
Contributor Author

@atlowChemi Thanks for the question. The reason for the manual patch is that the current behavior can crash the process with attacker-controlled input, so I think it’s worth fixing now rather than waiting for the next automated update. I also agree with aduh95 that this shouldn’t affect future automated updates, since the next update will overwrite the whole directory anyway.

@atlowChemi atlowChemi added the commit-queue Add this label to land a pull request using GitHub Actions. label May 28, 2026
@nodejs-github-bot nodejs-github-bot removed the commit-queue Add this label to land a pull request using GitHub Actions. label May 28, 2026
@nodejs-github-bot nodejs-github-bot merged commit d8ac301 into nodejs:main May 28, 2026
73 checks passed
@nodejs-github-bot
Copy link
Copy Markdown
Collaborator

Landed in d8ac301

@aduh95 aduh95 added the backported-to-v26.x PRs backported to the v26.x-staging branch. label May 28, 2026
aduh95 pushed a commit that referenced this pull request May 28, 2026
Original commit message:

    Fix a bug causing the session module to dereference a NULL pointer when applying a corrupt changeset.
    FossilOrigin-Name: e807d4e3798efd532b3d78d1dfe513ed4fbd3cb793dd0ae5c30cae6031422b10

Refs: https://sqlite.org/src/info/e807d4e3798efd53
Signed-off-by: junius-sec <sksch323@naver.com>
PR-URL: #63525
Refs: https://hackerone.com/reports/3736889
Refs: sqlite/sqlite@b869ed6
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Chemi Atlow <chemi@atlow.co.il>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

author ready PRs that have at least one approval, no pending requests for changes, and a CI started. backported-to-v26.x PRs backported to the v26.x-staging branch. dependencies Pull requests that update a dependency file. needs-ci PRs that need a full CI run. sqlite Issues and PRs related to the SQLite subsystem.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants