Skip to content

ffi: validate fast i32 argument ranges#64691

Open
trivikr wants to merge 1 commit into
nodejs:mainfrom
trivikr:ffi-i32-bypass-validation
Open

ffi: validate fast i32 argument ranges#64691
trivikr wants to merge 1 commit into
nodejs:mainfrom
trivikr:ffi-i32-bypass-validation

Conversation

@trivikr

@trivikr trivikr commented Jul 23, 2026

Copy link
Copy Markdown
Member

Fixes: #64690

V8’s Fast API converts signed integer arguments to int32 by
truncation. Fast FFI signatures using i32 or int32 did not enable the
JavaScript integer-validation wrapper, so optimized calls could accept
out-of-range or non-integer values that the generic FFI path rejects.

Add both signed 32-bit type names to the Fast API validation metadata and
native validation-selection check.


Assisted-by: openai:gpt-5.6-sol

@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Review requested:

  • @nodejs/ffi

@nodejs-github-bot nodejs-github-bot added c++ Issues and PRs that require attention from people who are familiar with C++. ffi Issues and PRs related to experimental Foreign Function Interface support. needs-ci PRs that need a full CI run. labels Jul 23, 2026
@trivikr trivikr added the request-ci Add this label to start a Jenkins CI on a PR. label Jul 23, 2026
Add i32 and int32 to Fast API integer validation so optimized calls
reject invalid values instead of allowing V8 to truncate them.

Signed-off-by: Kamat, Trivikram <16024985+trivikr@users.noreply.github.com>
Assisted-by: openai:gpt-5.6-sol
@trivikr
trivikr force-pushed the ffi-i32-bypass-validation branch from 5cfc0ae to a5ff09c Compare July 23, 2026 06:58
@codecov

codecov Bot commented Jul 23, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 50.00000% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 90.14%. Comparing base (0992f6b) to head (a5ff09c).

Files with missing lines Patch % Lines
src/ffi/fast.cc 0.00% 0 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #64691      +/-   ##
==========================================
- Coverage   90.14%   90.14%   -0.01%     
==========================================
  Files         741      741              
  Lines      242112   242114       +2     
  Branches    45605    45602       -3     
==========================================
- Hits       218244   218243       -1     
+ Misses      15360    15359       -1     
- Partials     8508     8512       +4     
Files with missing lines Coverage Δ
lib/internal/ffi/fast-api.js 93.55% <100.00%> (+6.21%) ⬆️
src/ffi/fast.cc 66.08% <0.00%> (-0.59%) ⬇️

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

c++ Issues and PRs that require attention from people who are familiar with C++. ffi Issues and PRs related to experimental Foreign Function Interface support. needs-ci PRs that need a full CI run. request-ci Add this label to start a Jenkins CI on a PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ffi: Fast FFI bypasses i32 range validation after V8 optimization

2 participants