Skip to content

Make WIF credential file readable inside the R2A container - #12

Closed
andypotanin wants to merge 1 commit into
productionfrom
fix/wif-credential-readable
Closed

Make WIF credential file readable inside the R2A container#12
andypotanin wants to merge 1 commit into
productionfrom
fix/wif-credential-readable

Conversation

@andypotanin

@andypotanin andypotanin commented Aug 29, 2026

Copy link
Copy Markdown
Member

Problem

Calling the action after google-github-actions/auth (workload identity) fails inside the R2A container with:

Configured GCP credential file could not be read

google-github-actions/auth writes GOOGLE_APPLICATION_CREDENTIALS with mode 0600. The R2A image runs as the non-root udx user, so the read-only bind mount at /tmp/gcp-credentials.json is unreadable inside the container.

The private udx/gh-workflows reusable workflow works around this by chmod-ing the file before docker run; the public action did not, so any external caller following the README hits this.

Fix

In the Run Rabbit Automation Action step, chmod 0644 the credential file for the duration of the container run and restore the original mode via an EXIT trap.

Verification

Reproduced on udx/www.wpcloud.io calling udx/github-rabbit-action@v1.0.4 directly:

  • without the chmod: run 33249682486 fails at the R2A step with the message above
  • with an equivalent caller-side chmod 0644 "$GOOGLE_APPLICATION_CREDENTIALS": run 33249791898 passes, full production plan (14 services)

Devin Review

google-github-actions/auth writes the credential file 0600. The R2A
container runs as the non-root udx user, so the read-only bind mount
fails with 'Configured GCP credential file could not be read'.
Temporarily chmod 0644 for the duration of the container run and
restore the original mode on exit.
Copilot AI lite review requested due to automatic review settings August 29, 2026 11:22
@andypotanin
andypotanin requested a review from a team as a code owner August 29, 2026 11:22

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Devin Review found 3 potential issues.

Devin Review

Comment thread action.yml
chmod "$credential_mode" "$GCP_CREDENTIALS_PATH" 2>/dev/null || true
}
trap restore_credential_mode EXIT
chmod 0644 "$GCP_CREDENTIALS_PATH"

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Readable credentials abort deployment

An already world-readable credential file can belong to another account. The unconditional chmod fails, aborting deployment before the container starts.

Prompt for agents
In action.yml's Run Rabbit Automation Action step, avoid requiring ownership of a credential file that is already readable by the container. The current unconditional chmod 0644 fails for caller-provided, world-readable files owned by another account, which can occur on self-hosted runners or with externally mounted credentials. Inspect the effective target mode first and change permissions only when additional read access is required. Preserve the existing temporary-mode restoration behavior for files that are changed, and account for symbolic-link paths when reading and restoring the target mode.
Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Handled in #13 (8536852): the action now leaves the caller credential untouched and uses install to stage a readable copy in a private mktemp -d directory. It no longer requires ownership of the source file.

Comment thread action.yml
chmod "$credential_mode" "$GCP_CREDENTIALS_PATH" 2>/dev/null || true
}
trap restore_credential_mode EXIT
chmod 0644 "$GCP_CREDENTIALS_PATH"

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Credential fix receives no release

Merging this behavior change without a new version makes Publish release skip publication. Versioned and v1 callers never receive the fix.

Prompt for agents
Prepare this action behavior change as the next patch release. Update package.json to the next semantic version and add the matching top entry to CHANGELOG.md with concise user-facing notes. Keep both values synchronized so make test passes and the production Publish release workflow detects the version change and creates the immutable release.
Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Handled in #13 (8536852): the combined production-targeting PR carries the 1.0.5 package version and matching changelog entry. After #13 merges into this branch, the production-targeted CI check verifies the release increment.

Comment thread action.yml
chmod "$credential_mode" "$GCP_CREDENTIALS_PATH" 2>/dev/null || true
}
trap restore_credential_mode EXIT
chmod 0644 "$GCP_CREDENTIALS_PATH"

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟨 Cloud credentials exposed to runner users

chmod 0644 lets every local account read the active Google Cloud credential while the container runs. Shared-runner processes can copy it before restoration.

Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Handled in #13 (8536852): the caller credential is no longer chmodded. Only a temporary copy inside a private mktemp -d directory is mounted for the non-root container and removed at step exit.

Copilot AI left a comment

Copy link
Copy Markdown

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 addresses failures when running the action after google-github-actions/auth (Workload Identity) by ensuring the generated GOOGLE_APPLICATION_CREDENTIALS file can be read inside the R2A container (which runs as a non-root user).

Changes:

  • Temporarily adjusts the GCP credentials file permissions to make the bind-mounted file readable inside the container.
  • Adds cleanup logic intended to restore the original credential file mode after use.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread action.yml
Comment on lines +554 to 564
# google-github-actions/auth writes the credential file 0600 and the
# R2A container runs as the non-root udx user, so the read-only bind
# mount is unreadable inside the container. Make it world-readable
# only while the container runs, then restore the original mode.
credential_mode="$(stat -c '%a' "$GCP_CREDENTIALS_PATH")"
restore_credential_mode() {
chmod "$credential_mode" "$GCP_CREDENTIALS_PATH" 2>/dev/null || true
}
trap restore_credential_mode EXIT
chmod 0644 "$GCP_CREDENTIALS_PATH"
gcp_mount=(-v "$GCP_CREDENTIALS_PATH:/tmp/gcp-credentials.json:ro" -e "GOOGLE_APPLICATION_CREDENTIALS=/tmp/gcp-credentials.json")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Handled in #13 (8536852): this follows the suggested private-directory copy pattern. The source credential remains private; the container receives a read-only mount of the staged copy, which the exit trap removes.

@andypotanin

Copy link
Copy Markdown
Member Author

Superseded by #13, which stages a readable copy of the credential in a private temp dir instead of chmod-ing the caller's file, and bumps the version so the fix actually ships.

@andypotanin
andypotanin deleted the fix/wif-credential-readable branch August 29, 2026 13:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants