Address an issue that allows a malicious client to place certificate files in arbitrary directories.

Thanks to David Black (disclosure@d1b.org) for pointing this out.
This commit is contained in:
Aldo Cortesi 2012-01-21 14:26:36 +13:00
parent d5e3722c97
commit c6150cc198
3 changed files with 11 additions and 10 deletions

View File

@ -13,7 +13,7 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import re, os, subprocess, datetime, urlparse, string
import time, functools, cgi, textwrap
import time, functools, cgi, textwrap, hashlib
import json
CERT_SLEEP_TIME = 1
@ -275,12 +275,13 @@ def dummy_cert(certdir, ca, commonname):
Returns cert path if operation succeeded, None if not.
"""
certpath = os.path.join(certdir, commonname + ".pem")
namehash = hashlib.sha256(commonname).hexdigest()
certpath = os.path.join(certdir, namehash + ".pem")
if os.path.exists(certpath):
return certpath
confpath = os.path.join(certdir, commonname + ".cnf")
reqpath = os.path.join(certdir, commonname + ".req")
confpath = os.path.join(certdir, namehash + ".cnf")
reqpath = os.path.join(certdir, namehash + ".req")
template = open(pkg_data.path("resources/cert.cnf")).read()
f = open(confpath, "w")