Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New Published Rules - innopolis.flask-insecure-set_cookie #3114

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions innopolis/flask-insecure-set_cookie.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import flask
from flask import response as r

app = flask.Flask()

@app.route("/index")
def index():
resp = r.set_cookie("username","DrewDennison")
return resp

@app.route("/semper")
def semper():
resp = r.set_cookie("cartTotal",
generate_cookie_value("DrewDennison"),
secure=False)
return resp

@app.route("/admin")
def admin():
# this cookie is secure
resp = r.set_cookie("user—rights", "admin", secure=True,
httponly=True, samesite="Lax")
return resp
24 changes: 24 additions & 0 deletions innopolis/flask-insecure-set_cookie.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
rules:
- id: flask-insecure-set_cookie
languages:
- python
message: secure and httponly flags are false by default, therefore cookie will be
available in HTTP and in javascript.
patterns:
- pattern: '... .set_cookie(...)'
- pattern-not: '... .set_cookie(..., secure=True, ..., httponly=True, ...)'
severity: WARNING
metadata:
category: security
subcategory:
- vuln
cwe:
- 'CWE 1004: Sensitive Cookie Without ''HttpOnly'' Flag'
- 'CWE 614: Sensitive Cookie in HTTPS Session Without ''Secure'' Attribute'
confidence: LOW
likelihood: LOW
technology:
- flask
impact: MEDIUM
references:
- https://www.easydevguide.com/posts/flask_cookie_security
Loading