problem: Actions runner token is stored with password hash #12443
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Does your problem still exist on the latest Forgejo version?
Yes, the problem still exists (tested locally with the latest development version)
About your usage of Forgejo
Co-maintainer of Codeberg.org's Forgejo instance.
Problem description
I took a CPU and trace profile on codeberg.org to check for a weird performance bug, while doing that there was something that caught my eye:

Text Version
That's way more than it should be.
The relevant code show painfully why it was showing up as taking that much time in the CPU profile:
codeberg.org/forgejo/forgejo@69cf1f3333/routers/api/actions/runner/interceptor.go (L43)It's run in the interceptor! Thus on every request from the Forgejo Runner to the Forgejo instance, the token is hashed and checked. But hashing is not expensive! But the hash used is pbkdf, which is a hash for passwords (low entropy) and thus slow on purpose:
codeberg.org/forgejo/forgejo@69cf1f3333/models/auth/twofactor.go (L73-L77)The token has enough entropy to be hashed via SHA256 or blake even.
Potential workarounds
codeberg.org/Codeberg-Infrastructure/forgejo@fb4a64f0ac, although seems to not be sufficient with a cache size of 1024 on the scale of Codeberg.Forgejo Version
v15.0.1
Other details about your environment (software names and versions)
Codeberg runs a soft fork of Forgejo, https://codeberg.org/Codeberg-Infrastructure/forgejo
Solutions
Accepted solutions to address this problem will go here
Tagging this as good first issue, and loosely related to actions. The way to fix this is straight forward IMO and happy to take a new contributor as a way to explore the codebase.
Happy to take this issue