Skip to content

fix(ffi): reject overflowing cryptographic parameters - #348

Open
harrshita123 wants to merge 1 commit into
google:masterfrom
harrshita123:fix/ffi-parameter-overflow
Open

fix(ffi): reject overflowing cryptographic parameters#348
harrshita123 wants to merge 1 commit into
google:masterfrom
harrshita123:fix/ffi-parameter-overflow

Conversation

@harrshita123

Copy link
Copy Markdown
Contributor

Fixes #347

Summary

  • reject PBKDF2 iteration counts that do not fit Web IDL's unsigned long
  • reject RSA-PSS salt lengths that cannot be represented by BoringSSL's signed 32-bit parameter
  • document the public parameter limits and add native regression coverage

Root cause

The native backend passed arbitrary-width Dart integers directly to fixed-width FFI parameters. Values outside those native ranges were narrowed before reaching BoringSSL, allowing PBKDF2 iterations and RSA-PSS salt lengths to wrap to different values.

The RSA-PSS path also accepted values such as 0xffffffff, which narrowed to BoringSSL's special -1 salt-length sentinel.

Impact

Oversized parameters now fail before the FFI call instead of silently selecting weaker or otherwise different cryptographic parameters. Valid parameter behavior is unchanged.

Validation

  • dart format --output=none --set-exit-if-changed .
  • dart analyze --fatal-warnings .
  • dart test test/webcrypto_test.dart (1,444 tests passed)
  • focused PBKDF2 and RSA-PSS overflow regression tests after rebasing onto current master

@harrshita123
harrshita123 marked this pull request as ready for review July 27, 2026 17:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: native FFI wraps oversized PBKDF2 iterations and RSA-PSS salt lengths

1 participant