-
-
Notifications
You must be signed in to change notification settings - Fork 383
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Replace NetrcOnlyTrusted
with list of trusted plugins for netrc
#2601
Comments
Then we're still missing an option that allows the use of credentials in custom steps/images. If the repo admin wants to allow it (e.g. in private repos). So why not structure it like this:
The use case I had was a step executing arbitrary git commands, among them |
is this not solved by simply make woodpecker/shared/constant/constant.go Lines 39 to 42 in 26b77ed
as an configuration option? |
Yes, but then it's only a global configuration and not per-repo. |
an option only instance admins should change in any case |
I don't think so. What about codeberg ci? The users wouldn't be able to use this option. |
well that would allow any one to steal other users credentials at codeberg:
|
Is cloning using the tokens of the pipeline authors? Shouldn't it use the repo users/owners? Anyways, I see your point. Maybe we should limit this to plugins? |
I am also not for exposing those secrets to easily (as commented before), but your point seems to be wrong.
It uses the oauth token of the first repo admin (might be updated to another repo admin on sync later not 100% sure).
An image filter would be for plugins only as otherwise it would not really help (see my description & similar to #2213). |
I also think in general we shouldn't expose these internal secrets. You can always add them manually. If I think about it, an image for plugins only in this case is kinda useless, so I'm not sure if we should implement this. (Using global config as suggested by @6543 could be an option but I'm not sure if it solves the underlying issue.) |
Speaking of the use-cases (AFAIK from reading the request / comments) the idea would be that a user could use:
Using the credentials to clone somewhere in the steps again using the official clone plugin is already supported. |
For github forge, it would make the credentials non-sensitive, if it is converted to a github app, using short lived and restricted access tokens. |
Do we know how other CI providers handle this? We should also take into account that this is a complicated situation for users if "too much" magic is happening behind the scenes or certain things only apply in some special situations. Also WRT to documentation. A situation which is popular in the instances I managed (and which worked/still works in drone) is to use arbitrary git commands to apply some git modifications and then push back to the cloned repo. For this a git plugin would only partially help (unless it has a setting where one could input arbitrary git commands of infinite length). |
GH Actions have https://docs.github.com/en/actions/security-guides/automatic-token-authentication which is a token for a special user/app AFAIK (https://github.com/apps/github-actions). I don't think though we should do something similar. You can still add secrets containing the credentials, but the netrc vars should be internal vars I think.
How does drone handle this? It's a really critical security issue if you just expose some random oauth tokens. |
I agree, not saying we should do the same. Just reporting how it works. |
Hmm looking at drone's docs I can't find an env var holding a token. There's nothing listed containing |
It's also not clear to me, unfortunately. The pipeline I am talking about does the following kind: pipeline
type: kubernetes
name: CI
steps:
- name: CI
image: <some image with git>
commands:
- git fetch origin json
[...]
- git status
- git diff --numstat
- git remote -v
- git add .
- git commit --message "Automated import"
- git push and the |
It even works without changing author/email config? Interesting. Does somebody has access to a drone instance so we can find out more? |
I am not 100% sure, but I think it is mounting |
This code shows how they create the netrc file: https://github.com/drone-runners/drone-runner-docker/blob/bb7abc32a5b79f7f03fae2bb398366b1ef94e0ff/engine/compiler/shell/shell.go#L38 |
Ah yeah, that might be it. Also
WRT to my example above, the repo is "private". |
As noticed in several PRs the current option
NetrcOnlyTrusted
is limiting users, but on the other hand not really protecting them as well as netrc credentials could be stolen by a custom clone step with custom commands.To prevent this a
pass-netrc-to-plugins
option should replace theNetrcOnlyTrusted
option. This option would contain list of images which will receive the netrc credentials if they are used as plugins. If the image however uses custom commands it wont get the credentials as those commands could be changed by others than the admin.This will allow all steps and the clone step to use netrc credentials. It will however be breaking as it wont be possible anymore to use clone steps with custom commands.
The text was updated successfully, but these errors were encountered: