Bug #4648
closedCVE-2014-0135 - Kafo does not handle default_values.yaml securely
Description
/tmp/default_values.yaml file has world readable permissions and does not check for existence when it's being created. Therefore it's prone to race-condition attacks. This file contains default values for all parameters (usually autogenerated passwords)
Proposed fix steps:- we'll use mktmpdir which will be passed to kafo_configure puppet module as a parameter
- kafo_configure puppet module will safely create file (check for non-existence, create file with 0600, then dumps data)
- packages (rpm, deb, gem) will remove any existing /tmp/default_values.yaml
Files
Updated by Marek Hulán almost 11 years ago
- File 0001-Fix-4648-store-default-values-securely.patch 0001-Fix-4648-store-default-values-securely.patch added
- Status changed from Assigned to Ready For Testing
Updated by Kurt Seifried almost 11 years ago
From http://kurt.seifried.org/2012/03/14/creating-temporary-files-securely/
Ruby
use Tempfile for files:
http://www.ruby-doc.org/stdlib-1.9.3/libdoc/tempfile/rdoc/Tempfile.html#method-c-new
use tmpdir for directories (require ‘tmpdir’ and then you can “Dir.mktmpdir”):
http://www.ruby-doc.org/stdlib-1.9.3/libdoc/tmpdir/rdoc/index.html
I would suggest using Tempfile as well. Belt and suspenders.
Updated by Dominic Cleal almost 11 years ago
Using mktmpdir should be sufficient to make this safe, so the child Puppet process is told to only write into that shared temporary space. The bit that concerns me in the check for File.exist? in the Puppet function, which isn't safe against races.
Better is to use an exclusive open on the file which will fail to open the file at the kernel level if it already exists, i.e. http://stackoverflow.com/questions/5226166/how-do-open-a-file-for-writing-only-if-it-doesnt-already-exist-in-ruby
Updated by Marek Hulán almost 11 years ago
- File 0001-Fix-4648-store-default-values-securely.patch 0001-Fix-4648-store-default-values-securely.patch added
We could create a tempfile in puppet process but after the process finishes it would be removed. So we could create it rather from kafo but then in puppet process we can't be sure about the origin, therefore I think we should be happy with tmp dir only.
Good catch with File.open Dominic, I'm attaching fixed version for re-review.
Updated by Marek Hulán almost 11 years ago
- Subject changed from Kafo does not handle default_values.yaml securely to CVE-2014-0135 - Kafo does not handle default_values.yaml securely
Updated by Dominic Cleal almost 11 years ago
- Status changed from Ready For Testing to Pending
Yep, the predictable filename is required too, but since it's in a safely created temporary directory, that's cool.
ACK, patch looks good.
Updated by Dominic Cleal over 10 years ago
- Target version changed from 1.9.0 to 1.8.4
Updated by Marek Hulán over 10 years ago
- Status changed from Pending to Closed
- % Done changed from 0 to 100
Applied in changeset f5f2d6d1aec4fb730638444b4014835a123de981.
Updated by Dominic Cleal over 10 years ago
Fixes released in Kafo 0.3.17 and 0.5.2.