bicep icon indicating copy to clipboard operation
bicep copied to clipboard

Add linter rule to verify deploymentScripts users aren't passing secure parameters to insecure properties

Open anthony-c-martin opened this issue 3 years ago • 1 comments

Similar in concept to the protect-commandtoexecute-secrets rule - we should teach users to use secure properties. Otherwise they risk exposing secrets in a way that can be read back from the deploymentScripts resource by anyone with */read permissions.

Example of unsafe behavior:

@secure()
param foo string

resource asdf 'Microsoft.Resources/deploymentScripts@2020-10-01' = {
  name: 'asdf'
  location: resourceGroup().location
  kind: 'AzurePowerShell'
  properties: {
    azPowerShellVersion: '3.0'
    retentionInterval: 'PT4H'
    // this should be flagged - the value of 'foo' can be accessed via a GET.
    arguments: '-foo ${foo}'
    scriptContent: loadTextContent('myScript.ps1')
  }
}

Desired approach - use secure env vars:

@secure()
param foo string

resource asdf 'Microsoft.Resources/deploymentScripts@2020-10-01' = {
  name: 'asdf'
  location: resourceGroup().location
  kind: 'AzurePowerShell'
  properties: {
    azPowerShellVersion: '3.0'
    retentionInterval: 'PT4H'
    scriptContent: loadTextContent('myScript.ps1')
    environmentVariables: [
      { name: 'foo', secureValue: foo }
    ]
  }
}

anthony-c-martin avatar Jan 31 '23 20:01 anthony-c-martin

Adding feature note from #7185 - other resource types that have first-class secure handling Microsoft.ContainerInstance/containerGroups - in particular.

torreymicrosoft avatar Jun 11 '26 22:06 torreymicrosoft