Skip to content

fix: add bound check for Yc_length against server DH params#5737

Merged
CarolYeh910 merged 6 commits intoaws:mainfrom
CarolYeh910:fix-dhe-bound
Feb 18, 2026
Merged

fix: add bound check for Yc_length against server DH params#5737
CarolYeh910 merged 6 commits intoaws:mainfrom
CarolYeh910:fix-dhe-bound

Conversation

@CarolYeh910
Copy link
Copy Markdown
Contributor

@CarolYeh910 CarolYeh910 commented Feb 16, 2026

Goal

Bound the length of Yc_in buffer against the size of server DH parameters

Why

s2n_dh_compute_shared_secret_as_server() reads a peer-supplied Yc_in buffer without validating its length against the server DH group size. This allows clients to send oversized Yc_length values (up to 65535 bytes) and cause unnecessary memory allocation and CPU workload.

How

Validate Yc_length does not exceed server_dh_params_size before invoking BN_bin2bn() or DH_compute_key().

Callouts

We would like to thank Joshua Rogers (https://joshua.hu/) of AISLE Research Team (https://aisle.com/) for reporting this issue.

Testing

I added a unit test to verify that s2n server will fail for S2N_ERR_DH_SHARED_SECRET when a client sends an oversized Yc_in buffer. One thing to note is that the selected parameters in this test may cause s2n_pkcs3_to_dh_params() to fail on certain libcryptos due to different behaviors of DH_check() across versions. The purpose is not testing DH_check(), thus skipping the test when s2n_pkcs3_to_dh_params() fails.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@github-actions github-actions bot added the s2n-core team label Feb 16, 2026
@CarolYeh910 CarolYeh910 added this pull request to the merge queue Feb 18, 2026
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Feb 18, 2026
@CarolYeh910 CarolYeh910 added this pull request to the merge queue Feb 18, 2026
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Feb 18, 2026
@CarolYeh910 CarolYeh910 added this pull request to the merge queue Feb 18, 2026
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Feb 18, 2026
@CarolYeh910 CarolYeh910 added this pull request to the merge queue Feb 18, 2026
Merged via the queue into aws:main with commit f9cb28a Feb 18, 2026
54 checks passed
@CarolYeh910 CarolYeh910 deleted the fix-dhe-bound branch February 18, 2026 23:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants