Trusted Microsoft Services Not Enabled
- Query id: e25b56cd-a4d6-498f-ab92-e6296a082097
- Query name: Trusted Microsoft Services Not Enabled
- Platform: AzureResourceManager
- Severity: Medium
- Category: Networking and Firewall
- CWE: 284
- Risk score: 5.2
- URL: Github
Description¶
Trusted Microsoft Services should be enabled for Storage Account access
Documentation
Code samples¶
Code samples with security vulnerabilities¶
Positive test num. 1 - bicep file
resource storage 'Microsoft.Storage/storageAccounts@2019-06-01' = {
name: 'storage'
location: 'location1'
sku: {
name: 'Standard_LRS'
tier: 'Standard'
}
kind: 'StorageV2'
properties: {
accessTier: 'Hot'
networkAcls: {
bypass: 'None'
virtualNetworkRules: [
{
id: 'id'
action: 'Allow'
}
{
id: 'id'
action: 'Allow'
}
]
defaultAction: 'Deny'
}
}
}
Positive test num. 2 - json file
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "2.0.0.0",
"apiProfile": "2019-03-01-hybrid",
"parameters": {},
"variables": {},
"functions": [],
"resources": [
{
"type": "Microsoft.Storage/storageAccounts",
"apiVersion": "2019-06-01",
"name": "storage",
"location": "location1",
"sku": {
"name": "Standard_LRS",
"tier": "Standard"
},
"kind": "StorageV2",
"properties": {
"accessTier": "Hot",
"networkAcls": {
"bypass": "None",
"virtualNetworkRules": [
{
"id": "id",
"action": "Allow"
},
{
"id": "id",
"action": "Allow"
}
],
"defaultAction": "Deny"
}
},
"resources": [
]
}
],
"outputs": {}
}
Positive test num. 3 - bicep file
resource storage 'Microsoft.Storage/storageAccounts@2019-06-01' = {
name: 'storage'
location: 'location1'
sku: {
name: 'Standard_LRS'
tier: 'Standard'
}
kind: 'StorageV2'
properties: {
accessTier: 'Hot'
networkAcls: {
bypass: 'None'
defaultAction: 'Deny'
}
}
}
Positive test num. 4 - json file
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "2.0.0.0",
"apiProfile": "2019-03-01-hybrid",
"parameters": {},
"variables": {},
"functions": [],
"resources": [
{
"type": "Microsoft.Storage/storageAccounts",
"apiVersion": "2019-06-01",
"name": "storage",
"location": "location1",
"sku": {
"name": "Standard_LRS",
"tier": "Standard"
},
"kind": "StorageV2",
"properties": {
"accessTier": "Hot",
"networkAcls": {
"bypass": "None",
"defaultAction": "Deny"
}
},
"resources": [
]
}
],
"outputs": {}
}
Positive test num. 5 - bicep file
resource storage 'Microsoft.Storage/storageAccounts@2019-06-01' = {
name: 'storage'
location: 'location1'
sku: {
name: 'Standard_LRS'
tier: 'Standard'
}
kind: 'StorageV2'
properties: {
accessTier: 'Hot'
networkAcls: {
bypass: 'None'
virtualNetworkRules: [
{
id: 'id'
action: 'Allow'
}
{
id: 'id'
action: 'Allow'
}
]
defaultAction: 'Deny'
}
}
}
Positive test num. 6 - json file
{
"properties": {
"template": {
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "2.0.0.0",
"apiProfile": "2019-03-01-hybrid",
"parameters": {},
"variables": {},
"functions": [],
"resources": [
{
"type": "Microsoft.Storage/storageAccounts",
"apiVersion": "2019-06-01",
"name": "storage",
"location": "location1",
"sku": {
"name": "Standard_LRS",
"tier": "Standard"
},
"kind": "StorageV2",
"properties": {
"accessTier": "Hot",
"networkAcls": {
"bypass": "None",
"virtualNetworkRules": [
{
"id": "id",
"action": "Allow"
},
{
"id": "id",
"action": "Allow"
}
],
"defaultAction": "Deny"
}
},
"resources": [
]
}
],
"outputs": {}
},
"parameters": {}
},
"kind": "template",
"type": "Microsoft.Blueprint/blueprints/artifacts",
"name": "myTemplate"
}
Positive test num. 7 - bicep file
Positive test num. 8 - json file
{
"properties": {
"template": {
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "2.0.0.0",
"apiProfile": "2019-03-01-hybrid",
"parameters": {},
"variables": {},
"functions": [],
"resources": [
{
"type": "Microsoft.Storage/storageAccounts",
"apiVersion": "2019-06-01",
"name": "storage",
"location": "location1",
"sku": {
"name": "Standard_LRS",
"tier": "Standard"
},
"kind": "StorageV2",
"properties": {
"accessTier": "Hot",
"networkAcls": {
"bypass": "None",
"defaultAction": "Deny"
}
},
"resources": [
]
}
],
"outputs": {}
},
"parameters": {}
},
"kind": "template",
"type": "Microsoft.Blueprint/blueprints/artifacts",
"name": "myTemplate"
}
Positive test num. 9 - bicep file
Positive test num. 10 - json file
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
},
"variables": {},
"resources": [
{
"type": "Microsoft.Storage/storageAccounts",
"name": "positive5",
"apiVersion": "2019-06-01",
"location": "[parameters('location')]",
"sku": {
"name": "Standard_LRS"
},
"kind": "Storage",
"properties": {}
}
]
}
Positive test num. 11 - bicep file
Positive test num. 12 - json file
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"keyVaultName": {
"type": "string",
"defaultValue": "[concat('kv-', uniqueString(resourceGroup().id))]",
"metadata": {
"description": "Specifies the name of the key vault."
}
}
},
"variables": {
"uniqueString": "[uniqueString(subscription().id, resourceGroup().id)]",
"diagnosticStorageAccountName": "[toLower( substring( replace( concat( parameters('keyVaultName'), variables('uniqueString'), variables('uniqueString') ), '-', ''), 0, 23) )]"
},
"resources": [
{
"type": "Microsoft.Storage/storageAccounts",
"name": "positive6",
"apiVersion": "2019-06-01",
"location": "[parameters('location')]",
"sku": {
"name": "Standard_LRS"
},
"kind": "StorageV2",
"tags": {
"displayName": "concat('Key Vault ', parameters('keyVaultName'), ' diagnostics storage account')"
}
}
]
}
Positive test num. 13 - bicep file
Positive test num. 14 - json file
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
},
"variables": {},
"resources": [
{
"type": "Microsoft.Storage/storageAccounts",
"name": "positive7",
"apiVersion": "2019-06-01",
"location": "[parameters('location')]",
"sku": {
"name": "Standard_LRS"
},
"kind": "Storage",
"properties": {
"networkAcls": {}
}
}
]
}
Code samples without security vulnerabilities¶
Negative test num. 1 - bicep file
resource storage 'Microsoft.Storage/storageAccounts@2019-06-01' = {
name: 'storage'
location: 'location1'
sku: {
name: 'Standard_LRS'
tier: 'Standard'
}
kind: 'StorageV2'
properties: {
accessTier: 'Hot'
networkAcls: {
virtualNetworkRules: [
{
id: 'id'
action: 'Allow'
}
{
id: 'id'
action: 'Allow'
}
]
defaultAction: 'Allow'
}
}
}
Negative test num. 2 - json file
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "2.0.0.0",
"apiProfile": "2019-03-01-hybrid",
"parameters": {},
"variables": {},
"functions": [],
"resources": [
{
"type": "Microsoft.Storage/storageAccounts",
"apiVersion": "2019-06-01",
"name": "storage",
"location": "location1",
"sku": {
"name": "Standard_LRS",
"tier": "Standard"
},
"kind": "StorageV2",
"properties": {
"accessTier": "Hot",
"networkAcls": {
"virtualNetworkRules": [
{
"id": "id",
"action": "Allow"
},
{
"id": "id",
"action": "Allow"
}
],
"defaultAction": "Allow"
}
},
"resources": [
]
}
],
"outputs": {}
}
Negative test num. 3 - bicep file
resource storage 'Microsoft.Storage/storageAccounts@2019-06-01' = {
name: 'storage'
location: 'location1'
sku: {
name: 'Standard_LRS'
tier: 'Standard'
}
kind: 'StorageV2'
properties: {
accessTier: 'Hot'
networkAcls: {
bypass: 'AzureServices'
virtualNetworkRules: [
{
id: 'id'
action: 'Allow'
}
{
id: 'id'
action: 'Allow'
}
]
defaultAction: 'Deny'
}
}
}
Negative test num. 4 - json file
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "2.0.0.0",
"apiProfile": "2019-03-01-hybrid",
"parameters": {},
"variables": {},
"functions": [],
"resources": [
{
"type": "Microsoft.Storage/storageAccounts",
"apiVersion": "2019-06-01",
"name": "storage",
"location": "location1",
"sku": {
"name": "Standard_LRS",
"tier": "Standard"
},
"kind": "StorageV2",
"properties": {
"accessTier": "Hot",
"networkAcls": {
"bypass": "AzureServices",
"virtualNetworkRules": [
{
"id": "id",
"action": "Allow"
},
{
"id": "id",
"action": "Allow"
}
],
"defaultAction": "Deny"
}
},
"resources": [
]
}
],
"outputs": {}
}
Negative test num. 5 - bicep file
resource storage 'Microsoft.Storage/storageAccounts@2019-06-01' = {
name: 'storage'
location: 'location1'
sku: {
name: 'Standard_LRS'
tier: 'Standard'
}
kind: 'StorageV2'
properties: {
accessTier: 'Hot'
networkAcls: {
virtualNetworkRules: [
{
id: 'id'
action: 'Allow'
}
{
id: 'id'
action: 'Allow'
}
]
defaultAction: 'Allow'
}
}
}
Negative test num. 6 - json file
{
"properties": {
"template": {
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "2.0.0.0",
"apiProfile": "2019-03-01-hybrid",
"parameters": {},
"variables": {},
"functions": [],
"resources": [
{
"type": "Microsoft.Storage/storageAccounts",
"apiVersion": "2019-06-01",
"name": "storage",
"location": "location1",
"sku": {
"name": "Standard_LRS",
"tier": "Standard"
},
"kind": "StorageV2",
"properties": {
"accessTier": "Hot",
"networkAcls": {
"virtualNetworkRules": [
{
"id": "id",
"action": "Allow"
},
{
"id": "id",
"action": "Allow"
}
],
"defaultAction": "Allow"
}
},
"resources": [
]
}
],
"outputs": {}
},
"parameters": {}
},
"kind": "template",
"type": "Microsoft.Blueprint/blueprints/artifacts",
"name": "myTemplate"
}
Negative test num. 7 - bicep file
resource storage 'Microsoft.Storage/storageAccounts@2019-06-01' = {
name: 'storage'
location: 'location1'
sku: {
name: 'Standard_LRS'
tier: 'Standard'
}
kind: 'StorageV2'
properties: {
accessTier: 'Hot'
networkAcls: {
bypass: 'AzureServices'
virtualNetworkRules: [
{
id: 'id'
action: 'Allow'
}
{
id: 'id'
action: 'Allow'
}
]
defaultAction: 'Deny'
}
}
}
Negative test num. 8 - json file
{
"properties": {
"template": {
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "2.0.0.0",
"apiProfile": "2019-03-01-hybrid",
"parameters": {},
"variables": {},
"functions": [],
"resources": [
{
"type": "Microsoft.Storage/storageAccounts",
"apiVersion": "2019-06-01",
"name": "storage",
"location": "location1",
"sku": {
"name": "Standard_LRS",
"tier": "Standard"
},
"kind": "StorageV2",
"properties": {
"accessTier": "Hot",
"networkAcls": {
"bypass": "AzureServices",
"virtualNetworkRules": [
{
"id": "id",
"action": "Allow"
},
{
"id": "id",
"action": "Allow"
}
],
"defaultAction": "Deny"
}
},
"resources": [
]
}
],
"outputs": {}
},
"parameters": {}
},
"kind": "template",
"type": "Microsoft.Blueprint/blueprints/artifacts",
"name": "myTemplate"
}
Negative test num. 9 - bicep file
resource storage 'Microsoft.Storage/storageAccounts@2019-06-01' = {
name: 'storage'
location: 'location1'
sku: {
name: 'Standard_LRS'
tier: 'Standard'
}
kind: 'StorageV2'
properties: {
accessTier: 'Hot'
networkAcls: {
bypass: 'AzureServices'
virtualNetworkRules: [
{
id: 'id'
action: 'Allow'
}
{
id: 'id'
action: 'Allow'
}
]
defaultAction: 'Allow'
}
}
}
Negative test num. 10 - json file
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"metadata": {
"_generator": {
"name": "bicep",
"version": "0.37.4.10188",
"templateHash": "12561968956268065716"
}
},
"resources": [
{
"type": "Microsoft.Storage/storageAccounts",
"apiVersion": "2019-06-01",
"name": "storage",
"location": "location1",
"sku": {
"name": "Standard_LRS",
"tier": "Standard"
},
"kind": "StorageV2",
"properties": {
"accessTier": "Hot",
"networkAcls": {
"bypass": "AzureServices",
"virtualNetworkRules": [
{
"id": "id",
"action": "Allow"
},
{
"id": "id",
"action": "Allow"
}
],
"defaultAction": "Allow"
}
}
}
]
}
Negative test num. 11 - bicep file
Negative test num. 12 - json file
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"metadata": {
"_generator": {
"name": "bicep",
"version": "0.37.4.10188",
"templateHash": "6409916551620575316"
}
},
"resources": [
{
"type": "Microsoft.Storage/storageAccounts",
"apiVersion": "2019-06-01",
"name": "storage",
"location": "location1",
"sku": {
"name": "Standard_LRS",
"tier": "Standard"
},
"kind": "StorageV2",
"properties": {
"accessTier": "Hot",
"networkAcls": {
"defaultAction": "Deny"
}
}
}
]
}