SSLProtocol all -SSLv2 -SSLv3 SSLCompression off SSLHonorCipherOrder on # Intermediate compatibility SSLCipherSuite ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-GCM-SHA256:\ ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:\ DHE-DSS-AES128-GCM-SHA256:kEDH+AESGCM:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA256:\ ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:\ ECDHE-ECDSA-AES256-SHA384: ECDHE-RSA-AES256-SHA:ECDHE-ECDSA-AES256-SHA:DHE-RSA-AES128-SHA256:\ DHE-RSA-AES128-SHA:DHE-DSS-AES128-SHA256:DHE-RSA-AES256-SHA256:DHE-DSS-AES256-SHA:\ DHE-RSA-AES256-SHA:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES256-SHA256:\ AES128-SHA:AES256-SHA:AES:CAMELLIA:DES-CBC3-SHA:!aNULL:!eNULL:!EXPORT:!DES:!RC4:!MD5:\ !PSK:!aECDH:!EDH-DSS-DES-CBC3-SHA:!EDH-RSA-DES-CBC3-SHA:!KRB5-DES-CBC3-SHA
Strict-Transport-Security: max-age=31536000; includeSubDomains
Header always set Strict-Transport-Security "max-age=31536000; includeSubDomains"
Public-Key-Pins: pin-sha256="M8HztCzM3elUxkcjR2S5P4hhyBNf6lHkmjAHKhpGPWE="; pin-sha256="..." max-age=5184000; report-uri="https://www.example.net/hpkp-report"
www.tu-chemnitz.de
X-Frame-Options
(RFC 7034) X-Frame-Options: DENY X-Frame-Options: SAMEORIGIN X-Frame-Options: ALLOW-FROM https://www.friendly-site.com
Content-Type: image/jpeg
X-Content-Type-Options: nosniff
Content-Type
gefälligst vertrauen
<script src="http://boeser.server.biz/evil.js"></script>
Content-Security-Policy
(CSP).htaccess
Content-Security-Policy: script-src 'self' https://ajax.googleapis.com
script-src
, style-src
, font-src
‒ woher JavaScript, CSS, Fonts img-src
, media-src
, object-src
‒ woher Bilder, Audio/Video, Objekte ladenframe-src
, connect-src
‒ woher iframe-Inhalte, wohin Ajax/XHR, Websocketsdefault-src
*, 'none', 'self'
Beispiel:
Content-Security-Policy: default-src 'self'; img-src 'self' *.tu-chemnitz.de; frame-src 'none'
→ alles nur vom selben Server, Bilder von beliebigen Servern in tu-chemnitz.de, keine Inhalte in Frame
<button onclick="doSomeThings();">Klick mich!</button>
eval
natürlich auch<script src="better.js"></script> <button id="do">Klick mich!</button>
// better.js - mit jQuery $(document).ready(function() { $('#do').click(function() { alert('Yep.'); }); });
→ Bis dahin: Content-Security-Policy: script-src 'unsafe-inline'
→ wichtiger XSS-Schutz weg :-(
Content-Security-Policy-Report-Only: default-src 'self'; report-uri /csp-reporter.php
csp-reporter.php:
<?php // csp-reporter.php - CSP-Fehler loggen error_log('CSP: '. file_get_contents('php://input')); ?>
ssl_error_log:
[Thu Mar 12 11:10:45.262430 2015] [:error] [pid 53220] [client 134.109.200.128:47323] CSP: {"csp-report":{"document-uri":"https://www-sl7.hrz.tu-chemnitz.de/","referrer":"", "violated-directive":"default-src 'self'","effective-directive":"font-src", "original-policy":"default-src 'self'; report-uri /csp-reporter.php", "blocked-uri":"https://www.tu-chemnitz.de","status-code":0}}, referer: https://www-sl7.hrz.tu-chemnitz.de/
Content-Security-Policy: default-src 'self'; script-src 'self' 'unsafe-eval' 'unsafe-inline'; style-src 'self' 'unsafe-inline'; font-src 'self' data:; img-src 'self' data:
SSLCipherSuite
, SHA-2-Zertifikat Strict-Transport-Security
X-Frame-Options
Content-Security-Policy
angehen mod_security