Skip to content

sqlite: throw on oversized strings instead of aborting - #66521

Open
trivikr wants to merge 1 commit into
nodejs:mainfrom
trivikr:sqlite-error-msg-v8-string-limit
Open

trivikr wants to merge 1 commit into
nodejs:mainfrom
trivikr:sqlite-error-msg-v8-string-limit

Conversation

@trivikr

@trivikr trivikr commented Oct 5, 2026 •

Copy link
Copy Markdown
Member

Fixes: #66520
Fixes: #66522

Several conversions from SQLite text to V8 strings passed a length of -1 to String::NewFromUtf8(). With that length, V8 skips its length check and aborts the process when the UTF-8 text exceeds String::kMaxLength.

SQLite error messages embed the offending identifier or token, so CreateSQLiteErrorImpl() could hit this. NullableSQLiteStringToValue(), used for setAuthorizer() callback arguments and statement.columns() metadata, had the same problem, and the authorizer also called ToLocalChecked() on each argument.

Convert error messages with Utf8StringMaybeOneByte(), and check the length up front in NullableSQLiteStringToValue(), so oversized strings throw ERR_STRING_TOO_LONG as column values already do. In the authorizer, deny the action and let the pending error reach the caller.


Assisted-by: claude:opus-5.5

@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Review requested:

  • @nodejs/sqlite

@nodejs-github-bot nodejs-github-bot added c++ Issues and PRs that require attention from people who are familiar with C++. needs-ci PRs that need a full CI run. sqlite Issues and PRs related to the SQLite subsystem. labels Oct 5, 2026
@trivikr
trivikr force-pushed the sqlite-error-msg-v8-string-limit branch 2 times, most recently from c6c38b5 to a9632cc Compare October 5, 2026 03:25
@trivikr trivikr changed the title sqlite: throw on oversized error messages sqlite: throw on oversized strings instead of aborting Oct 5, 2026
Several conversions from SQLite text to V8 strings passed a length of
-1 to String::NewFromUtf8(). With that length, V8 skips its length
check and aborts the process when the UTF-8 text exceeds
String::kMaxLength.

SQLite error messages embed the offending identifier or token, so
CreateSQLiteErrorImpl() could hit this. NullableSQLiteStringToValue(),
used for setAuthorizer() callback arguments and statement.columns()
metadata, had the same problem, and the authorizer also called
ToLocalChecked() on each argument.

Convert error messages with Utf8StringMaybeOneByte(), and check the
length up front in NullableSQLiteStringToValue(), so oversized strings
throw ERR_STRING_TOO_LONG as column values already do. In the
authorizer, deny the action and let the pending error reach the caller.

Signed-off-by: Trivikram Kamat <16024985+trivikr@users.noreply.github.com>
Assisted-by: claude:opus-5.5
@trivikr
trivikr force-pushed the sqlite-error-msg-v8-string-limit branch from a9632cc to b5dfc66 Compare October 5, 2026 15:18

@araujogui araujogui left a comment

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.

LGTM

@trivikr trivikr added request-ci Add this label to start a Jenkins CI on a PR. Only starts once the PR has an approving review. author ready PRs with CI started, the required approvals, and no outstanding review comments. labels Oct 5, 2026
@github-actions github-actions Bot removed the request-ci Add this label to start a Jenkins CI on a PR. Only starts once the PR has an approving review. label Oct 5, 2026
@nodejs-github-bot

This comment was marked as outdated.

@codecov

codecov Bot commented Oct 5, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.40%. Comparing base (bbd566d) to head (b5dfc66).
⚠️ Report is 11 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #66521      +/-   ##
==========================================
- Coverage   92.74%   90.40%   -2.34%     
==========================================
  Files         422      791     +369     
  Lines      193170   275995   +82825     
  Branches    29783    52976   +23193     
==========================================
+ Hits       179160   249520   +70360     
- Misses      13682    16873    +3191     
- Partials      328     9602    +9274     
Files with missing lines Coverage Δ
src/node_sqlite.cc 82.05% <100.00%> (ø)

... and 499 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.

@trivikr trivikr added the resume-ci Add this label to resume the latest eligible Jenkins CI run on a PR with an approving review. label Oct 5, 2026
@github-actions github-actions Bot added resume-ci-failed Resuming CI with the resume-ci label failed and requires manual intervention. and removed resume-ci Add this label to resume the latest eligible Jenkins CI run on a PR with an approving review. labels Oct 5, 2026
@github-actions

github-actions Bot commented Oct 5, 2026

Copy link
Copy Markdown
Contributor

Failed to resume CI

   ✖  test/parallel/test-sqlite-statement.js
   ℹ  https://ci.nodejs.org/job/node-test-binary-windows-js-suites/RUN_SUBSET=3,nodes=win2022-COMPILED_BY-vs2022_clang/43766/consoleText
