-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Python: Promote cookie injection query from experimental #16893
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
Python: Promote cookie injection query from experimental #16893
Conversation
0853bdb
to
070d678
Compare
QHelp previews: python/ql/src/Security/CWE-020/CookieInjection.qhelpConstruction of a cookie using user-supplied input.Constructing cookies from user input can allow an attacker to control a user's cookie. This may lead to a session fixation attack. Additionally, client code may not expect a cookie to contain attacker-controlled data, and fail to sanitize it for common vulnerabilities such as Cross Site Scripting (XSS). An attacker manipulating the raw cookie header may additionally be able to set cookie attributes such as RecommendationDo not use raw user input to construct cookies. ExampleIn the following cases, a cookie is constructed for a Flask response using user input. The first uses from flask import request, make_response
@app.route("/1")
def set_cookie():
resp = make_response()
resp.set_cookie(request.args["name"], # BAD: User input is used to set the cookie's name and value
value=request.args["name"])
return resp
@app.route("/2")
def set_cookie_header():
resp = make_response()
resp.headers['Set-Cookie'] = f"{request.args['name']}={request.args['name']};" # BAD: User input is used to set the raw cookie header.
return resp References
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like the query is now in the standard format, and the help file is also improved. I suspect we also benefit from more cookie write models.
Two questions:
- Is
python/ql/src/experimental/semmle/python/security/injection/CookieInjection.qll
still around? Could it be deleted as part of this? - You have simplified the alert to not mention specific flags. Is that to align with other languages or what is the rationale?
Ah, I guess this has been split out into another query? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Part of https://github.com/github/codeql-python-team/issues/792 promoting #6360;
Depends on #16696
Promotes the Cookie Injection query from experimental, finding instances of user input being used to set the name or value of a cookie.