Bug 540387 - certutil causes segmentation fault when listing keys in cert database (package nss-tools)
Summary: certutil causes segmentation fault when listing keys in cert database (packag...
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Fedora
Classification: Fedora
Component: nss
Version: 12
Hardware: All
OS: Linux
low
medium
Target Milestone: ---
Assignee: Kamil Dudka
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2009-11-23 09:02 UTC by Karel Srot
Modified: 2010-02-05 01:40 UTC (History)
4 users (show)

Fixed In Version: 3.12.5-8.fc12
Doc Type: Bug Fix
Doc Text:
Clone Of: 540386
: 540386 (view as bug list)
Environment:
Last Closed: 2010-02-05 01:40:37 UTC
Type: ---
Embargoed:


Attachments (Terms of Use)
backtrace (3.79 KB, text/plain)
2009-11-24 16:18 UTC, Kamil Dudka
no flags Details
proposed fix (648 bytes, patch)
2009-12-12 08:59 UTC, Kamil Dudka
no flags Details | Diff
proposed fix (691 bytes, patch)
2009-12-12 09:02 UTC, Kamil Dudka
rrelyea: review+
Details | Diff

Description Karel Srot 2009-11-23 09:02:20 UTC
Description of problem:

certutil utility causes segmentation fault when listing keys in cert database after adding moduleDBOnly flag into pkcs11.txt.

This bug is reported to nss component since nss-tools is missing in bugzilla at the moment.


Version-Release number of selected component (if applicable):
nss-tools-3.12.4-14.fc12.i686


How reproducible:
always


Steps to Reproduce:
1. set environment variable NSS_DEFAULT_DB_TYPE=sql
2. create new nss cert database, e.g. ~/nssdb
3. add moduleDBOnly flag into ~/nssdb/pkcs11.txt
4. certutil -K -d ~/nssdb
see additional info for console log


Actual results:
segmentation fault


Expected results:
list keys in database (or some error message if the setting is misleading??)


Additional info:

[karel@fedora12 nssdb]$ uname -a
Linux fedora12.localdomain 2.6.31.5-127.fc12.i686.PAE #1 SMP Sat Nov 7 21:25:57 EST 2009 i686 i686 i386 GNU/Linux
[karel@fedora12 nssdb]$ rpm -q nss
nss-3.12.4-14.fc12.i686
[karel@fedora12 nssdb]$ rpm -q nss-tools
nss-tools-3.12.4-14.fc12.i686
[karel@fedora12 ~]$ export NSS_DEFAULT_DB_TYPE=sql
[karel@fedora12 ~]$ bash
[karel@fedora12 ~]$ cd ~/nssdb
[karel@fedora12 nssdb]$ certutil -N -d .
Enter a password which will be used to encrypt your keys.
The password should be at least 8 characters long,
and should contain at least one non-alphabetic character.

Enter new password: 
Re-enter password: 
[karel@fedora12 nssdb]$ ls
cert9.db  key4.db  pkcs11.txt
[karel@fedora12 nssdb]$ certutil -K -d .
certutil: Checking token "NSS Certificate DB" in slot "NSS User Private Key and Certificate Services"
certutil: no keys found
[karel@fedora12 nssdb]$ vim pkcs11.txt 
[karel@fedora12 nssdb]$ # adding moduleDBOnly flag
[karel@fedora12 nssdb]$ cat pkcs11.txt 
library=
name=NSS Internal PKCS #11 Module
parameters=configdir='.' certPrefix='' keyPrefix='' secmod='secmod.db' flags= updatedir='' updateCertPrefix='' updateKeyPrefix='' updateid='' updateTokenDescription='' 
NSS=Flags=internal,critical,moduleDBOnly trustOrder=75 cipherOrder=100 slotParams=(1={slotFlags=[RSA,DSA,DH,RC2,RC4,DES,RANDOM,SHA1,MD5,MD2,SSL,TLS,AES,Camellia,SEED,SHA256,SHA512] askpw=any timeout=30})
[karel@fedora12 nssdb]$ certutil -K -d .
Segmentation fault (core dumped)
[karel@fedora12 nssdb]$

Comment 1 Kamil Dudka 2009-11-24 16:18:16 UTC
Created attachment 373478 [details]
backtrace

Comment 2 Kamil Dudka 2009-11-24 16:20:22 UTC
I can confirm the crash. It ends in an infinite loop calling SECMOD_LoadModule() recursively and crashes on stack overflow. A backtrace of the crash without optimizations is attached.

Comment 3 Elio Maldonado Batiz 2009-11-24 18:27:42 UTC
From https://developer.mozilla.org/en/PKCS11_Module_Specs
moduleDB - this library includes NSS specific functions to supply additional module specs for loading. 
moduleDBOnly - this library has no PKCS #11 functions and is only used for loading additional modules.

Why would one add moduleDBOnly to flags for the NSS Internal PKCS #11 Module when it isn't so?

Comment 4 Kamil Dudka 2009-11-24 18:57:05 UTC
(In reply to comment #3)
> Why would one add moduleDBOnly to flags for the NSS Internal PKCS #11 Module
> when it isn't so?  

That's not enough reason for stack overflow within a security library :-)

Comment 5 Kamil Dudka 2009-12-12 08:59:14 UTC
Created attachment 377848 [details]
proposed fix

Comment 6 Kamil Dudka 2009-12-12 09:02:38 UTC
Created attachment 377849 [details]
proposed fix

Comment 7 Elio Maldonado Batiz 2009-12-14 05:57:49 UTC
This looks good. +1

Comment 8 Bob Relyea 2009-12-14 19:33:19 UTC
Comment on attachment 377849 [details]
proposed fix

r+, but it's not really a sufficient check to prevent recursion (only the simplest type of recursion).

(it's possible that some grandchild could call the return the modulespec of a grandparent.)

bob

Comment 9 Kamil Dudka 2009-12-14 19:38:55 UTC
(In reply to comment #8)
> (From update of attachment 377849 [details])
> r+, but it's not really a sufficient check to prevent recursion (only the
> simplest type of recursion).

Exactly. That's why the comment is there. I've been forced to make a trade-off between correctness and complexity. Anyway it should be sufficient to solve the bug reported in comment #0.

Comment 10 Bob Relyea 2009-12-14 20:09:29 UTC
Right. Solving the bigger problem is my issue (actually solving the first problem was my issue as well, but I don't mind the help;).

bob

Comment 11 Fedora Update System 2010-01-07 06:35:16 UTC
nss-3.12.5-2.fc12 has been submitted as an update for Fedora 12.
http://admin.fedoraproject.org/updates/nss-3.12.5-2.fc12

Comment 12 Fedora Update System 2010-01-07 21:41:38 UTC
nss-3.12.5-2.fc12 has been pushed to the Fedora 12 testing repository.  If problems still persist, please make note of it in this bug report.
 If you want to test the update, you can install it with 
 su -c 'yum --enablerepo=updates-testing update nss'.  You can provide feedback for this update here: http://admin.fedoraproject.org/updates/F12/FEDORA-2010-0262

Comment 13 Fedora Update System 2010-01-08 20:15:08 UTC
nss-3.12.5-2.fc12 has been pushed to the Fedora 12 testing repository.  If problems still persist, please make note of it in this bug report.
 If you want to test the update, you can install it with 
 su -c 'yum --enablerepo=updates-testing update nss'.  You can provide feedback for this update here: http://admin.fedoraproject.org/updates/F12/FEDORA-2010-0262

Comment 14 Fedora Update System 2010-01-15 19:00:38 UTC
nss-3.12.5-7.fc12 has been submitted as an update for Fedora 12.
http://admin.fedoraproject.org/updates/nss-3.12.5-7.fc12

Comment 15 Fedora Update System 2010-01-17 02:54:29 UTC
nss-3.12.5-7.fc12 has been pushed to the Fedora 12 testing repository.  If problems still persist, please make note of it in this bug report.
 If you want to test the update, you can install it with 
 su -c 'yum --enablerepo=updates-testing update nss'.  You can provide feedback for this update here: http://admin.fedoraproject.org/updates/F12/FEDORA-2010-0685

Comment 16 Fedora Update System 2010-01-25 21:22:09 UTC
nss-3.12.5-8.fc12 has been submitted as an update for Fedora 12.
http://admin.fedoraproject.org/updates/nss-3.12.5-8.fc12

Comment 17 Fedora Update System 2010-01-27 01:11:49 UTC
nss-3.12.5-8.fc12 has been pushed to the Fedora 12 testing repository.  If problems still persist, please make note of it in this bug report.
 If you want to test the update, you can install it with 
 su -c 'yum --enablerepo=updates-testing update nss'.  You can provide feedback for this update here: http://admin.fedoraproject.org/updates/F12/FEDORA-2010-1127

Comment 18 Fedora Update System 2010-02-05 01:40:11 UTC
nss-3.12.5-8.fc12 has been pushed to the Fedora 12 stable repository.  If problems still persist, please make note of it in this bug report.


Note You need to log in before you can comment on or make changes to this bug.