Add sanity checks in key export#9823
Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds sanity checks to prevent integer overflow in key export functions by validating contextLen before casting operations.
Changes:
- Added bounds check for
contextLenin TLS 1.2 key export to prevent overflow inseedLencalculation - Added bounds check for
contextLenin TLS 1.3 key export to prevent truncation when casting toword32 - Added test case to verify rejection of
contextLenvalues exceedingUINT16_MAX
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| src/ssl.c | Added validation to reject contextLen > UINT16_MAX in TLS 1.2 path to prevent overflow |
| src/tls13.c | Added validation to reject contextLen > UINT32_MAX in TLS 1.3 path to prevent truncation |
| tests/api.c | Added test case verifying rejection of oversized contextLen values |
Comments suppressed due to low confidence (1)
tests/api.c:1
- The test verifies that the function returns 0 (failure) for oversized
contextLen, but there's no test coverage for the TLS 1.3 path which usesUINT32_MAXas the limit. Consider adding a test case that exercises the TLS 1.3 code path withcontextLenexceedingUINT32_MAXto ensure both validation paths are covered.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated no new comments.
Comments suppressed due to low confidence (1)
tests/api.c:1
- The new test case claims
contextLenvalues exceedingUINT16_MAXmust be rejected, but it currently asserts success (... , 0). This makes the test contradictory and will fail to catch regressions. Update the assertion to expect a failure return (e.g.,ExpectIntNE(..., 0)or compare against the project’s standard failure code for this API).
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Jenkins retest this please. I could not reproduce test failure locally. |
|
Scan-Build Analysis shows that it is waiting for status to be reported, but when I click on the link and view the test it shows as completed successfully. Run |
Description
Resolve a casting overflow condition in
Added a bounds check on contextLen before the seedLen calculation.
Added a bounds check on contextLen against UINT32_MAX
Fixes zd21242
Testing
Added test case to
test_export_keying_material_cbChecklist