<-- Back

Security scan reports the originURI cookie without the SameSite attribute in a Mendix application

Issue

A security scan reports a finding about a cookie without the SameSite attribute in a Mendix application. The finding refers to the originURI cookie. The Mendix Runtime sets this cookie on the sign-in page, for example on a request to /login.html or /SSO/.

The scanner explains that cookies without the SameSite attribute are sent in cross-origin requests. A malicious website can use this behavior for Cross-Site Request Forgery (CSRF) attacks.

Environment

  • Studio Pro (all versions)
  • Applications hosted in any deployment type

Cause

The default login.js file of the Mendix application template sets the originURI cookie without the SameSite attribute. Mendix generates this file. Direct changes to the file are not possible.

The originURI cookie does not contain sensitive information. It only indicates where to redirect the client when authentication is required. The cookie does not need additional restrictions. The finding does not represent a security risk for the application.

Solution / Workaround

Please note that, if the explanation in Cause section is accepted, no change is required. If the security policy requires the SameSite attribute on this cookie, use a custom copy of the sign-in script. 

This option adds a custom file to the project. Complete the following steps:

  1. Create a copy of the default sign-in script, for example custom_login.js. Place the copy in the theme/web folder of the project.
  2. In the copy, set the originURI cookie with SameSite=Strict.
  3. Place a customized login.html file in the theme/web folder.
  4. In the login.html file, replace the default script reference:

    <script src="js/login.js?{{cachebust}}"></script>

    with a reference to the custom script:

    <script src="custom_login.js?{{cachebust}}"></script>
  5. Redeploy the application.
  6. Open the sign-in page. Check the cookie in the developer tools of the browser.
  7. Test the sign-in flow, especially the redirect after sign-in. The redirect depends on this cookie.

Note: 

Mendix always copies the default login.js file from the application template to the deployment/web folder and deploys it. This also happens when login.html does not reference the file. This behavior is expected and does not affect the custom setup.

The custom script is part of the project. Maintain the script when the application template changes.

Internal information related

  • 292092
  • C3T260XGA/p1794568889876769

Additional information

Have more questions? Submit a request

0 Comments

Article is closed for comments.

To provide feedback, please open a ticket here. Don't forget to include the article's URL along with the feedback you would like to provide.