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

How to check in AngularJS if a service was register or not

There are cases when you need to check in a service or a controller was register in AngularJS.
For example a valid use case is when you have the same implementation running on multiple application. In this case, you may want to intercept the HTTP provider and add a custom step there. This step don’t needs to run on all the application, only in the one where the service exist and register.
A solution for this case would be to have a flag in the configuration that specify this. In the core you would have an IF that would check the value of this flag.
Another solution is to check if a specific service was register in AngularJS or not. If the service was register that you would execute your own logic.
To check if a service was register or not in AngularJS container you need to call the ‘has’ method of ‘inhector’. It will return TRUE if the service was register.
if ($injector.has('httpInterceptorService')) { $httpProvider.interceptors.push('httpInterceptorService&#…

ADO.NET provider with invariant name 'System.Data.SqlClient' could not be loaded

Today blog post will be started with the following error when running DB tests on the CI machine:
threw exception: System.InvalidOperationException: The Entity Framework provider type 'System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer' registered in the application config file for the ADO.NET provider with invariant name 'System.Data.SqlClient' could not be loaded. Make sure that the assembly-qualified name is used and that the assembly is available to the running application. See http://go.microsoft.com/fwlink/?LinkId=260882 for more information. at System.Data.Entity.Infrastructure.DependencyResolution.ProviderServicesFactory.GetInstance(String providerTypeName, String providerInvariantName) This error happened only on the Continuous Integration machine. On the devs machines, everything has fine. The classic problem – on my machine it’s working. The CI has the following configuration:

TeamCity.NET 4.51EF 6.0.2VS2013
It seems that there …

Fundamental Books of a Software Engineer (version 2018)

More then six years ago I wrote a blog post about fundamental books that any software engineer (developer) should read. Now it is an excellent time to update this list with new entries.

There are 5 different categories of books, that represent the recommended path. For example, you start with Coding books, after that, you read books about Programming, Design and so on.
There are some books about C++ that I recommend not because you shall know C++, only because the concepts that you can learn from it.

Coding

Writing solid codeCode completeProgramming Pearls, more programming pearls(recommended)[NEW] Introduction to Algorithms

Programming

Refactoring (M. Fowler)Pragmatic ProgrammerClean code[NEW] Software Engineering: A Practitioner's Approach[NEW] The Mythical Man-Month[NEW] The Art of Computer Programming

Design

Applying UML and Patterns (GRASP patterns)C++ coding standards (Sutter, Alexandrescu)The C++ programming language (Stroustrup, Part IV)Object-oriented programming (Peter Coad)P…