Bug 1089476

Summary: Firefox crashes when using opensc-pkcs11 authentication module
Product: [Fedora] Fedora Reporter: Luca Giuzzi <luca.giuzzi>
Component: firefoxAssignee: Gecko Maintainer <gecko-bugs-nobody>
Status: CLOSED UPSTREAM QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: urgent Docs Contact:
Priority: unspecified    
Version: 20CC: collura, gecko-bugs-nobody, gmazyland, kalevlember, nmavrogi, stefw, stransky, tmraz
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2014-04-28 12:17:49 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Luca Giuzzi 2014-04-19 13:42:42 UTC
Description of problem:

The pkcs#11 opensc plugin corrupts the memory of firefox; it is thus unusable.

Version-Release number of selected component (if applicable):

opensc-0.13.0-11.fc20.x86_64
firefox-28.0-3.fc20.x86_64

[I have the same problem with the 32 bit version of the packages, though]


How reproducible:

Try to authenticate using a smartcard; the browser prompts for the pin of
the card and shows the relative certificate; however, after the data have been
confirmed, the memory of the browser is corrupted and either

a) there is a segmentation fault and firefox closes
b) no SSL using site is accessible and the error
security library: memory allocation failure
is presented


Steps to Reproduce:
1. try to authenticate using a smartcard (pkcs#11, via opensc) on some site

Actual results:

Firefox crashes

Expected results:

Authentication is successful and firefox does not crash.

Additional info:

The card reader I use is
Bus 006 Device 004: ID 058f:9520 Alcor Micro Corp. EMV Certified Smart Card Reader

The actual smartcard is the italian "Regione lombardia CNS" (which is supported by opensc as "Italian CNS/CNR"). 

I point out that this configuration used to work last time I checked (I reckon it was between 4 and 6 months ago).

Comment 1 Luca Giuzzi 2014-04-19 13:48:25 UTC
The error messages presented by firefox (when it does not crash right away) upon attempting a secure connection are:

a) 
An error occurred during a connection to serviziweb2.inps.it. Received incorrect handshakes hash values from peer. (Error code: ssl_error_bad_handshake_hash_value)

b)
An error occurred during a connection to serviziweb2.inps.it. security library: memory allocation failure. (Error code: sec_error_no_memory)

Actually, I suppose that the first error is due to memory corruption rather than a wrong hash being sent from the peer.

Comment 2 Luca Giuzzi 2014-04-19 14:15:07 UTC
I have also opened an issue on the OpenSC bug tracker:
https://github.com/OpenSC/OpenSC/issues/232

Comment 3 Luca Giuzzi 2014-04-20 09:45:25 UTC
I add some further detail; perhaps the problem is with firefox NSS interface rather than opensc.

1) running opensc with debug options does not show anything abnormal
2) I have the exact same problem with the aurora version of firefox
3) usign opensc with google-chrome  (after I enabled it with the following
modutil -dbdir sql:.pki/nssdb/ -add "OpenSC" -libfile /usr/lib64/pkcs11/opensc-pkcs11.so
)
does not show any corruption.

Comment 4 Nikos Mavrogiannopoulos 2014-04-21 12:46:59 UTC
Should that be reassigned to firefox then?

Note that the authors of opensc have a mode called opensc-onepin that enables some hacks especially for firefox. I don't know whether that is relevant with your case though: https://bugzilla.redhat.com/show_bug.cgi?id=1077167#c3

Comment 5 Luca Giuzzi 2014-04-21 15:48:14 UTC
I agree that the bug should be reassigned.

Comment 6 Luca Giuzzi 2014-04-21 15:49:13 UTC
(actually I have filed in the above referenced bug report on their bugzilla)

Comment 7 Martin Stransky 2014-04-28 12:17:49 UTC
Let's track this upstream.