Skip to content

check DER long-form length bounds in mg_der_to_tlv#3579

Closed
alhudz wants to merge 1 commit into
cesanta:masterfrom
alhudz:der-tlv-length-bounds
Closed

check DER long-form length bounds in mg_der_to_tlv#3579
alhudz wants to merge 1 commit into
cesanta:masterfrom
alhudz:der-tlv-length-bounds

Conversation

@alhudz
Copy link
Copy Markdown

@alhudz alhudz commented Jun 1, 2026

mg_der_to_tlv() parses ASN.1 from an untrusted TLS peer (the ECDSA signature in CertificateVerify). On a long-form length it reads der[1]-0x80 length bytes without checking they fit in dersz, so der[2..128] can be read past the buffer. Add the same guard mg_der_parse already has.

@cpq
Copy link
Copy Markdown
Member

cpq commented Jun 2, 2026

@alhudz could you report this to the https://github.com/cesanta/mongoose/security/advisories please ?

@alhudz
Copy link
Copy Markdown
Author

alhudz commented Jun 2, 2026

Sure, will file it through the advisories page. Same untrusted-peer path applies to the other two length checks I sent (#3581, #3582), happy to roll them into the same advisory if you'd prefer one report.

@scaprile
Copy link
Copy Markdown
Collaborator

scaprile commented Jun 2, 2026

@cpq YAD (Yet another duplicate).

@scaprile scaprile closed this Jun 2, 2026
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.

3 participants