CVE-2022-39268: Cross-Site Request Forgery (CSRF) (CWE-352)
value: ### Impact In a CSRF attack, an innocent end user is tricked by an attacker into submitting a web request that they did not intend. This may cause actions to be performed on the website that can include inadvertent client or server data leakage, change of session state, or manipulation of an end user's account. ### Patch Upgrade to v2022.09.10 to patch this vulnerability. ### Workarounds Rebuild and redeploy the Orchest `auth-server` with this commit: https://github.com/orchest/orchest/commit/c2587a963cca742c4a2503bce4cfb4161bf64c2d ### References https://en.wikipedia.org/wiki/Cross-site_request_forgery https://cwe.mitre.org/data/definitions/352.html ### For more information If you have any questions or comments about this advisory: * Open an issue in https://github.com/orchest/orchest * Email us at rick@orchest.io
CWE description: The web application does not, or can not, sufficiently verify whether a well-formed, valid, consistent request was intentionally provided by the user who submitted the request.
CVSS v3 base score: 8.1
Published: 2022-09-30T21:15Z
Repository: https://github.com/orchest/orchest
Language: Python
Files changed: services/auth-server/app/app/views.py
Commit date: 2022-09-30 15:24:32 +0200
Commit message: Set auth cookies to SameSite=Lax

Diff: diff --git a/services/auth-server/app/app/views.py b/services/auth-server/app/app/views.py
index 2692bdc28..6b37c716f 100644
--- a/services/auth-server/app/app/views.py
+++ b/services/auth-server/app/app/views.py
@@ -112,12 +112,12 @@ def register_views(app: Flask) -> None:
             return "", 401
 
     @app.route("/login/clear", methods=["GET"])
     def logout() -> Response | None:
         resp = redirect_response("/")
-        resp.set_cookie("auth_token", "")
-        resp.set_cookie("auth_username", "")
+        resp.set_cookie("auth_token", "", samesite="Lax")
+        resp.set_cookie("auth_username", samesite="Lax")
         return resp
 
     def redirect_response(url: str, redirect_type: str = "server") -> Response:
         if redirect_type == "client":
             return jsonify({"redirect": url})
@@ -180,12 +180,13 @@ def register_views(app: Flask) -> None:
 
                     db.session.add(token)
                     db.session.commit()
 
                     resp = redirect_response(redirect_url, redirect_type)
-                    resp.set_cookie("auth_token", token.token)
-                    resp.set_cookie("auth_username", username)
+                    # samesite="Lax" to avoid CSRF attacks.
+                    resp.set_cookie("auth_token", token.token, samesite="Lax")
+                    resp.set_cookie("auth_username", username, samesite="Lax")
 
                     return resp
 
                 else:
                     return jsonify({"error": invalid_login_msg}), 401

Vulnerable code:         resp.set_cookie("auth_token", "")
        resp.set_cookie("auth_username", "")
                    resp.set_cookie("auth_token", token.token)
                    resp.set_cookie("auth_username", username)
Fixed code:         resp.set_cookie("auth_token", "", samesite="Lax")
        resp.set_cookie("auth_username", samesite="Lax")
                    # samesite="Lax" to avoid CSRF attacks.
                    resp.set_cookie("auth_token", token.token, samesite="Lax")
                    resp.set_cookie("auth_username", username, samesite="Lax")