Add security headers notes
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by Lowell Abbott · committed by Lowell Abbott · parent f962720 · Browse files · 1 file·+127 added−0 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
1 file+127 added−0 removed
- other:+127 added−0 removed
Provenance
- Commit
8459ced- Tree
d8a03ac- Author
Lowell Abbott <lowell.abbott@gmail.com>- Committer
Lowell Abbott <lowell.abbott@gmail.com>- Parent
f962720
1 file changed+127 added−0 removed
modified:docs/security.rst+127 added
102 unmodified lines103 vulnerabilities104 <https://github.com/pallets/flask/issues/248#issuecomment-59934857>`_, so105 this behavior was changed and :func:`~flask.jsonify` now supports serializing106 arrays.107+108+109+SSL/HTTPS110+---------111+112+For implementing HTTPS on your server113+114+Below some packages in suggestion order that implements this protocol:115+116+* `flask-talisman <https://github.com/GoogleCloudPlatform/flask-talisman>`_117+* `flask-sslify <https://github.com/kennethreitz/flask-sslify>`_118+* `flask-secure-headers <https://github.com/twaldear/flask-secure-headers>`_119+120+Security Headers121+----------------122+123+This sections contains sections headers supported by Flask and a list of packages in suggestion order that implements it124+125+`Content Security Policy <https://csp.withgoogle.com/docs/index.html>`_ (CSP)126+-----------------------------------------------------------------------------127+128+For enhancing security and preventing common web vulnerabilities such as cross-site scripting and MITM related attacks129+130+Example131+132+.. sourcecode:: html133+ 134+ Content-Security-Policy: default-src https:; script-src 'nonce-{random}'; object-src 'none'135+136+137+To learn more check `this <https://csp.withgoogle.com/docs/index.html>`_138+139+* `flask-talisman <https://github.com/GoogleCloudPlatform/flask-talisman>`_140+* `flask-csp <https://github.com/twaldear/flask-csp>`_141+* `flask-secure-headers <https://github.com/twaldear/flask-secure-headers>`_142+143+`HTTP Strict Transport Security <https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Strict-Transport-Security>`_ (HSTS)144+------------------------------------------------------------------------------------------------------------------------------145+146+147+For automatically redirect HTTP to HTTPS on all the website url's and prevent MITM attacks148+149+Example150+151+.. sourcecode:: html152+ 153+ Strict-Transport-Security: max-age=<expire-time 154+ Strict-Transport-Security: max-age=<expire-time>; includeSubDomains 155+ Strict-Transport-Security: max-age=<expire-time>; preload 156+157+To learn more check `this <https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Strict-Transport-Security>`_ 158+159+160+* `flask-talisman <https://github.com/GoogleCloudPlatform/flask-talisman>`_161+* `flask-sslify <https://github.com/kennethreitz/flask-sslify>`_162+* `flask-secure-headers <https://github.com/twaldear/flask-secure-headers>`_163+164+`X-FRAME-OPTIONS <https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Frame-Options>`_ (Clickjacking protection)165+-------------------------------------------------------------------------------------------------------------------------166+Prevents the client clicking page elements outside of the website avoiding hijacking or UI redress attacks167+168+169+.. sourcecode:: html170+ 171+ X-Frame-Options: DENY 172+ X-Frame-Options: SAMEORIGIN173+ X-Frame-Options: ALLOW-FROM https://example.com/174+175+To learn more check `this <https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Strict-Transport-Security>`_ 176+177+* `flask-talisman <https://github.com/GoogleCloudPlatform/flask-talisman>`_178+* `flask-secure-headers <https://github.com/twaldear/flask-secure-headers>`_179+180+`X-Content-Type-Options <https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Content-Type-Options>`_181+-------------------------------------------------------------------------------------------------------------182+183+Prevents XSS by blocking requests on clients and forcing then to read the content type instead of first opening it.184+185+.. sourcecode:: html186+ 187+ X-Content-Type-Options: nosniff188+189+To learn more check `this <https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Content-Type-Options>`_ 190+191+192+* `flask-talisman <https://github.com/GoogleCloudPlatform/flask-talisman>`_193+* `flask-secure-headers <https://github.com/twaldear/flask-secure-headers>`_194+195+`Cookie options <https://developer.mozilla.org/en-US/docs/Web/HTTP/Cookies#Secure_and_HttpOnly_cookies>`_196+----------------------------------------------------------------------------------------------------------197+198+For setting cookies on client-side storage199+200+Example201+202+.. sourcecode:: html203+ 204+ Set-Cookie: [cookie-name]=[cookie-value] 205+206+To learn more check `this <https://developer.mozilla.org/en-US/docs/Web/HTTP/Cookies#Secure_and_HttpOnly_cookies>`_207+208+* `flask-talisman <https://github.com/GoogleCloudPlatform/flask-talisman>`_209+* `flask-secure-headers <https://github.com/twaldear/flask-secure-headers>`_210+211+`HTTP Public Key Pinning <https://developer.mozilla.org/en-US/docs/Web/HTTP/Public_Key_Pinning>`_ (HPKP)212+-------------------------------------------------------------------------------------------------------213+214+For associating clients with web servers throught a certificate key and prevent MITM attacks215+216+Example217+218+.. sourcecode:: html219+220+ Public-Key-Pins: pin-sha256="base64=="; max-age=expireTime [; includeSubDomains][; report-uri="reportURI"] 221+222+To learn more check `this <https://developer.mozilla.org/en-US/docs/Web/HTTP/Public_Key_Pinning>`_223+224+* `flask-talisman <https://github.com/GoogleCloudPlatform/flask-talisman>`_225+* `flask-secure-headers <https://github.com/twaldear/flask-secure-headers>`_226+227+References:228+-----------229+230+* https://docs.djangoproject.com/en/1.11/topics/security/231+* https://blog.appcanary.com/2017/http-security-headers.html232+* https://developer.mozilla.org233+* https://csp.withgoogle.com/docs/index.html