✖  Refusing to resume CI: failures reference files changed by this PR
Full Auto Start CI output
�[36m⠋�[39m Validating Jenkins credentials
�[36m⠋�[39m Validating Jenkins credentials
✔  Jenkins credentials valid
�[36m⠙�[39m Looking for CI runs for pull request 66521
�[36m⠙�[39m Looking for CI runs for pull request 66521
�[36m⠙�[39m Getting PR from nodejs/node/pull/66521
�[36m⠙�[39m Getting reviews from nodejs/node/pull/66521
�[36m⠙�[39m Getting comments from nodejs/node/pull/66521
✔  Found PR CI job 78186
�[36m⠹�[39m Querying data for job/node-test-pull-request/78186/
�[36m⠹�[39m Querying data for job/node-test-pull-request/78186/
�[36m⠹�[39m Querying API for job/node-test-pull-request/78186/
✔  Build data downloaded
�[36m⠹�[39m Checking whether PR CI job 78186 can be resumed
�[36m⠹�[39m Checking whether PR CI job 78186 can be resumed
✔  Jenkins offers a Resume build action
�[36m⠸�[39m Checking failures against changed PR files
�[36m⠸�[39m Checking failures against changed PR files
�[36m⠼�[39m Querying data for job/node-test-pull-request/78186/
�[36m⠼�[39m Querying API for job/node-test-pull-request/78186/
✔  Build data downloaded
�[36m⠼�[39m Querying failures of job/node-test-commit/93023/
�[36m⠼�[39m Querying failures of job/node-test-commit/93023/
�[36m⠼�[39m Querying API for job/node-test-commit-windows-fanned/81005/
�[36m⠴�[39m Querying API for job/node-test-binary-windows-js-suites/43766/
�[36m⠴�[39m Querying API for job/node-test-binary-windows-js-suites/RUN_SUBSET=3,nodes=win2022-COMPILED_BY-vs2022_clang/43766/
�[36m⠦�[39m Querying console text for job/node-test-binary-windows-js-suites/RUN_SUBSET=3,nodes=win2022-COMPILED_BY-vs2022_clang/43766/
✔  Data downloaded
   ✖  test/parallel/test-sqlite-statement.js
   ℹ  https://ci.nodejs.org/job/node-test-binary-windows-js-suites/RUN_SUBSET=3,nodes=win2022-COMPILED_BY-vs2022_clang/43766/consoleText
ok 1400 sea/test-single-executable-application-asset-keys # skip Cannot find signtool: Error: - process terminated with status 1, expected 0
  ---
  duration_ms: 2657.09900
  ...
ok 1401 parallel/test-sqlite-statement
✖  Refusing to resume CI: failures reference files changed by this PR

View workflow run

@trivikr

trivikr commented Oct 6, 2026 •

Copy link
Copy Markdown
Member Author

I'm not sure why resume-ci failed.

The error is in report/test-report-process-timeout-worker and not test/parallel/test-sqlite-statement.js

...
ok 1401 parallel/test-sqlite-statement
  ---
  duration_ms: 34102.26500
  ...
ok 1402 sea/test-single-executable-application-assets # skip Cannot find signtool: Error: - process terminated with status 1, expected 0
  ---
  duration_ms: 2427.06500
  ...
 failed 1 out of 10
not ok 1403 report/test-report-process-timeout-worker
  ---
  duration_ms: 6928.28600
  severity: fail
  exitcode: 1
  stack: |-
    <anonymous_script>:450
          "add
    
    SyntaxError: Unterminated string in JSON at position 12288 (line 450 column 11)
        at JSON.parse (<anonymous>)
        at Object.validate (C:\workspace\node-test-binary-windows-js-suites\node\test\common\report.js:32:24)
        at Object.<anonymous> (C:\workspace\node-test-binary-windows-js-suites\node\test\report\test-report-process-timeout-worker.js:36:10)
        at Module._compile (node:internal/modules/cjs/loader:1968:14)
        at Object..js (node:internal/modules/cjs/loader:2108:10)
        at Module.load (node:internal/modules/cjs/loader:1690:32)
        at Module._load (node:internal/modules/cjs/loader:1480:12)
        at wrapModuleLoad (node:internal/modules/cjs/loader:261:19)
        at Module.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:171:5)
        at node:internal/main/run_main_module:33:47
    
    Node.js v27.0.0-pre
...

https://ci.nodejs.org/job/node-test-binary-windows-js-suites/43766/RUN_SUBSET=3,nodes=win2022-COMPILED_BY-vs2022_clang/console

@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@trivikr trivikr added commit-queue PRs queued for automated landing through the Commit Queue. and removed resume-ci-failed Resuming CI with the resume-ci label failed and requires manual intervention. labels Oct 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

author ready PRs with CI started, the required approvals, and no outstanding review comments. c++ Issues and PRs that require attention from people who are familiar with C++. commit-queue PRs queued for automated landing through the Commit Queue. needs-ci PRs that need a full CI run. sqlite Issues and PRs related to the SQLite subsystem.

Projects

None yet

5 participants