Skip to content

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

Open
harrshita123 wants to merge 2 commits into
google:masterfrom
harrshita123:fix/ffi-parameter-overflow
Open

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

Conversation

@harrshita123

@harrshita123 harrshita123 commented Jul 27, 2026

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
  • add native regression coverage for integer narrowing at the FFI boundary

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)

@harrshita123
harrshita123 marked this pull request as ready for review July 27, 2026 17:10
Comment thread lib/src/webcrypto/webcrypto.pbkdf2.dart Outdated
Comment thread lib/src/webcrypto/webcrypto.rsapss.dart Outdated
Comment thread lib/src/testing/regression/uint32_parameter_overflow.dart
Comment thread lib/src/impl_ffi/impl_ffi.pbkdf2.dart
Comment thread lib/src/impl_ffi/impl_ffi.rsapss.dart
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

2 participants