Skip to content

Harden ASN1_mbstring_ncopy - #29376

Closed
jogme wants to merge 2 commits into
openssl:masterfrom
jogme:utf8_cpy
Closed

jogme wants to merge 2 commits into
openssl:masterfrom
jogme:utf8_cpy

Conversation

@jogme

@jogme jogme commented Dec 11, 2025

Copy link
Copy Markdown
Contributor

Some output values were incorrectly checked against UTF8.

Checklist
  • documentation is added or updated
  • tests are added or updated

@jogme
jogme requested a review from vdukhovni December 11, 2025 12:01
@jogme

jogme commented Dec 11, 2025

Copy link
Copy Markdown
Contributor Author

@vdukhovni I added two missing checks for UTF8_putc; PTAL

@jogme
jogme force-pushed the utf8_cpy branch 2 times, most recently from 92eedd7 to 0936dd7 Compare December 11, 2025 12:47

@vdukhovni vdukhovni left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Basically fine. Just suggesting adding comments to highlight the interdependence of the code in type_str() and the output selection in ASN1_mbstring_ncopy().

Comment thread crypto/asn1/a_mbstr.c
Reported by Murali Aniruddhan

Signed-off-by: Norbert Pocs <[email protected]>

@shahsb shahsb left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Add a CHANGES entry for 3.3 (or next stable) mentioning "ASN.1: Harden mbstring copy against invalid UTF-8". Run fuzzing (e.g., via oss-fuzz) on this post-merge.

Comment thread crypto/asn1/a_mbstr.c
outlen = 0;
traverse_string(in, len, inform, out_utf8, &outlen);
ret = traverse_string(in, len, inform, out_utf8, &outlen);
if (ret < 0) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The traverse_string error handling assumes ret < 0 means invalid UTF-8, but confirm if traverse_string can return other negative values (e.g., out-of-memory). If so, consider a specific error code.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think this code is ok, it should not return other logic error than invalid string here.

Comment thread crypto/asn1/a_mbstr.c
Comment thread test/asn1_internal_test.c
Comment thread test/asn1_internal_test.c
vdukhovni
vdukhovni previously approved these changes Dec 14, 2025

@vdukhovni vdukhovni left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

LGTM + minor nit.

Comment thread crypto/asn1/a_strex.c Outdated
Comment thread crypto/asn1/a_strex.c

@vdukhovni vdukhovni left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Reconfirmed.

@vdukhovni
vdukhovni requested review from Sashan and mbroz December 15, 2025 12:43

@mbroz mbroz left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM, in fact it is mostly "check return codes" hardening we should use everywhere...

Comment thread crypto/asn1/a_mbstr.c
outlen = 0;
traverse_string(in, len, inform, out_utf8, &outlen);
ret = traverse_string(in, len, inform, out_utf8, &outlen);
if (ret < 0) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think this code is ok, it should not return other logic error than invalid string here.

@jogme jogme added approval: done This pull request has the required number of approvals branch: master Applies to master branch branch: 3.0 Applies to openssl-3.0 branch (EOL) branch: 3.3 Applies to openssl-3.3 (EOL) branch: 3.4 Applies to openssl-3.4 branch: 3.5 Applies to openssl-3.5 branch: 3.6 Applies to openssl-3.6 labels Dec 17, 2025
@openssl-machine openssl-machine added approval: ready to merge The 24 hour grace period has passed, ready to merge and removed approval: done This pull request has the required number of approvals labels Dec 18, 2025
@openssl-machine

Copy link
Copy Markdown
Collaborator

This pull request is ready to merge

openssl-machine pushed a commit that referenced this pull request Dec 18, 2025
Reported by Murali Aniruddhan

Signed-off-by: Norbert Pocs <[email protected]>

