Skip to content

Prevent ACR refresh token exposure in EXECVE audit logs#4675

Open
ehvs wants to merge 1 commit intomasterfrom
ehvs/ARO-24815
Open

Prevent ACR refresh token exposure in EXECVE audit logs#4675
ehvs wants to merge 1 commit intomasterfrom
ehvs/ARO-24815

Conversation

@ehvs
Copy link
Collaborator

@ehvs ehvs commented Mar 10, 2026

Which issue this PR addresses:

Replace az acr login --name with az acr login --expose-token + podman login --password-stdin in pull_container_images() to prevent the ACR refresh token from appearing as a command-line argument in auditd EXECVE records.

https://issues.redhat.com/browse/ARO-24815

why we need it:

During RP/Gateway VMSS bootstrap, pull_container_images() calls az acr login --name $registry. The Azure CLI internally spawns a docker login --password $token subprocess, which exposes the ACR refresh token as a plaintext command-line argument. This is captured by auditd EXECVE syscall logging.

podman --password-stdin should be used rather than az acr log to prevent the secret variable from being shown in shell output.

What is PR does

Tip

Files that directly fix ARO-24815 are (to assist reviewing changes):

  1. pkg/deploy/generator/scripts/rpVMSS.sh
  2. pkg/deploy/generator/scripts/util-common.sh
  1. Unsets xtrace shell option while working with sensitive information. Variables containing sensitive information are written to output when xtrace is set.
    • While logging into Azure acr via podman
    • While updating system TLS certificates
  2. Addresses shellcheck warnings
    • The warnings that can be safely disregarded have been disabled
    • Some warnings were valid, that code has been refactored

General improvements to improve readability

  1. All function and variable descriptions have been refactored to have a uniform style.
  2. Command/function calls with more than three options have been broken up into multiple lines.

Test plan for issue:

Deploying to INT to

  • Ensure the problem is resolved
  • Ensure no new errors/failures were introduced

Successfully deployed in pipelines:

  1. INT
  2. Canary
    • The script succeeds until the aro image pull is attempted. It tries to pull an image based on the tag, which apparently is no longer created.
  3. Re-releasing to INT to confirm no regression after rebasing from master

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the VMSS bootstrapping image-pull flow to avoid exposing ACR credentials in process arguments by switching from az acr login to token-based login and podman login --password-stdin.

Changes:

  • Replace az acr login --name <registry> with az acr login --expose-token + podman login --password-stdin in pull_container_images().
  • Derive ACR registry hostname from ACRRESOURCEID for use with podman login.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@s-fairchild s-fairchild force-pushed the ehvs/ARO-24815 branch 2 times, most recently from fff96c9 to bd9f985 Compare March 17, 2026 18:04
Copilot AI review requested due to automatic review settings March 17, 2026 18:04
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review is ineligible. To be eligible to request a review, you need a paid Copilot license, or your organization must enable Copilot code review.

Copilot AI review requested due to automatic review settings March 17, 2026 19:16
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review is ineligible. To be eligible to request a review, you need a paid Copilot license, or your organization must enable Copilot code review.

@swiencki
Copy link
Collaborator

swiencki commented Mar 18, 2026

The new xtrace helpers can abort bootstrap under set -e. xtrace_unset() returns non-zero when tracing is already off, and xtrace_set() returns non-zero when tracing was previously on. Because both VMSS bootstrap scripts run with errexit, the new wrapper around the ACR login path can terminate the script instead of just suppressing tracing.

# * Sets XTRACE_IS_SET=XTRACE_SET (if true) or XTRACE_IS_SET=XTRACE_UNSET (if false).
xtrace_set_capture() {
[[ $- =~ "x" ]] && XTRACE_IS_SET=$XTRACE_SET || XTRACE_IS_SET=$XTRACE_UNSET
}
# xtrace_unset()
#
# Un-sets xtrace (if set)
xtrace_unset() {
(( XTRACE_IS_SET == XTRACE_SET )) && set +x
}
# xtrace_set()
#
# Sets xtrace (if unset)
xtrace_set() {
(( XTRACE_IS_SET == XTRACE_UNSET )) && set -x
}

@hlipsig
Copy link
Collaborator

hlipsig commented Mar 18, 2026

@copilot please review

Copy link

Copilot AI commented Mar 18, 2026

@hlipsig I've opened a new pull request, #4692, to work on those changes. Once the pull request is ready, I'll request review from you.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review is ineligible. To be eligible to request a review, you need a paid Copilot license, or your organization must enable Copilot code review.

@s-fairchild
Copy link
Collaborator

The new xtrace helpers can abort bootstrap under set -e. xtrace_unset() returns non-zero when tracing is already off, and xtrace_set() returns non-zero when tracing was previously on. Because both VMSS bootstrap scripts run with errexit, the new wrapper around the ACR login path can terminate the script instead of just suppressing tracing.

# * Sets XTRACE_IS_SET=XTRACE_SET (if true) or XTRACE_IS_SET=XTRACE_UNSET (if false).
xtrace_set_capture() {
[[ $- =~ "x" ]] && XTRACE_IS_SET=$XTRACE_SET || XTRACE_IS_SET=$XTRACE_UNSET
}
# xtrace_unset()
#
# Un-sets xtrace (if set)
xtrace_unset() {
(( XTRACE_IS_SET == XTRACE_SET )) && set +x
}
# xtrace_set()
#
# Sets xtrace (if unset)
xtrace_set() {
(( XTRACE_IS_SET == XTRACE_UNSET )) && set -x
}

@swiencki This is true. I've tested locally with a short script sourcing util-common.sh and running xtrace_set and xtrace_unset. Not super relevant, but running xtrace_set in succession does not cause failure (return non zero). However running xtrace_set in succession does cause failure (return non zero). Not sure why.

Anyways I've pushed an update that returns 0 if the conditional test for XTRACE_IS_SET is false.

@s-fairchild
Copy link
Collaborator

@copilot please review

@github-actions
Copy link

Please rebase pull request.

@github-actions github-actions bot added needs-rebase branch needs a rebase and removed ready-for-review labels Mar 18, 2026
Copilot AI review requested due to automatic review settings March 19, 2026 13:49
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review is ineligible. To be eligible to request a review, you need a paid Copilot license, or your organization must enable Copilot code review.

@github-actions github-actions bot removed the needs-rebase branch needs a rebase label Mar 19, 2026
@github-actions github-actions bot added the needs-rebase branch needs a rebase label Mar 25, 2026
@github-actions
Copy link

Please rebase pull request.

@s-fairchild s-fairchild added the next-release To be included in the next RP release rollout label Mar 25, 2026
…e acr login secret

Reference: https://portal.microsofticm.com/imp/v5/incidents/details/752908291/summary

Add unset xtrace while configuring tls certificates
    * To be extra safe and ensure no certificate details are logged via shell tracing.

Add shell check comments, Update function descriptions
    * Add shellcheck comments for warnings that can be safely ignored.
    * Improve function readability by formatting them all in the same style.

Address shellcheck warnings in bootstrap scripts
    * Several warnings were unaddressed. Some of them were disabled as they can be safely ignored.
    * Others were refactored as the warnings were legitimate.
@github-actions github-actions bot removed the needs-rebase branch needs a rebase label Mar 25, 2026
@cadenmarchese
Copy link
Member

/azp run ci

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

loki next-release To be included in the next RP release rollout priority-high High priority issue or pull request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

10 participants