turiya / keyczar

Automatically exported from code.google.com/p/keyczar
0 stars 0 forks source link

keyczart creates world-readable keys #157

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. pip install python-keyczar==0.715
1. $ mkdir test
2. $ keyczart create --location=test/ --purpose=crypt
3. $ keyczart addkey --location=test/
4. $ ls -l test/

What is the expected output? What do you see instead?
The key especially should not be world readable, but I don't see any reason for 
the meta file to be world-readable either. I can chmod them, but that presents 
a race condition where a malicious process might have already read the new key. 
The files should simply be created in a more secure mode. 0600 or 0640 would 
both be better than 0644.

total 8
-rw-r--r-- 1 dolph dolph 160 Feb 11 19:51 1
-rw-r--r-- 1 dolph dolph 162 Feb 11 19:51 meta

What version of the product are you using? On what operating system?
python-keyczar 0.715

Please provide any additional information below.
As a workaround, I've wrapped my calls to keyczart in umask set / unset. For 
example (I'm using the python "library"):

  old_umask = os.umask(0o177)
  try:
    keyczart.main([                                                                                                                  
      'addkey',                                                                                                                    
      '--status=primary',                                                                                                          
      '--location=%s' % key_repository_path])
  finally:
    os.umask(old_umask)

Original issue reported on code.google.com by dolph.ma...@gmail.com on 12 Feb 2015 at 6:47

GoogleCodeExporter commented 9 years ago
Patch attached / available here: 
https://code.google.com/r/dolphmathews-keyczar/source/detail?r=6deb638bdd5cc219e
0c925dd4874644b9591adc8

Original comment by dolph.ma...@gmail.com on 13 Feb 2015 at 12:54

Attachments:

GoogleCodeExporter commented 9 years ago
Also opened a pull request against the new github repo to fix this:

  https://github.com/google/keyczar/pull/2

Original comment by dolph.ma...@gmail.com on 27 Feb 2015 at 11:22

GoogleCodeExporter commented 9 years ago
Merged in Github: 
https://github.com/google/keyczar/commit/3e662adf3f12c8844c6cf3a7352e7a6379e8fcf
e

Original comment by swillden@google.com on 28 Feb 2015 at 4:23

GoogleCodeExporter commented 9 years ago
Reopened. Devin pointed out that this also needs to be done in the other 
implementations.

Original comment by swillden@google.com on 28 Feb 2015 at 11:06