Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Possible Null Pointer Dereference in TLSWrap::PskClientCallback #56665

Open
wooffie opened this issue Jan 20, 2025 · 1 comment
Open

Possible Null Pointer Dereference in TLSWrap::PskClientCallback #56665

wooffie opened this issue Jan 20, 2025 · 1 comment
Labels
needs more info Issues without a valid reproduction. tls Issues and PRs related to the tls subsystem.

Comments

@wooffie
Copy link
Contributor

wooffie commented Jan 20, 2025

Version

20.18.0

Platform


Subsystem

crypto

What steps will reproduce the bug?

Problem around with part of code - https://github.com/nodejs/node/blob/da5f7aca6ac1fac2b7840dc11c0ef8e740cfc414/src/crypto/crypto_tls.cc#L1559C1-L1564C58

After creating Utf8Value object code checks its length, but not checks for nullptr. After this nullptr can be dereferenced in memcpy call

How often does it reproduce? Is there a required condition?

Condition - identity_buf stores nullptr

What is the expected behavior? Why is that the expected behavior?

Return 0, for consistent API, for example

if (*identity_buf == nullptr || identity_buf.length() > max_identity_len)
    return 0;

What do you see instead?

Additional information

Found by Linux Verification Center (linuxtesting.org) with SVACE.

Reporter: Burkov Egor (eburkov@rvision.ru).

Organization: R-Vision (support@rvision.ru).

@lpinca lpinca added the tls Issues and PRs related to the tls subsystem. label Jan 20, 2025
@tniessen
Copy link
Member

After creating Utf8Value object code checks its length, but not checks for nullptr. After this nullptr can be dereferenced in memcpy call

How often does it reproduce? Is there a required condition?

Condition - identity_buf stores nullptr

@wooffie Could you please clarify how this could happen and then lead to dereferencing a nullptr? As far as I can tell, only an empty Utf8Value could contain a nullptr (because allocations are checked), in which case its length would be zero and the pointer *identity_buf would never be dereferenced. (And even then, I am not sure it would contain a nullptr because small sizes should rely on stack allocation.)

@tniessen tniessen added the needs more info Issues without a valid reproduction. label Mar 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs more info Issues without a valid reproduction. tls Issues and PRs related to the tls subsystem.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants