secureString parameter has a hardcoded default

Remove secret defaults from secureString parameters and supply values through a protected deployment path.

Description

ARM secureString and Bicep @secure() hide parameter values from deployment history. A password or key used as a default is still readable in the template and its source history.

Potential impact

Anyone with access to that history might obtain the secret, including one reused in another environment.

Remediation

Remove the default and supply the value at deployment through a Key Vault reference or protected pipeline variable. Limit deployment and secret-reading permissions and keep the value out of logs and outputs. Rotate any exposed secret, update its consumers and invalidate the old value.

Examples

The second example removes the default from adminPassword. Supply the SQL server name, administrator account and a password meeting the service’s complexity requirements. Configure networking and access permissions separately.

Before

bicep
@secure()
param adminPassword string = 'HardcodedPassword1!'
param adminLogin string
param sqlServerName string

resource sqlServer 'Microsoft.Sql/servers@2015-05-01-preview' = {
  name: sqlServerName
  location: resourceGroup().location
  tags: {}
  properties: {
    administratorLogin: adminLogin
    administratorLoginPassword: adminPassword
    version: '12.0'
  }
}

After

bicep
@secure()
param adminPassword string
param adminLogin string
param sqlServerName string

resource sqlServer 'Microsoft.Sql/servers@2015-05-01-preview' = {
  name: sqlServerName
  location: resourceGroup().location
  tags: {}
  properties: {
    administratorLogin: adminLogin
    administratorLoginPassword: adminPassword
    version: '12.0'
  }
}

References