AZ-400 ยท Secrets and sensitive information
Secure files and preventing secret leakage
Azure Pipelines secure files, secret masking and its limits, avoiding secrets in logs, scripts and forks, pull_request_target risks, script injection, restricting secret access to protected branches and environments.
Key points
- Secure files: certificates, keystores, SSH keys encrypted on the server (10 MB each); YAML pipeline must be authorized, fetch with DownloadSecureFile@1.
- Log masking matches exact values only: register derived values, store secrets separately, never echo them.
- Pass untrusted input via environment variables, not into scripts.
- Keep secrets from fork code; no PR checkout under pull_request_target; gate with protected branches or environments.
Source: https://learn.microsoft.com/en-us/azure/devops/pipelines/library/secure-files
Practice questions
What is the size limit for a single Azure Pipelines secure file?
- 1 MB
- 10 MB
- 100 MB
- 1 GB
Show answer
Answer: B. 10 MB
Each secure file can be at most 10 MB. Larger artifacts belong in other storage, with only a small key or certificate kept as a secure file.
Which practices reduce script injection from untrusted values such as a pull request title in GitHub Actions?
- Pass the value through an intermediate environment variable and quote it in the script
- Interpolate the expression directly inside the run command
- Pass the value as an argument to a JavaScript action
- Limit titles to 50 characters in the repository settings
- Rely on log masking to stop the injection
Show answer
Answer: A. Pass the value through an intermediate environment variable and quote it in the script, C. Pass the value as an argument to a JavaScript action
Assign the value to an intermediate environment variable and quote it in the shell, or hand it to a JavaScript action as an argument. Interpolating the expression directly into run lets crafted text become shell code, and making the title shorter or hidden is not a control.
True or false: because pipeline logs mask secret values, a secret can never appear in a log.
Show answer
Answer: False
False. Masking depends on finding the exact value, so encoded, split or transformed versions can leak, and both GitHub and Azure Pipelines say redaction is not foolproof. If a secret reaches a log, delete the log and rotate the secret.
Practice 8 questions on this topic in Bitzu
Short lessons, instant explanations and spaced review of what you get wrong. Free on iOS and Android.
