| reviewed | 2022-11-16 |
|---|---|
| severity | Important |
| pillar | Security |
| category | SE:02 Secured development lifecycle |
| resource | Virtual Machine Scale Sets |
| resourceType | Microsoft.Compute/virtualMachineScaleSets,Microsoft.Compute/virtualMachineScaleSets/extensions |
| online version | https://azure.github.io/PSRule.Rules.Azure/en/rules/Azure.VMSS.ScriptExtensions/ |
Custom Script Extensions scripts that reference secret values must use the protectedSettings.
Virtual Machines Scale Sets support the ability to execute custom scripts on launch. This can be configured via user data and custom script extensions. When the template is rendered, anything in the settings section will be rendered in clear text. To ensure they're kept secret, use the protectedSettings section instead.
Consider specifying secure values within properties.extensionProfile.extensions.protectedSettings to avoid exposing
secrets during extension deployments.
To deploy VMSS extensions that pass this rule:
- Set any secure values within
properties.extensionProfile.extensions.protectedSettings
"extensionProfile": {
"extensions": [
{
"name": "customScript",
"properties": {
"publisher": "Microsoft.Compute",
"protectedSettings": {
"commandToExecute": "Write-Output 'example'"
},
"typeHandlerVersion": "1.8",
"autoUpgradeMinorVersion": true,
"type": "CustomScriptExtension"
}
}
]
}To deploy VMSS extensions that pass this rule:
- Set any secure values within
properties.extensionProfile.extensions.protectedSettings
extensionProfile: {
extensions: [
{
name: 'customScript'
properties: {
publisher: 'Microsoft.Compute'
protectedSettings: {
commandToExecute: 'Write-Output "example"'
},
typeHandlerVersion: '1.8'
autoUpgradeMinorVersion: true
type: 'CustomScriptExtension'
}
}
]
}