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

crypto: throw proper errors if out enc is UTF-16 #12752

Closed
wants to merge 1 commit into from

Conversation

addaleax
Copy link
Member

Throw Errors instead of hard crashing when the .digest() output
encoding is UTF-16.

Fixes: #9817

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • commit message follows commit guidelines
Affected core subsystem(s)

crypto

Throw `Error`s instead of hard crashing when the `.digest()` output
encoding is UTF-16.

Fixes: nodejs#9817
@addaleax addaleax added crypto Issues and PRs related to the crypto subsystem. lts-watch-v6.x labels Apr 29, 2017
@nodejs-github-bot nodejs-github-bot added c++ Issues and PRs that require attention from people who are familiar with C++. crypto Issues and PRs related to the crypto subsystem. labels Apr 29, 2017
@gibfahn
Copy link
Member

gibfahn commented Apr 30, 2017

cc/ @nodejs/crypto

@shigeki
Copy link
Contributor

shigeki commented May 1, 2017

The doc says that only the following three encoding can be accepted.

The encoding can be 'hex', 'latin1' or 'base64'

Is it better to have white-listed check rather than having only UCS2 check?

@addaleax
Copy link
Member Author

addaleax commented May 1, 2017

@shigeki Yeah, those are the only encodings that actually make some sense here, so whitelisting sounds okay to me; that would be a breaking change, though.

@shigeki
Copy link
Contributor

shigeki commented May 1, 2017

that would be a breaking change, though.

I think that only utf-16le and other wrong encoding strings would be affected.
But I agree it gets semver major. It is a good chance to have in Node-v8 if possible.
If we need to have this in LTS, this PR is good.

@addaleax
Copy link
Member Author

addaleax commented May 3, 2017

@addaleax
Copy link
Member Author

addaleax commented May 3, 2017

Landed in 6c2daf0

@addaleax addaleax closed this May 3, 2017
@addaleax addaleax deleted the fix-crypto-9817 branch May 3, 2017 17:20
addaleax added a commit that referenced this pull request May 3, 2017
Throw `Error`s instead of hard crashing when the `.digest()` output
encoding is UTF-16.

Fixes: #9817
PR-URL: #12752
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com>
anchnk pushed a commit to anchnk/node that referenced this pull request May 6, 2017
Throw `Error`s instead of hard crashing when the `.digest()` output
encoding is UTF-16.

Fixes: nodejs#9817
PR-URL: nodejs#12752
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com>
@jasnell jasnell mentioned this pull request May 11, 2017
@gibfahn gibfahn mentioned this pull request Jun 15, 2017
3 tasks
gibfahn pushed a commit that referenced this pull request Jun 18, 2017
Throw `Error`s instead of hard crashing when the `.digest()` output
encoding is UTF-16.

Fixes: #9817
PR-URL: #12752
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com>
@gibfahn
Copy link
Member

gibfahn commented Jun 18, 2017

Landed this on v6.x, seems reasonably safe (node was previously hard crashing so it shouldn't get much worse).

LMK if this was a mistake.

gibfahn pushed a commit that referenced this pull request Jun 20, 2017
Throw `Error`s instead of hard crashing when the `.digest()` output
encoding is UTF-16.

Fixes: #9817
PR-URL: #12752
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com>
MylesBorins pushed a commit that referenced this pull request Jul 11, 2017
Throw `Error`s instead of hard crashing when the `.digest()` output
encoding is UTF-16.

Fixes: #9817
PR-URL: #12752
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com>
@MylesBorins MylesBorins mentioned this pull request Jul 18, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c++ Issues and PRs that require attention from people who are familiar with C++. crypto Issues and PRs related to the crypto subsystem.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

{Hash, Hmac}.digest and sign hard crash when supplied 'ucs2' encoding
7 participants