
Security News
Vite Releases Technical Preview of Rolldown-Vite, a Rust-Based Bundler
Vite releases Rolldown-Vite, a Rust-based bundler preview offering faster builds and lower memory usage as a drop-in replacement for Vite.
github.com/microsoft/azure-sql-security-sample
Sample application with database that showcases security features of Azure SQL DB (V12).
The following table is an estimation of the cost of deploying the Demo as of 5/9/2016.
Resource | Cost/Month | Cost/Hr |
---|---|---|
S1 SQL Database | $30 | $0.04 |
B1 App Service Plan | $55.80 | $0.075 |
Storage Plan | ~$0 | $0.0036/transaction |
Azure Key Vault | ~$0 | $0.03/10k operations |
Monthly Total | $85.80/mo | ~$0.115/hr |
In order to allow your client application to access and use the keys in your Azure Key Vault, we need to provision an application in Azure Active Directory. This will create a Client ID and Secret that your app will use to authenticate to the Azure Key Vault. To do this, head to the Classic Azure Portal and log in.
Select “Active Directory” in the left sidebar, choose the Active Directory you wish to use (or create a new one if it doesn’t exist), then click “Applications”. If you choose a directory other than your default, you will need to refer to the steps to change the directory associated with your account, which can be found here.
Add a new application by filling out the modal window that appears.
Enter a name, select “Web Application” as the type, and enter any URL for the Sign-On URL and App ID URI. These must include “http://”, but do not need to be real pages for the purposes of this demo.
Go to the “Configure” tab and generate a new client key (also called a “secret”) by selecting a duration from the dropdown, then saving the configuration. Copy the client ID and secret out to a text file, as they will be used in deployment and in enabling the Always Encrypted functionality.
In order to deploy an Azure Key Vault for use with the Always Encrypted functionality of the demo, you will need to provide your tenantID during the deployment process. This can be copied from Powershell in the response to the Login-AzureRmAccount
command. After the deployment step, this information is not saved by the application.
In order to create access permissions to the Azure Key Vault during deployment, you will need to collect both your user ObjectID and the Application ObjectID.
Login-AzureRmAccount
, and copy down the TenantID returned.Get-AzureRMAduser -UserPrincipalName <AccountName>
and copy the ObjectID returned. This is your UserObjectID.Get-AzureRmADServicePrincipal -ServicePrincipalName <ClientID from AAD application step>
and copy the ObjectID returned. This is your ApplicationObjectId.Click the Deploy to Azure Button and fill out the fields to deploy the demo to your Azure Subscription.
Note on Passwords: Please use only characters and numbers [a-z A-Z 0-9]. Because of certain implementation decisions made in development of this demo, other characters may cause deployment issues.
' ORDER BY SSN --
Threat Detection is designed to detect suspicious database activity- which may indicate malicious access, a breach, or an exploit attempt on the Database. This is designed around machine learning algorithms that look for anomalous database activities over historical data and normal behavior of databases. Because SQL injection is a leading exploit vector for unauthorized access to data, it is flagged by Threat Detection as abnormal behavior.
Get-AzureRmKeyVault -ResourceGroupName <yourResourceGroupName>
within powershell would be an option to ensure you choose the correct key vault.SELECT SSN, BirthDate FROM dbo.Patients
or SELECT * FROM dbo.Patients
)
During the pre-deployment steps, you collected information which enabled the deployment to create an Azure Key Vault and the required permissions for both you (the user) and the Application Active Directory registration we created. During those steps, the Azure Active Directory registration for the application was necessary to enable key vault connectivity, because the application needs access to the key to enable the driver to transparently handle the decryption of the columns we encrypted.
During the creation, we gave the user create, list, wrapKey, unwrapKey, sign, verify
permissions in order to facilitate your Key Vault management; the application needs get, wrapKey, unwrapKey, sign, verify
. As a best practice, you should always follow the principle of least privelege. For documentation on Key Vault Permissions, see About Keys and Secrets.
This is the equivalent of creating a key vault and permissions via Powershell- see the section/cmdlets under "Create and Configure a key vault".
Our connection string for our application contains Column Encryption Setting=Enabled
which allows the driver to handle the necessary overhead to decrypt the newly encrypted data without code changes. Ordinarily, you would need to change the connection string- but in this demo, we preemptively included this within the connection string with the intent that you enable this functionality. Don't forget this for your app if you intend to use Always Encrypted functonality.
We had to prepare our application to authenticate against our Key Vault- this code is discussed in more detail in this Blog Post. The code changes referenced there are in our file Startup.cs, which can be found here.
Sign in using (Rachel@contoso.com/Password!1) or (alice@contoso.com/Password!1)
Specifically, we used a DbConnectionInterceptor
. The Opened()
function is called whenever Entity Framework opens a connection and we set SESSION_CONTEXT with the current application UserId
there.
The predicate functions we created in Enable-RLS.sql identify users by the UserId
which was set by our interceptor whenever a connection is established from the application. The two types of predicates we created were Filter and Block.
SELECT
, UPDATE
, and DELETE
operations to exclude rows that do not satisfy the predicate.INSERT
, UPDATE
, and DELETE
operations that do not satisfy the predicate.Dynamic data masking limits sensitive data exposure by masking the data according to policies defined on the database level while the data in the database remains unchanged; this is based on the database user's permissions. Those with the UNMASK
permission will
have the ability to see the data without masks. In our case, the application's database login did not have the UNMASK
permission and saw the data as masked. For your administrator login, the data was visible, as the user had the UNMASK
permission. For more information on Dynamic Data Masking, see the documentation.
The code included in this sample is only intended to provide a simple demo platform for users to enable and gain experience with Azure SQL Database (V12) security features; the demo web app is not intended to hold sensitive data and should not be used as a reference for applications that use or store sensitive data.Please take adequate steps to securely develop your application and store your data.
FAQs
Unknown package
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Vite releases Rolldown-Vite, a Rust-based bundler preview offering faster builds and lower memory usage as a drop-in replacement for Vite.
Research
Security News
A malicious npm typosquat uses remote commands to silently delete entire project directories after a single mistyped install.
Research
Security News
Malicious PyPI package semantic-types steals Solana private keys via transitive dependency installs using monkey patching and blockchain exfiltration.