Skip to content

Fix: Prevent cleartext credential storage in Git DAG bundles#64105

Open
rjgoyln wants to merge 3 commits intoapache:mainfrom
rjgoyln:credential_leakage
Open

Fix: Prevent cleartext credential storage in Git DAG bundles#64105
rjgoyln wants to merge 3 commits intoapache:mainfrom
rjgoyln:credential_leakage

Conversation

@rjgoyln
Copy link
Contributor

@rjgoyln rjgoyln commented Mar 23, 2026

The current GitHook stores sensitive auth_token by concatenating it directly into the repo_url (e.g., https://user:token@repo.git).

Solution

Remove URL Concatenation: Stopped injecting tokens into the URL string.

Implement GIT_ASKPASS: Switched to using the GIT_ASKPASS environment variable with a secure temporary script to handle authentication.

Verification

After the fix, the command remains clean, and all unit tests passed.

closes: #64099

Was generative AI tooling used to co-author this PR?
  • Yes (please specify the tool below)

  • Read the Pull Request Guidelines for more information. Note: commit author/co-author name and email in commits become permanently public when merged.
  • For fundamental code changes, an Airflow Improvement Proposal (AIP) is needed.
  • When adding dependency, check compliance with the ASF 3rd Party License Policy.
  • For significant user-facing changes create newsfragment: {pr_number}.significant.rst, in airflow-core/newsfragments. You can add this file in a follow-up commit after the PR is created so you know the PR number.

@rjgoyln rjgoyln marked this pull request as ready for review March 23, 2026 16:40
@potiuk
Copy link
Member

potiuk commented Mar 23, 2026

Just to be very clear - this is not a vulnerabilty - this is at most security improvement.

@potiuk potiuk changed the title Fix: Prevent cleartext credential leakage in Git DAG bundles Fix: Prevent cleartext credential storage in Git DAG bundles Mar 23, 2026
@potiuk
Copy link
Member

potiuk commented Mar 23, 2026

I updated the description and removed the scary RED thingie - as this is not a vulnerability, it might be a nice security improvement though

@rjgoyln
Copy link
Contributor Author

rjgoyln commented Mar 23, 2026

I updated the description and removed the scary RED thingie - as this is not a vulnerability, it might be a nice security improvement though

Thanks for the guidance, Jarek!😍
I'm still aligning with Airflow's security terminology, so I appreciate you updating the description.

self.repo_url = self.repo_url
elif not self.repo_url.startswith("git@") or not self.repo_url.startswith("https://"):

if not self.repo_url.startswith("git@") or not self.repo_url.startswith("https://"):
Copy link
Contributor

Choose a reason for hiding this comment

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

this condition would always be true unless the or here is replaced by "and".
Also the http:// urls still seem to embed the credentials in this case.


with open(askpass_path) as f:
content = f.read()
assert f"echo '{ACCESS_TOKEN}'" in content
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: better to add escape sequence to the single quote here.

return

with tempfile.NamedTemporaryFile(mode="w", suffix=".sh", delete=True) as askpass_script:
askpass_script.write(f"#!/bin/sh\necho '{self.auth_token}'\n")
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: might need escape sequences for the single quotes here as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for your advice—I learned a lot 😊

@rjgoyln rjgoyln force-pushed the credential_leakage branch from 065f045 to 9470b1a Compare March 23, 2026 19:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cleartext Credential stored locally in Airflow DAG Bundles Git Configuration

3 participants