mirror of
https://github.com/go-gitea/gitea.git
synced 2026-03-12 02:24:21 -05:00
[Intentional] Secrets are not visible in forks #14793
Open
opened 2025-11-02 11:23:06 -06:00 by GiteaMirror
·
12 comments
No Branch/Tag Specified
main
release/v1.25
release/v1.24
release/v1.23
release/v1.22
release/v1.21
release/v1.20
release/v1.19
release/v1.18
release/v1.17
release/v1.16
release/v1.15
release/v1.14
release/v1.13
release/v1.12
release/v1.11
release/v1.10
release/v1.9
release/v1.8
v1.25.3
v1.25.2
v1.25.1
v1.25.0
v1.24.7
v1.25.0-rc0
v1.26.0-dev
v1.24.6
v1.24.5
v1.24.4
v1.24.3
v1.24.2
v1.24.1
v1.24.0
v1.23.8
v1.24.0-rc0
v1.25.0-dev
v1.23.7
v1.23.6
v1.23.5
v1.23.4
v1.23.3
v1.23.2
v1.23.1
v1.23.0
v1.23.0-rc0
v1.24.0-dev
v1.22.6
v1.22.5
v1.22.4
v1.22.3
v1.22.2
v1.22.1
v1.22.0
v1.23.0-dev
v1.22.0-rc1
v1.21.11
v1.22.0-rc0
v1.21.10
v1.21.9
v1.21.8
v1.21.7
v1.21.6
v1.21.5
v1.21.4
v1.21.3
v1.21.2
v1.20.6
v1.21.1
v1.21.0
v1.21.0-rc2
v1.21.0-rc1
v1.20.5
v1.22.0-dev
v1.21.0-rc0
v1.20.4
v1.20.3
v1.20.2
v1.20.1
v1.20.0
v1.19.4
v1.21.0-dev
v1.20.0-rc2
v1.20.0-rc1
v1.20.0-rc0
v1.19.3
v1.19.2
v1.19.1
v1.19.0
v1.19.0-rc1
v1.20.0-dev
v1.19.0-rc0
v1.18.5
v1.18.4
v1.18.3
v1.18.2
v1.18.1
v1.18.0
v1.17.4
v1.18.0-rc1
v1.19.0-dev
v1.18.0-rc0
v1.17.3
v1.17.2
v1.17.1
v1.17.0
v1.17.0-rc2
v1.16.9
v1.17.0-rc1
v1.18.0-dev
v1.16.8
v1.16.7
v1.16.6
v1.16.5
v1.16.4
v1.16.3
v1.16.2
v1.16.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-rc1
v1.3.2
v1.3.1
v1.3.0
v1.3.0-rc2
v1.3.0-rc1
v1.2.3
v1.2.2
v1.2.1
v1.2.0
v1.2.0-rc3
v1.2.0-rc2
v1.1.4
v1.2.0-rc1
v1.1.3
v1.1.2
v1.1.1
v1.1.0
v1.0.2
v1.0.1
v1.0.0
v0.9.99
Labels
Clear labels
$20
$250
$50
$500
backport/done
💎 Bounty
docs-update-needed
good first issue
hacktoberfest
issue/bounty
issue/confirmed
issue/critical
issue/duplicate
issue/needs-feedback
issue/not-a-bug
issue/regression
issue/stale
issue/workaround
lgtm/need 2
modifies/api
modifies/translation
outdated/backport/v1.18
outdated/theme/markdown
outdated/theme/timetracker
performance/bigrepo
performance/cpu
performance/memory
performance/speed
pr/breaking
proposal/accepted
proposal/rejected
pr/wip
pull-request
reviewed/wontfix
💰 Rewarded
skip-changelog
status/blocked
topic/accessibility
topic/api
topic/authentication
topic/build
topic/code-linting
topic/commit-signing
topic/content-rendering
topic/deployment
topic/distribution
topic/federation
topic/gitea-actions
topic/issues
topic/lfs
topic/mobile
topic/moderation
topic/packages
topic/pr
topic/projects
topic/repo
topic/repo-migration
topic/security
topic/theme
topic/ui
topic/ui-interaction
topic/ux
topic/webhooks
topic/wiki
type/bug
type/deprecation
type/docs
type/enhancement
type/feature
type/miscellaneous
type/proposal
type/question
type/refactoring
type/summary
type/testing
type/upstream
Mirrored from GitHub Pull Request
No Label
issue/not-a-bug
Milestone
No items
No Milestone
Projects
Clear projects
No project
No Assignees
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: github-starred/gitea#14793
Reference in New Issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
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?
Originally created by @n3o77 on GitHub (Jul 22, 2025).
Description
It seems that secret variables are not properly passed to environment variables in actions. But i'm not 100% sure what's going wrong as I can't echo the secrets which makes debugging hard.
The secret is properly set in the repository where the workflow is running. I'm using the same secret in another workflow, in the same repository, passing it through
docker/build-push-actionand it's working there without any issues so i'm confident that the secret is properly defined.i.E.:
.gitea/workflows/ci.yml
With this no authentication is used. And the install failes.
When i'm trying with this:
Then authentication is used with
myusernamebut fails because the password is empty. If i'm setting the password instead of using the secret everything works fine.Gitea Version
1.24.3
Can you reproduce the bug on the Gitea demo site?
No
Log Gist
No response
Screenshots
No response
Git Version
No response
Operating System
No response
How are you running Gitea?
Docker Image
Database
MySQL/MariaDB
@n3o77 commented on GitHub (Jul 22, 2025):
I did some more testing. This seems to be only a problem on a PR from a fork. If i create a PR from another branch in the main repository everything works as expected.
@delvh commented on GitHub (Jul 22, 2025):
Ah, but now we are entering dangerous territory.
IIRC, that is intended:
Otherwise, a malicious fork can simply steal your secrets which are often things such as access keys or similar.
As it should be right now, secrets do not cross repo boundaries.
The only people allowed to see the secrets are the owner and/or admins of the repo itself.
In other words: Even in the best case, it would allow forks to impersonate the real project.
That's why forks don't receive the secrets of the parent.
@n3o77 commented on GitHub (Jul 22, 2025):
I see, that makes some sense. Some kind of notice / error would be nice as I wasted quite some hours because I thought something is wrong with my setup. It would also be nice that we could either configure secrets on the forked repositories which can then be used or maybe workflows which are already in the main branch.
In our usecase we want to run tests before a PR can be merged, but to be able to run tests it's necessary to pull private repositories... i don't think that's uncommon, or is it?
@delvh commented on GitHub (Jul 22, 2025):
No, it's not uncommon.
Nevertheless, each of the private forks will need to configure the necessary secrets for itself again.
(At least while there's no better option to distinguish "friendly" forks from untrusted forks)
But yeah, I agree, there should be some kind of warning somewhere.
To me, the best place sounds like a mixture of both
@ChristopherHX regarding 2:
Do you agree that a warning like that would make sense when a value cannot be injected?
If yes, should that happen in
act? Or where would that belong? Into the runner? Gitea itself?and if we were to implement 1, where would we get the information from? Would that require any change outside of Gitea?
@n3o77 commented on GitHub (Jul 22, 2025):
Sounds good. Thank you very much.
Can you think of any workaround for now to get that working? For us it's only used internally with trusted employees, so not really an issue with external PRs.
Another thing which would be nice to display is which secret was used (project secret, orga. secret or user secret) or if the secret doesn't exist at all. That would make debugging much easier.
@delvh commented on GitHub (Jul 22, 2025):
Copy the necessary secrets for each employee individually into their repo.
@n3o77 commented on GitHub (Jul 22, 2025):
Where? In the forked repo settings there's no setting for actions / secrets.
I tried the user settings -> secrets, but that doesn't seem to work either.
@lunny commented on GitHub (Jul 22, 2025):
If you’re in a trusted environment, ask your employee to create a pull request directly from the main repository. That should work.
@delvh commented on GitHub (Jul 22, 2025):
Regarding the
no secrets in settings:Please enable actions first for the fork:
@n3o77 commented on GitHub (Jul 22, 2025):
Unfortunately that doesn't seem to work either for PRs to the main repo. But it works if I create a PR inside the fork. So i guess the only way right now is creating branches in the main repository and then create PRs from there or some variant of that. Not great but better than nothing i guess.
Again, thank you @delvh .
@ChristopherHX commented on GitHub (Jul 22, 2025):
You could dangerously switch to
pull_request_target, then the workflow file is taken from the base branch not from the fork.The GitHub Actions Setting, I do not care about this protection and I want that forks see secrets for inner source is not implemented
Secrets are far less protected, write access to repository = secret access if you can trigger a workflow.
The hardening mechanism "environment secrets" coupled with branch protection or manual approval are not implemented in Gitea Actions.
Yes this makes sense to me. Would certainly help a lot for people to save time.
Generally implementing this only requires actionlint and yaml.v3 as external dependencies that are already used, e.g. taking my schema validator and traversing over every expression and look for
secretsandvarsusages if we happen to have anpull_requestevent instead if doing schema validation.In this case using acts data structures makes no sense, maybe customize and embed this directly into Gitea? (It's 100% my own code and has not landed in gitea/act).
By reading the workflow and parsing the expressions
This depends on architecture, something like this has no dependency to act. So I would put this into Gitea.
I wonder:
Do we want to see an warning if the PR is not from a fork? Sometimes people with write access create a workflow, test it and then wonder why it not works for forks.
I would prefer this, e.g. you know this before the job starts.
However
Option 2 could work for the barely supported reusable workflows as well (Which I want to move to Gitea Server side, except if you specify runs-on for the workflow)...
@n3o77 commented on GitHub (Jul 22, 2025):
@ChristopherHX that works for me and in this particular case is fine security wise. Thank you very much!
I think using the secrets from the fork for those PRs would be optimal, then every dev can manage their own secrets. Any chance to get that implemented at some point?