Skip to main content

Using SQL security features to isolate sensitive data inside a PoC

When writing a PoC you need to keep it as simple as possible and prove that from a technology perspective the project vision is feasible and is the right one. One of the fundamentals rules of a PoC is that it needs to cover things that are not general truth (e.g. You don’t want to prove that ASP.NET MVC can render HTML or expose an REST API).
Keeping a PoC as simple as possible can become a problem when you want to use customer data not only mocks data. When you have customer sensitive information, which should not be visible even to the development team you might end up in a strange situation.
The problem is not related on how you can do this. The biggest problem is the effort that you need to invest to create the deployment scripts or the automation mechanism that would allow the customer to deploy the solution in an isolated environment, where development team would not have access. This effort might require extra development effort that you don’t want to include in a PoC.
It is clear on how we can achieve this using a classical approach. We would need to separate environments for DEV and PoCWithRealData. We need to use a separate environment, deployed on a different infrastructure where development team don’t have access to it. Nothing special, but with a little more complexity level from deployment perspective. For PoC you might not want to create deployment scripts and other things like this, especially when things are not too complicated.

Let us take a look on how we can use Azure SQL (also applies for SQL Server) features to make our life more simple. In this context, we are starting from the assumption that all client confidential information are stored inside Azure SQL.
What if we would be able to allow development team to access only mock data from Azure SQL, without having access to the rest of the data? It is as creating a custom view for the development team that can be used to fetch only mock data, without being able to see or access other information.
This can be achieved using row-level security feature that is offered by Azure SQL. These features allow us to control and restrict user access to data from SQL tables based on their roles, enabling us to have a full control on what data can be accessed by each user.
Things that we need to do:
  • Create a user that has access to entire database and it is be used by customer to populate the database
  • Create the SQL script that populated storage with mock data
  • Grant access to development users/roles to have access to mock data by creating the right security policy
  • Create the migration script that would allow us to migrate confident data to storage
  • Migrate the client confident data
  • Test and validate with both users/roles
  • Share the access rights for mock data with the development team

In this moment, we have only one environments that can be used by both sides without any problems. The development team has access only to their mock data and it is impossible for them to access the real data as long as they use only their access rights.

To make things a little simpler, we can use the user information that are used to access the Web Application also to access the SQL instance. This would enable us to assign to our customer users a specific role in Azure AD that enable access to confidential data. Without this role, users can see only mock data.
An important thing that we need to keep in mind is how we can know that a row is mock data or customer confidential data. This can be achieved in two ways. The first option is to add an extra column that specify if data is real data or to have a specific range of values in the row ID for example that are reserved for mocks data.
In both cases, you need to ensure that the user/role that will be used by the development team has only reads data (SELECT). For extra rights, you need to use stored procedure or other mechanism to ensure that they will not alter confidential data.

Conclusion
This is only one way how we can simplify a PoC. Of course, the solution is not perfect. The biggest risk is from development team to get the admin access rights or to start to write inside the logs confidential data. Of course, both of these risks can be mitigate and kept under control. 

Comments

Popular posts from this blog

Windows Docker Containers can make WIN32 API calls, use COM and ASP.NET WebForms

After the last post , I received two interesting questions related to Docker and Windows. People were interested if we do Win32 API calls from a Docker container and if there is support for COM. WIN32 Support To test calls to WIN32 API, let’s try to populate SYSTEM_INFO class. [StructLayout(LayoutKind.Sequential)] public struct SYSTEM_INFO { public uint dwOemId; public uint dwPageSize; public uint lpMinimumApplicationAddress; public uint lpMaximumApplicationAddress; public uint dwActiveProcessorMask; public uint dwNumberOfProcessors; public uint dwProcessorType; public uint dwAllocationGranularity; public uint dwProcessorLevel; public uint dwProcessorRevision; } ... [DllImport("kernel32")] static extern void GetSystemInfo(ref SYSTEM_INFO pSI); ... SYSTEM_INFO pSI = new SYSTEM_INFO(...

How to audit an Azure Cosmos DB

In this post, we will talk about how we can audit an Azure Cosmos DB database. Before jumping into the problem let us define the business requirement: As an Administrator I want to be able to audit all changes that were done to specific collection inside my Azure Cosmos DB. The requirement is simple, but can be a little tricky to implement fully. First of all when you are using Azure Cosmos DB or any other storage solution there are 99% odds that you’ll have more than one system that writes data to it. This means that you have or not have control on the systems that are doing any create/update/delete operations. Solution 1: Diagnostic Logs Cosmos DB allows us activate diagnostics logs and stream the output a storage account for achieving to other systems like Event Hub or Log Analytics. This would allow us to have information related to who, when, what, response code and how the access operation to our Cosmos DB was done. Beside this there is a field that specifies what was th...

Cloud Myths: Cloud is Cheaper (Pill 1 of 5 / Cloud Pills)

Cloud Myths: Cloud is Cheaper (Pill 1 of 5 / Cloud Pills) The idea that moving to the cloud reduces the costs is a common misconception. The cloud infrastructure provides flexibility, scalability, and better CAPEX, but it does not guarantee lower costs without proper optimisation and management of the cloud services and infrastructure. Idle and unused resources, overprovisioning, oversize databases, and unnecessary data transfer can increase running costs. The regional pricing mode, multi-cloud complexity, and cost variety add extra complexity to the cost function. Cloud adoption without a cost governance strategy can result in unexpected expenses. Improper usage, combined with a pay-as-you-go model, can result in a nightmare for business stakeholders who cannot track and manage the monthly costs. Cloud-native services such as AI services, managed databases, and analytics platforms are powerful, provide out-of-the-shelve capabilities, and increase business agility and innovation. H...