Insecure definition of secret variable in pipeline
Rule Details
Cortex AppSec Rule ID
APPSEC_CICD_192
Category
Credential Hygiene
Severity
MEDIUM
Impact
The task.setvariable command is the least secure way to set secret variables in Azure Pipelines. This is because the secret is stored in plain text in the pipeline yaml file, which anyone with access to the pipeline can view. In addition, hard coded secrets can make it difficult to maintain your code. If you need to change a secret or to perform a periodic rotation, you will need to update it in all of the places where it is used. This can be a time-consuming and error-prone process.
Recommended Solution - Buildtime
Use OIDC instead of long term credentials as it is more secure, when the service you authenticate against supports it.
The recommended ways to set secret variables in Azure Pipelines are:
Set a pipeline secret variable. The secret is encrypted and stored in Azure Pipelines exclusively for the pipeline
Set a secret in a variable group. Variable groups are a way to group together related variables. Secret variables can be added to variable groups and then used in pipelines. This makes it easy to manage secret variables and to reuse them across multiple pipelines
Link secrets from an Azure key vault. Azure key vault is a service that provides secure storage for secrets. Secret variables can be added to Azure key vault and then used in pipelines
For more information refer to: https://learn.microsoft.com/en-us/azure/devops/pipelines/process/set-secret-variables?view=azure-devops&tabs=yaml%2Cbash.
Last updated
Was this helpful?
