Skip to content

Fix buffer overflow in wc_HpkeLabeledExtract via oversized ECH#9927

Closed
anhu wants to merge 1 commit intowolfSSL:masterfrom
anhu:ech_overflow
Closed

Fix buffer overflow in wc_HpkeLabeledExtract via oversized ECH#9927
anhu wants to merge 1 commit intowolfSSL:masterfrom
anhu:ech_overflow

Conversation

@anhu
Copy link
Member

@anhu anhu commented Mar 9, 2026

SetEchConfigsEx accepted arbitrarily large ECH configs without bounds checking rawLen. This allowed attacker-controlled data (from DNS HTTPS records or TLS retry_configs) to overflow the fixed 512-byte labeled_ikm stack buffer in wc_HpkeLabeledExtract during ClientHello construction.

Add MAX_ECH_CONFIG_RAW_SZ to reject oversized configs at parse time, and add bounds checks in both wc_HpkeLabeledExtract and wc_HpkeLabeledExpand before writing into their fixed-size buffers.

Fixes ZD#21309

…config

SetEchConfigsEx accepted arbitrarily large ECH configs without bounds
checking rawLen. This allowed attacker-controlled data (from DNS HTTPS
records or TLS retry_configs) to overflow the fixed 512-byte labeled_ikm
stack buffer in wc_HpkeLabeledExtract during ClientHello construction.

Add MAX_ECH_CONFIG_RAW_SZ to reject oversized configs at parse time, and
add bounds checks in both wc_HpkeLabeledExtract and wc_HpkeLabeledExpand
before writing into their fixed-size buffers.

Fixes ZD#21309
@anhu anhu requested a review from wolfSSL-Bot March 9, 2026 13:50
@anhu anhu self-assigned this Mar 9, 2026
@philljj philljj added the For This Release Release version 5.9.0 label Mar 9, 2026
* is concatenated into a MAX_HPKE_LABEL_SZ buffer in wc_HpkeLabeledExtract
* along with version (7) + suite_id (HPKE_SUITE_ID_LEN) + label (~12) +
* TLS info prefix (8) overhead. */
#define MAX_ECH_CONFIG_RAW_SZ (MAX_HPKE_LABEL_SZ - 50)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where does the - 50 come from?

@anhu
Copy link
Member Author

anhu commented Mar 9, 2026

Closing because #9737 fixes this issue.

@anhu anhu closed this Mar 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

For This Release Release version 5.9.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants