-
Notifications
You must be signed in to change notification settings - Fork 1.1k
flux leaks https password in git error messages #2655
Comments
There are some improvements for this in 1.16.0 (see #2549 ), but I am afraid it doesn't cover this case. I think we will need to go through all the potential error cases as well, which is going to be tough since, for instance the error above comes from an invocation of the git command whose format we don't fully control. |
Thanks @2opremio i missed that issue when searching. Glad a fix is on the books. Cheers. |
I have given some more thought to this but I don't think we can strive to remove the URL password from every possible error message. Also, having the password in the Flux command-line arguments by itself is not a great idea. It could be considered a leak in the same way as printing them in the logs. Thus, I would recommend using something like the Git Credential storage. I haven't tried it, but you should be able to change Flux's git configuration to use this, plus you could mount the credentials file from a Kubernetes secret. |
I have already done something very similar to this in my current HTTPS setup. You may be interested to know that the credentials supplied in a Git HTTPS url are easily persisted to a user's credential store. All that is required is for one to create a
Once this config is created, any credential used in a Git HTTPS operation will be persisted in the file referenced in the config above. Extrapolating, it should be possible for Flux to use the credentialed HTTPS url one-time (to persist the credentials) and thereafter, substitute a sanitized URL in future Git operations. |
The same issue with leaking of PAT as topicstarter stated. P.S. also it looks like that fluxd 1.17.0 effectively hides PAT and the issue is resolved. |
I've seen this in a different error message:
Would be open to setting up something else for https auth, but the above comments don't quite make it clear how this should be done. Would git, in this context, respect a
On version 1.18.0 |
I have never used Just try it. |
How about that, works perfectly: apiVersion: v1
kind: Secret
metadata:
name: flux-netrc
namespace: flux
type: Opaque
stringData:
netrc: |-
machine ghe-host.com
login usernamehere
password tokengoeshere # flux command:
--git-url=https://ghe-host.com/org/repo
# under volumes:
- name: flux-netrc
secret:
secretName: flux-netrc
defaultMode: 0400
# under volumeMounts
- name: flux-netrc
mountPath: /root/.netrc
subPath: netrc Now logs all look slightly funny, but everything works with zero leak chance:
|
Flux v1 is formally superseded since the GitOps Toolkit APIs have been declared stable: https://fluxcd.io/docs/migration/timetable/ The repo will remain in maintenance for some time, but no new features can be accepted. Bugs can be addressed if they are critical and there is a PR to resolve it, but soon only CVEs can be addressed in Flux v1, and new users are all recommended to use Flux v2 for some time now. I am not sure how to resolve this issue without a breaking change, but I also do not want to spend time on it unless there is an actual user who is actively being impacted by this. Please speak up if you still need help. My preference would be to work around rather than patch, until they are able to migrate to Flux v2 where this type of issue can be given priority if it is present. I do not think you will find this problem anymore in modern Flux releases. Thanks for using Flux! |
Describe the bug
When configured to use Git over HTTPs, Flux will log errors containing the PAT.
To Reproduce
Expected behavior
Error logs containing URLS should be sanitized.
Logs
Additional context
The text was updated successfully, but these errors were encountered: