Skip to content
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

Woodpecker agent tokens should only be valid for one time usage #3297

Open
3 tasks done
runephilosof-karnovgroup opened this issue Jan 30, 2024 · 5 comments
Open
3 tasks done
Labels
enhancement improve existing features security

Comments

@runephilosof-karnovgroup
Copy link
Contributor

Clear and concise description of the problem

Woodpecker token is available to jobs woodpecker-ci/autoscaler#91

Suggested solution

Agent tokens should be invalidated after first usage.

Alternative

No response

Additional context

No response

Validations

  • Checked that the feature isn't part of the next version already [https://woodpecker-ci.org/faq#which-version-of-woodpecker-should-i-use]
  • Read the docs.
  • Check that there isn't already an issue that request the same feature to avoid creating a duplicate.
@runephilosof-karnovgroup runephilosof-karnovgroup added the feature add new functionality label Jan 30, 2024
@qwerty287
Copy link
Contributor

Maybe I completely misunderstand this, but what about this case:

  1. Start agent with some token set vie env var
  2. The server invalidates the token.
  3. Shut down the agent.
  4. Start the agent again. This should work without changing the env vars.

Maybe you could also fix your problem with #3199?

@runephilosof-karnovgroup
Copy link
Contributor Author

Maybe the token should be exchanged for another token, which is saved in the agent config.

@runephilosof-karnovgroup
Copy link
Contributor Author

@anbraten @6543 This is a security issue since it seems like some people are using the woodpecker autoscaler in a way that makes the token available to jobs (I say that because woodpecker-ci/autoscaler#15 (comment) is merged).

@qwerty287 qwerty287 added enhancement improve existing features security and removed feature add new functionality labels Feb 8, 2024
@anbraten
Copy link
Member

anbraten commented Feb 8, 2024

Maybe the token should be exchanged for another token, which is saved in the agent config.

So sth like this?

  • The registration-token would be generated via an api endpoint, already creating the agent db entry with the final agent-token
  • The generated registration-token maybe a jwt-token containing the resulting agent-id is returned and invalidated
  • The agent exchanges the registration-token for an agent-token
  • The fetched agent-token is saved to the config
  • The agent is from now on using the agent-token from the config file

@runephilosof-karnovgroup
Copy link
Contributor Author

Something in the database will need to indicate that it is invalid.
Maybe add a field (either registration_token:string or registered:bool).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement improve existing features security
Projects
None yet
Development

No branches or pull requests

3 participants