AZ-400 Exam QuestionsBrowse all questions from this exam

AZ-400 Exam - Question 161


You use release pipelines in Azure Pipelines to deploy an app. Secrets required be the pipeline are stored as pipeline variables. Logging of commands is enabled for the Azure Pipelines agent.

You need to prevent the values of the secrets from being logged.

What should you do?

Show Answer
Correct Answer: A

To prevent secrets from being logged in Azure Pipelines when logging of commands is enabled, you should store the secrets in environment variables instead of pipeline variables. This approach reduces the risk of the secrets appearing in the logs, as environment variables are typically not logged by default. Passing secrets on the command line or echoing them to the command line would not be secure, and simply adding a prefix to their names does not ensure their protection.

Discussion

9 comments
Sign in to comment
markpOption: A
Sep 15, 2022

A is correct. But provided link and explanation are not totally correct. The question is about Classis Release (not YAML), so the correct explanation is from here: https://docs.microsoft.com/en-us/azure/devops/pipelines/process/variables?view=azure-devops&tabs=classic%2Cbatch We make an effort to mask secrets from appearing in Azure Pipelines output, but you still need to take precautions. Never echo secrets as output. Some operating systems log command line arguments. Never pass secrets on the command line. Instead, we suggest that you map your secrets into environment variables.

zellckOption: A
Jun 3, 2023

A is the answer. https://learn.microsoft.com/en-us/azure/devops/pipelines/process/set-secret-variables?view=azure-devops&tabs=yaml%2Cbash#secret-variable-in-the-ui We make an effort to mask secrets from appearing in Azure Pipelines output, but you still need to take precautions. Never echo secrets as output. Some operating systems log command line arguments. Never pass secrets on the command line. Instead, we suggest that you map your secrets into environment variables. You'll need to map secret variable as environment variables to reference them in YAML pipelines.

xRiot007
Jul 17, 2023

An even better approach would be to get them from a key vault. Your machine could be compromised and then those environment variables are secrets no more.

Fal991lOption: C
Mar 31, 2023

Option A, storing secrets in environment variables instead of pipeline variables, is a valid approach to prevent secrets from being logged during pipeline execution. However, it is not the most optimal solution for this scenario.

Fal991l
Mar 31, 2023

While environment variables are not logged by default, they can be accidentally exposed through logs or other sources, and their values can be visible in the running process of the task. Additionally, environment variables are typically accessible to all tasks running in the pipeline, which could potentially increase the attack surface if an attacker gains access to the pipeline. By applying a prefix of "secret" to the name of the pipeline variables, as suggested in option C, the variables are automatically marked as secret variables in Azure Pipelines, and their values are not logged by default during pipeline execution. This provides a more secure approach to handling secrets in pipelines and reduces the risk of accidental exposure. Therefore, while option A is not necessarily incorrect, option C is a better solution for securing secrets in Azure Pipelines.

Aravindking
May 31, 2023

Bard AI response to the question -- Applying a prefix of secret to the name of the variables is not a secure way to protect secrets. This is because the Azure Pipelines agent logs all variables, regardless of their name. This means that the values of the secrets would be exposed in the logs, even if they are prefixed with the word "secret". hence option A is correct

garbas
Sep 18, 2023

https://learn.microsoft.com/en-us/azure/devops/pipelines/process/variables#variable-naming-restrictions "Don't use variable prefixes reserved by the system. These are: endpoint, input, secret, path, and securefile. Any variable that begins with one of these strings (regardless of capitalization) won't be available to your tasks and scripts."

syu31svcOption: A
Sep 1, 2022

Answer is supported by provided link

AravindkingOption: A
May 31, 2023

The correct answer is A. Bard AI explanation -- Storing secrets in the environment variables instead of the pipeline variables will prevent the values of the secrets from being logged. This is because environment variables are not logged by the Azure Pipelines agent. option C is not correct - The statement that by applying a prefix of "secret" to the name of the pipeline variables, the variables are automatically marked as secret variables in Azure Pipelines, and their values are not logged by default during pipeline execution is not true.

renzokuOption: A
Jul 19, 2023

A. Store the secrets in the environment variables instead of the pipeline variables. Environment variables are not shown in the build logs unless you explicitly log them as part of your pipeline script. Store secrets in pipeline variables, they can be easily accessed and potentially exposed in the logs, by default, pipeline variables are logged in plaintext in the build logs.

ozbonnyOption: A
Feb 22, 2024

A. Store the secrets in the environment variables instead of the pipeline variables.

4bd3116Option: C
Jun 3, 2024

By applying a prefix such as "secret" to the name of the variables, Azure Pipelines automatically redacts the values of these variables from being logged in the pipeline logs. This approach ensures that even if logging of commands is enabled for the Azure Pipelines agent, sensitive information such as secret values will not be exposed in the logs.

sieunhantanbao
Jul 16, 2024

This is incorrect. https://learn.microsoft.com/en-us/azure/devops/pipelines/process/variables?view=azure-devops&tabs=yaml%2Cbatch#variable-naming-restrictions User-defined and environment variables can consist of letters, numbers, ., and _ characters. Don't use variable prefixes reserved by the system. These are: endpoint, input, secret, path, and securefile. Any variable that begins with one of these strings (regardless of capitalization) won't be available to your tasks and scripts.

Miten94
Jun 23, 2024

Came in Exam June 23, 2024