sjcl icon indicating copy to clipboard operation
sjcl copied to clipboard

Chrome/59/Android zero-fill-right-shift bug in decrypt

Open sebjoub opened this issue 7 years ago • 8 comments

Hi, just checking if anybody has the same problem.

I narrowed it down to this line: file: core/codecString.js line: 20 out += String.fromCharCode(tmp >>> 24);

the zero fill right shift seems to not work all the time (very intermittent) with chrome 59 on android 6/7. Haven't seen the problem with Chrome 58, 59, 60 on MacOS/X, Linux, Windows.

To fix it I changed the line to: out += String.fromCharCode(((tmp&0xff000000) >>> 24)&0x000000ff);

Haven't played with the masks to see if one or the other makes it work or if I need both. Will do some more tests tomorrow.

Will fill a bug report with Chrome tomorrow....

Thanks.

sebjoub avatar Jul 02 '17 03:07 sebjoub

I can confirm that this issue seems to appear in latest Chrome on Android - more precisely, it seems the issue is in the Android System WebView which was updated on 30th of June.

Your hotfix seems to work. Have you had time to report this issue to Chrome?

scholtzm avatar Jul 04 '17 07:07 scholtzm

We're seeing this too but not quite so intermittently. On affected devices it breaks reliably every time. The workaround supplied by @sebjoub appears to fix it.

nukefusion avatar Jul 04 '17 08:07 nukefusion

This is a bug in Chrome I am already in contact with the Chrome Team and will open a bug with them today.

There is an easier fix though, replace the last line with out += String.fromCharCode(tmp >>> 8 >>> 8 >>> 8);

This only happens after a certain ramp-up phase. Likely happens because of an invalid optimization for ARM CPUs on a later optimization step

@sebjoub have you already filed a bug report with the Chrome team? If so please post a link.

Nilos avatar Jul 04 '17 08:07 Nilos

I published [email protected] which contains my fix for the problem. Thanks @sebjoub for the bug report.

Nilos avatar Jul 04 '17 08:07 Nilos

No I have not posted a bug report with the chrome team. I thought @Nilos did.

sebjoub avatar Jul 04 '17 13:07 sebjoub

Here is the URL for the chromium bug report: https://bugs.chromium.org/p/chromium/issues/detail?id=739175#

sebjoub avatar Jul 04 '17 14:07 sebjoub

Could anyone confirm exactly which Android devices this affects? We need to decide on whether to issue an urgent patch to our Cordova app. Is it a specific combination of Android version and Chrome version, or something else? I cannot replicate it on my Nexus 6P with Chrome 59 and Android 7.1.1.

jezbo7 avatar Jul 10 '17 08:07 jezbo7

@jezbo7

sjcl v1.0.6
Android System WebView v59.0.3071.125

However, as @Nilos pointed out, the behaviour was inconsistent and only happened after a certain ramp-up phase.

scholtzm avatar Jul 10 '17 08:07 scholtzm