-
Notifications
You must be signed in to change notification settings - Fork 519
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
Some compatibility issue with emoji #776
Comments
Data is truncated wrong when its length is greater than 255 bytes.
|
Can you verify if the same character encoding is being used in PHP and Node? |
message # 1 is not relevant because of message # 2. Issue is not with encoding or emoji but with data length(64 emoji characters has 256 bytes length). When data length greater than 72 bytes(not characters) it should be truncated, and truncation works fine with data length up to 255 bytes. As shown in message # 2 comparison data 72 bytes length with hash created from data 255 bytes(with same first 72 bytes) is true but not with data 256+ bytes length(with some exceptions...) |
I see what is happening. Lines 153 to 154 in 4c38d38
Lines 220 to 227 in 4c38d38
|
This issue is actually what caused the minor version bump from https://en.wikipedia.org/wiki/Bcrypt#Versioning_history While working on a patch, I also noticed that the current tests are broken. node.bcrypt.js/test/implementation.js Lines 19 to 28 in 4c38d38
They seem to be misguided as to what they should actually be testing for. For the Lines 216 to 217 in 4c38d38
The first test ends up with a assert.strictEqual(bcrypt.hashSync("012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234", "$2a$05$CCCCCCCCCCCCCCCCCCCCC."), "$2a$05$CCCCCCCCCCCCCCCCCCCCC.6.O1dLNbjod2uo0DVcW.jHucKbPDdHS");
assert.strictEqual(bcrypt.hashSync("0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345", "$2a$05$CCCCCCCCCCCCCCCCCCCCC."), "$2a$05$CCCCCCCCCCCCCCCCCCCCC.6.O1dLNbjod2uo0DVcW.jHucKbPDdHS");
assert.strictEqual(bcrypt.hashSync("01XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", "$2a$05$CCCCCCCCCCCCCCCCCCCCC."), "$2a$05$CCCCCCCCCCCCCCCCCCCCC.6.O1dLNbjod2uo0DVcW.jHucKbPDdHS");
assert.strictEqual(bcrypt.hashSync("01XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", "$2a$05$CCCCCCCCCCCCCCCCCCCCC."), "$2a$05$CCCCCCCCCCCCCCCCCCCCC.6.O1dLNbjod2uo0DVcW.jHucKbPDdHS");
assert.strictEqual(bcrypt.hashSync("01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456", "$2a$05$CCCCCCCCCCCCCCCCCCCCC."), "$2a$05$CCCCCCCCCCCCCCCCCCCCC.iR4w4CV15J.nwTvWxPojXRxApAByroS"); But... all of that is "okay"... maybe. It's actually expected and like I said, it's what caused the minor version bump from The tests for You can also try for yourself and see that the two inputs below generate the same hash... which is a problem. bcrypt.hashSync(
"0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345",
"$2b$05$CCCCCCCCCCCCCCCCCCCCC."
);
bcrypt.hashSync(
"01XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
"$2b$05$CCCCCCCCCCCCCCCCCCCCC."
); |
This should definitely be assigned a CVE. Users on v4 may not be quick to update without a prompt from npm/yarn informing them of the vulnerability. |
We are deprecating v4, but I don't think this warrants a CVE. The original bug in OpenBSD didn't get assigned a CVE |
The original bug was assigned CVE-2011-2483. In fact, the initial notification of this issue was on a mailing list with the subject "CVE request". Given the nature of this issue, a CVE is definitely warranted. |
The bug you have linked is a sign extension bug that affected |
You're right, I misread what the CVE was issued for. Nevertheless, I still believe this should be assigned a CVE. Do you have any justification as to why this clear security issue shouldn't be assigned a CVE, other than an example of one case where a CVE wasn't assigned? Is your stance that this isn't a security issue? |
Just following up on this and still trying to figure out why this hasn't been assigned a CVE. I've contacted Security@GitHub and they'll only issue a CVE to the project maintainer. Users running v4 in prod should be alerted that their password hashing library has a security flaw. |
@Piccirello I don't have access to create a CVE from Github as well. I'm not a maintainer. @ncb000gt I guess you can file an advisory on GitHub to alert users. I've already put a deprecation notice on the npm package. |
@agathver i've made you a maintainer on the project. let me know if you need more access than that. :) |
@Piccirello Hey! 👋 |
Hey folks, just updating that the vulnerability has been added to our DB: https://snyk.io/vuln/SNYK-JS-BCRYPT-572911 and was assigned CVE-2020-7689. |
Thanks @AdamGold |
Fix overflow bug. See issue kelektiv#776
When using 64+ emoji compatibility between bcrypt <> php and bcrypt <> bcryptjs is broken, whereas bcryptjs <> php is fine.
Code to represent the issue.
The output:
Fedora 31 x86_64, bcrypt 3.0.7, node v12.13.1
The text was updated successfully, but these errors were encountered: