Sharing ASP.NET_SessionId and .ASPXAUTH cookie security risk

We're developing a SAAS solution for a big company in which doctors can view patients and make mutations, order products, provide licenses. This project is for 4 separate companies under one umbrella company. For each company we developed a portal. All portals use the same code but have a strict separated database because the database contains all the patient information. We're using Sitecore as CMS.

The client decided to use virtual folders instead of subdomains for the production environment. Our staging evironment url is for example: For the production environment they would like a URL such as: One SSL certificate is being used for all portals and requests.

We're using Membership Provider (forms authentication) for the authentication of users. Users can not log in with the same account in for example portal1 and portal3 because of the usage of separated databases. Because we're using formsauthentication the ".ASPXAUTH" cookie is being used. Of course the "ASP.NET_SessionId" cookie is used also.

Because the client wants to use virtual folders instead of subdomains, the cookies are shared over all portals. It is possible to set the "path" on the node in web.config but this path is dynamically read by Sitecore and resolved in a pipeline. I did not find a way to override this path after it is being loaded in the web.config. Also I did not find a way to alter the ASP.NET_SessionId cookie path.

My question is: is it a (security) risk to share these cookies over multiple portals (remember, they should be separated completely)? Are there any other problems this setup could cause?

Hope somebody can help!


Yes, there is a huge security risk. What you do is called a multitenant application. You have to take special steps to ensure that cookies and other sensitive data cannot be shared.

My advice would be to store the tenant name (portal1) in the custom data section of the forms authentication cookie. You set the custom data when you issue the forms cookie.

Then, have a custom module or just a handler of the Application_AuthorizeRequest event, where the identity is already established based on the cookie.

In your handler, you decrypt the forms authentication ticket from the cookie, retrieve the user data and compare to the actual url. If there is a match - nothing happens. If there is no match, it means that user is authenticated in one portal but tries to access another. You can gently clear the response and render a message "well, this portal is not meant for you" or just log the user out.

Need Your Help

Where can I find the QWebPage and pymongo in python3.4?

python qt python-3.x pyqt pyqt5

I'm working on some code that requires a number of packages from python qt 5. I get a missing package error upon importing the QWebPage module:

SQL Average of fields based on conditions

mysql sql database relational-database reporting

I am creating a reporting tool and it has a specific requirement I would like to solve in the SQL world. I am using MySQL 5.6.11: