diff --git a/python/ql/src/experimental/Security/CWE-614/InsecureCookie.py b/python/ql/src/experimental/Security/CWE-614/InsecureCookie.py new file mode 100644 index 00000000000..54bbeff7d12 --- /dev/null +++ b/python/ql/src/experimental/Security/CWE-614/InsecureCookie.py @@ -0,0 +1,15 @@ +from flask import Flask, request, make_response, Response + + +@app.route("/true") +def true(): + resp = make_response() + resp.set_cookie("name", value="value", secure=True) + return resp + + +@app.route("/flask_make_response") +def flask_make_response(): + resp = make_response("hello") + resp.headers['Set-Cookie'] = "name=value; Secure;" + return resp \ No newline at end of file diff --git a/python/ql/src/experimental/Security/CWE-614/InsecureCookie.qhelp b/python/ql/src/experimental/Security/CWE-614/InsecureCookie.qhelp new file mode 100644 index 00000000000..ab5e3031629 --- /dev/null +++ b/python/ql/src/experimental/Security/CWE-614/InsecureCookie.qhelp @@ -0,0 +1,26 @@ + + + + +

Failing to set the 'secure' flag on a cookie can cause it to be sent in cleartext. +This makes it easier for an attacker to intercept.

+
+ + +

Always set secure to True or add "; Secure;" to the cookie's raw value.

+
+ + +

This example shows two ways of adding a cookie to a Flask response. The first way uses set_cookie's +secure flag and the second adds the secure flag in the cookie's raw value.

+ +
+ + +
  • Detectify: Cookie lack Secure flag.
  • +
  • PortSwigger: TLS cookie without secure flag set.
  • +
    + +
    \ No newline at end of file