Skip to content

Conversation

@DavidBlaa
Copy link
Member

No description provided.

DavidBlaa and others added 30 commits December 11, 2025 11:56
Updated SQL insert statements to set 'iscomplex' to true for specific citation types in the dim_mappingkeys table.
cookie.Domain = Request.Url.Host; // Set the domain
cookie.Path = "/"; // Set the path
cookieJwt.Expires = DateTime.Now.AddDays(1); // Expires in 1 day

Check failure

Code scanning / CodeQL

Cookie security: persistent cookie

Avoid persistent cookies.

Copilot Autofix

AI about 7 hours ago

In general, to avoid persistent cookies for sensitive data, you either (1) make them session cookies by not setting an Expires (or Max-Age), so the browser keeps them only in memory and deletes them when the browser closes, or (2) stop storing the sensitive data in a cookie at all and rely on server‑side session state. Here we can preserve existing behavior while improving security by turning the "jwt" cookie into a session cookie.

The minimal, non‑breaking fix in this snippet is to remove the explicit expiration, which is the only thing making the cookie persistent. In ASP.NET, if you do not set Expires, HttpCookie defaults to a session cookie. So in Console/BExIS.Web.Shell/Controllers/AccountController.cs, within the login action where the JWT cookie is created (around lines 303‑316), we should delete the line cookieJwt.Expires = DateTime.Now.AddDays(1);. No other functional change is required: the cookie will still be created with the same name, value, domain, and path, but will now only live as long as the browser session.

No new imports, helper methods, or additional definitions are needed; this is strictly a one‑line removal in the existing method.

Suggested changeset 1
Console/BExIS.Web.Shell/Controllers/AccountController.cs

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/Console/BExIS.Web.Shell/Controllers/AccountController.cs b/Console/BExIS.Web.Shell/Controllers/AccountController.cs
--- a/Console/BExIS.Web.Shell/Controllers/AccountController.cs
+++ b/Console/BExIS.Web.Shell/Controllers/AccountController.cs
@@ -308,7 +308,6 @@
                         HttpCookie cookieJwt = new HttpCookie("jwt", jwt);
 
                         // Set additional properties if needed
-                        cookieJwt.Expires = DateTime.Now.AddDays(1); // Expires in 1 day
                         cookieJwt.Domain = Request.Url.Host; // Set the domain
                         cookieJwt.Path = "/"; // Set the path
 
EOF
@@ -308,7 +308,6 @@
HttpCookie cookieJwt = new HttpCookie("jwt", jwt);

// Set additional properties if needed
cookieJwt.Expires = DateTime.Now.AddDays(1); // Expires in 1 day
cookieJwt.Domain = Request.Url.Host; // Set the domain
cookieJwt.Path = "/"; // Set the path

Copilot is powered by AI and may make mistakes. Always verify output.
cookieJwt.Expires = DateTime.Now.AddDays(1); // Expires in 1 day
cookieJwt.Domain = Request.Url.Host; // Set the domain
cookieJwt.Path = "/"; // Set the path

Check failure

Code scanning / CodeQL

Cookie security: overly broad path

Overly broad path for cookie.

Copilot Autofix

AI about 7 hours ago

In general, to fix an overly broad cookie path, set the cookie’s Path to the actual context path (or a narrower application sub-path) instead of /. This limits which HTTP requests will include the cookie and prevents other applications on the same domain from accessing it.

In this specific code, we should replace cookieJwt.Path = "/"; with a path that corresponds to the current application’s virtual directory (context path). In ASP.NET, Request.ApplicationPath returns the application’s root path (for example, /BExIS or / if deployed at domain root). Using Request.ApplicationPath (or the corresponding MVC helper in this controller) preserves existing functionality for this app but avoids exposing the cookie to sibling apps hosted under the same domain. No new methods or external libraries are required; we only need to change the assignment of the Path property on the HttpCookie.

Concretely: in Console/BExIS.Web.Shell/Controllers/AccountController.cs, in the region where cookieJwt is configured (lines around 305–315), change cookieJwt.Path = "/"; to cookieJwt.Path = Request.ApplicationPath;. This will ensure the cookie is only sent for requests under the same application root, while still working correctly for all routes within this app.


Suggested changeset 1
Console/BExIS.Web.Shell/Controllers/AccountController.cs

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/Console/BExIS.Web.Shell/Controllers/AccountController.cs b/Console/BExIS.Web.Shell/Controllers/AccountController.cs
--- a/Console/BExIS.Web.Shell/Controllers/AccountController.cs
+++ b/Console/BExIS.Web.Shell/Controllers/AccountController.cs
@@ -310,7 +310,7 @@
                         // Set additional properties if needed
                         cookieJwt.Expires = DateTime.Now.AddDays(1); // Expires in 1 day
                         cookieJwt.Domain = Request.Url.Host; // Set the domain
-                        cookieJwt.Path = "/"; // Set the path
+                        cookieJwt.Path = Request.ApplicationPath; // Restrict the cookie to this application's path
 
                         // Add the cookie to the response
                         Response.Cookies.Add(cookieJwt);
EOF
@@ -310,7 +310,7 @@
// Set additional properties if needed
cookieJwt.Expires = DateTime.Now.AddDays(1); // Expires in 1 day
cookieJwt.Domain = Request.Url.Host; // Set the domain
cookieJwt.Path = "/"; // Set the path
cookieJwt.Path = Request.ApplicationPath; // Restrict the cookie to this application's path

// Add the cookie to the response
Response.Cookies.Add(cookieJwt);
Copilot is powered by AI and may make mistakes. Always verify output.
// Create a new cookie
HttpCookie cookie = new HttpCookie("jwt", jwt);
HttpCookie cookieJwt = new HttpCookie("jwt", jwt);

Check warning

Code scanning / CodeQL

Cookie 'Secure' attribute is not set to true

Cookie attribute 'Secure' is not set to true.
@DavidBlaa DavidBlaa merged commit 0a1fe2f into master Jan 12, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants