Skip to main content
InterviewHubPRO
Section Overview
Q38

Question 38 of 50

Part 3: Enterprise Scale, Compliance & Production Hardening (Senior / Staff)

76%
CI/CD & GitHub Actions (50 Qs)•Part 3: Enterprise Scale, Compliance & Production Hardening (Senior / Staff)

Secrets Masking and Redaction: How GitHub Actions protects sensitive data in logs and how to avoid accidental leaks.

senior LevelCode ExampleState ManagementCI/CD & DevOps

In Simple Words: GitHub Actions automatically masks any value registered as a secret in repository settings or set via ::add-mask:: by replacing occurrences with *** in execution logs.

bash
# Registering a dynamic secret generated in a step
echo "::add-mask::$TEMP_TOKEN"
echo "TEMP_TOKEN=$TEMP_TOKEN" >> "$GITHUB_ENV"

Common Leak Vectors & Mitigations:

  1. Encoded Secrets: Base64 or URL-encoded secrets are not masked by default. Always register both raw and encoded representations if logs might print them.
  2. Command Tracing: Avoid set -x in bash scripts when secrets are exported as environment variables.
  3. Structured Formats: Dumping complete JSON payloads with jq or print_r can reveal secret subkeys. Use explicit parsing instead of object dumps.