Reviewed-by: Nikola Pajkovsky <[email protected]>
Reviewed-by: Viktor Dukhovni <[email protected]>
(Merged from #29376)
openssl-machine pushed a commit that referenced this pull request Dec 18, 2025
Signed-off-by: Norbert Pocs <[email protected]>

Reviewed-by: Nikola Pajkovsky <[email protected]>
Reviewed-by: Viktor Dukhovni <[email protected]>
(Merged from #29376)
openssl-machine pushed a commit that referenced this pull request Dec 18, 2025
Reported by Murali Aniruddhan

Signed-off-by: Norbert Pocs <[email protected]>

Reviewed-by: Nikola Pajkovsky <[email protected]>
Reviewed-by: Viktor Dukhovni <[email protected]>
(Merged from #29376)
openssl-machine pushed a commit that referenced this pull request Dec 18, 2025
Signed-off-by: Norbert Pocs <[email protected]>

Reviewed-by: Nikola Pajkovsky <[email protected]>
Reviewed-by: Viktor Dukhovni <[email protected]>
(Merged from #29376)
openssl-machine pushed a commit that referenced this pull request Dec 18, 2025
Reported by Murali Aniruddhan

Signed-off-by: Norbert Pocs <[email protected]>

Reviewed-by: Nikola Pajkovsky <[email protected]>
Reviewed-by: Viktor Dukhovni <[email protected]>
(Merged from #29376)
openssl-machine pushed a commit that referenced this pull request Dec 18, 2025
Signed-off-by: Norbert Pocs <[email protected]>

Reviewed-by: Nikola Pajkovsky <[email protected]>
Reviewed-by: Viktor Dukhovni <[email protected]>
(Merged from #29376)
openssl-machine pushed a commit that referenced this pull request Dec 18, 2025
Reported by Murali Aniruddhan

Signed-off-by: Norbert Pocs <[email protected]>

Reviewed-by: Nikola Pajkovsky <[email protected]>
Reviewed-by: Viktor Dukhovni <[email protected]>
(Merged from #29376)
openssl-machine pushed a commit that referenced this pull request Dec 18, 2025
Signed-off-by: Norbert Pocs <[email protected]>

Reviewed-by: Nikola Pajkovsky <[email protected]>
Reviewed-by: Viktor Dukhovni <[email protected]>
(Merged from #29376)
openssl-machine pushed a commit that referenced this pull request Dec 18, 2025
Reported by Murali Aniruddhan

Signed-off-by: Norbert Pocs <[email protected]>

Reviewed-by: Nikola Pajkovsky <[email protected]>
Reviewed-by: Viktor Dukhovni <[email protected]>
(Merged from #29376)
openssl-machine pushed a commit that referenced this pull request Dec 18, 2025
Signed-off-by: Norbert Pocs <[email protected]>

Reviewed-by: Nikola Pajkovsky <[email protected]>
Reviewed-by: Viktor Dukhovni <[email protected]>
(Merged from #29376)
@jogme

jogme commented Dec 18, 2025

Copy link
Copy Markdown
Contributor Author

Merged to all active branches and resolved mergeconflicts with older branches.

Thank you for the reviews!

@jogme jogme closed this Dec 18, 2025
openssl-machine pushed a commit that referenced this pull request Dec 18, 2025
Reported by Murali Aniruddhan

Signed-off-by: Norbert Pocs <[email protected]>

Reviewed-by: Nikola Pajkovsky <[email protected]>
Reviewed-by: Viktor Dukhovni <[email protected]>
(Merged from #29376)
openssl-machine pushed a commit that referenced this pull request Dec 18, 2025
Signed-off-by: Norbert Pocs <[email protected]>

Reviewed-by: Nikola Pajkovsky <[email protected]>
Reviewed-by: Viktor Dukhovni <[email protected]>
(Merged from #29376)
websurfer5 pushed a commit to websurfer5/openssl that referenced this pull request Dec 23, 2025
Reported by Murali Aniruddhan

Signed-off-by: Norbert Pocs <[email protected]>

Reviewed-by: Nikola Pajkovsky <[email protected]>
Reviewed-by: Viktor Dukhovni <[email protected]>
(Merged from openssl#29376)
websurfer5 pushed a commit to websurfer5/openssl that referenced this pull request Dec 23, 2025
Signed-off-by: Norbert Pocs <[email protected]>

Reviewed-by: Nikola Pajkovsky <[email protected]>
Reviewed-by: Viktor Dukhovni <[email protected]>
(Merged from openssl#29376)
websurfer5 pushed a commit to websurfer5/openssl that referenced this pull request Dec 23, 2025
Reported by Murali Aniruddhan

Signed-off-by: Norbert Pocs <[email protected]>

Reviewed-by: Nikola Pajkovsky <[email protected]>
Reviewed-by: Viktor Dukhovni <[email protected]>
(Merged from openssl#29376)
websurfer5 pushed a commit to websurfer5/openssl that referenced this pull request Dec 23, 2025
Signed-off-by: Norbert Pocs <[email protected]>

Reviewed-by: Nikola Pajkovsky <[email protected]>
Reviewed-by: Viktor Dukhovni <[email protected]>
(Merged from openssl#29376)
websurfer5 pushed a commit to websurfer5/openssl that referenced this pull request Dec 29, 2025
Reported by Murali Aniruddhan

Signed-off-by: Norbert Pocs <[email protected]>

Reviewed-by: Nikola Pajkovsky <[email protected]>
Reviewed-by: Viktor Dukhovni <[email protected]>
(Merged from openssl#29376)
websurfer5 pushed a commit to websurfer5/openssl that referenced this pull request Dec 29, 2025
Signed-off-by: Norbert Pocs <[email protected]>

Reviewed-by: Nikola Pajkovsky <[email protected]>
Reviewed-by: Viktor Dukhovni <[email protected]>
(Merged from openssl#29376)
GhisBntly added a commit to GhisBntly/quictls that referenced this pull request Jan 29, 2026
Check return code of UTF8_putc

Signed-off-by: Norbert Pocs <[email protected]>

Reviewed-by: Nikola Pajkovsky <[email protected]>
Reviewed-by: Viktor Dukhovni <[email protected]>
(Merged from openssl#29376)
raspbian-autopush pushed a commit to raspbian-packages/openssl that referenced this pull request Jan 29, 2026
Reported by Murali Aniruddhan

Signed-off-by: Norbert Pocs <[email protected]>

Reviewed-by: Nikola Pajkovsky <[email protected]>
Reviewed-by: Viktor Dukhovni <[email protected]>
(Merged from openssl/openssl#29376)

Gbp-Pq: Name Harden-ASN1_mbstring_ncopy.patch
raspbian-autopush pushed a commit to raspbian-packages/openssl that referenced this pull request Jan 29, 2026
Signed-off-by: Norbert Pocs <[email protected]>

Reviewed-by: Nikola Pajkovsky <[email protected]>
Reviewed-by: Viktor Dukhovni <[email protected]>
(Merged from openssl/openssl#29376)

Gbp-Pq: Name Check-return-code-of-UTF8_putc.patch
raspbian-autopush pushed a commit to raspbian-packages/openssl that referenced this pull request Jan 29, 2026
Reported by Murali Aniruddhan

Signed-off-by: Norbert Pocs <[email protected]>

Reviewed-by: Nikola Pajkovsky <[email protected]>
Reviewed-by: Viktor Dukhovni <[email protected]>
(Merged from openssl/openssl#29376)

Gbp-Pq: Name Harden-ASN1_mbstring_ncopy.patch
raspbian-autopush pushed a commit to raspbian-packages/openssl that referenced this pull request Jan 29, 2026
Signed-off-by: Norbert Pocs <[email protected]>

Reviewed-by: Nikola Pajkovsky <[email protected]>
Reviewed-by: Viktor Dukhovni <[email protected]>
(Merged from openssl/openssl#29376)

Gbp-Pq: Name Check-return-code-of-UTF8_putc.patch
GhisBntly added a commit to GhisBntly/openssl-1.1.1 that referenced this pull request Jan 30, 2026
….19 to fix CVE-2025-69419:

Check return code of UTF8_putc

Signed-off-by: Norbert Pocs <[email protected]>

Reviewed-by: Nikola Pajkovsky <[email protected]>
Reviewed-by: Viktor Dukhovni <[email protected]>
(Merged from openssl/openssl#29376)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approval: ready to merge The 24 hour grace period has passed, ready to merge branch: master Applies to master branch branch: 3.0 Applies to openssl-3.0 branch (EOL) branch: 3.3 Applies to openssl-3.3 (EOL) branch: 3.4 Applies to openssl-3.4 branch: 3.5 Applies to openssl-3.5 branch: 3.6 Applies to openssl-3.6

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants