Skip to content

Security: Prevent CI secret exposure in Git remote URLs - #1

Open
mertcano wants to merge 1 commit into
krakenfx:mainfrom
mertcano:mertcano-patch-1
Open

Security: Prevent CI secret exposure in Git remote URLs#1
mertcano wants to merge 1 commit into
krakenfx:mainfrom
mertcano:mertcano-patch-1

Conversation

@mertcano

Copy link
Copy Markdown

Why

The scheduled sync workflow previously interpolated secrets.FORK_PAT directly into clone and remote URLs. This critical anti-pattern exposed the credential in command-line arguments and persisted it within the Git remote configuration.

How

Refactored the authentication mechanism to use an ephemeral http.extraheader injected securely through Git's environment configuration (GIT_CONFIG_COUNT, GIT_CONFIG_KEY_0, GIT_CONFIG_VALUE_0). Removed all token references from the git clone, git remote set-url, and git remote add URLs, keeping them strictly credential-free. Enabled set -euo pipefail to enforce strict bash error handling and pipeline failure propagation.

Security/Robustness changes

Eliminates credential leakage in the CI/CD pipeline, ensuring tokens are not inadvertently logged or exposed to local/downstream processes inspecting .git/config.

Testing

Verified that changed-file secret scanning passes and that token-bearing Git URLs are no longer present after remediation.

Why

The scheduled sync workflow previously interpolated secrets.FORK_PAT directly into clone and remote URLs. This critical anti-pattern exposed the credential in command-line arguments and persisted it within the Git remote configuration.  

How

Refactored the authentication mechanism to use an ephemeral http.extraheader injected securely through Git's environment configuration (GIT_CONFIG_COUNT, GIT_CONFIG_KEY_0, GIT_CONFIG_VALUE_0).  Removed all token references from the git clone, git remote set-url, and git remote add URLs, keeping them strictly credential-free.  Enabled set -euo pipefail to enforce strict bash error handling and pipeline failure propagation.  

Security/Robustness changes

Eliminates credential leakage in the CI/CD pipeline, ensuring tokens are not inadvertently logged or exposed to local/downstream processes inspecting .git/config.  

Testing

Verified that changed-file secret scanning passes and that token-bearing Git URLs are no longer present after remediation.
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.

1 participant