Skip to content

crypto: fix missing error checks on ASN1_STRING_to_UTF8() - #65200

Open
ndossche wants to merge 1 commit into
nodejs:mainfrom
ndossche:asn1_string-1
Open

crypto: fix missing error checks on ASN1_STRING_to_UTF8()#65200
ndossche wants to merge 1 commit into
nodejs:mainfrom
ndossche:asn1_string-1

Conversation

@ndossche

Copy link
Copy Markdown
Contributor

This function returns a negative error code on error. When it does so, the value_str pointer will remain uninitialized and cause a crash later on when it is freed by OPENSSL_free(). Even if it wouldn't crash there, it still fails to signal the error and an empty string may be propagated to the callers. The check also mirrors the other one in the same file.

Note: this was found by a static-dynamic analyser I'm developing.

Supersedes nodejs/ncrypto#41

This function returns a negative error code on error.
When it does so, the `value_str` pointer will remain uninitialized
and cause a crash later on when it is freed by OPENSSL_free().
Even if it wouldn't crash there, it still fails to signal the error
and an empty string may be propagated to the callers.
The check also mirrors the other one in the same file.

Signed-off-by: ndossche <nora.dossche@ugent.be>
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Review requested:

  • @nodejs/crypto
  • @nodejs/security-wg

@nodejs-github-bot nodejs-github-bot added dependencies Pull requests that update a dependency file. needs-ci PRs that need a full CI run. labels Aug 10, 2026
@panva panva added author ready PRs that have at least one approval, no pending requests for changes, and a CI started. request-ci Add this label to start a Jenkins CI on a PR. labels Aug 10, 2026
@github-actions github-actions Bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Aug 10, 2026
@nodejs-github-bot

This comment was marked as outdated.

@panva
panva requested a review from tniessen August 10, 2026 21:41
daltino

This comment was marked as resolved.

@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

author ready PRs that have at least one approval, no pending requests for changes, and a CI started. dependencies Pull requests that update a dependency file. needs-ci PRs that need a full CI run.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants