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

chore: Fixing non-propagated custom GH token in forked PRs #134

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

heyvister1
Copy link
Contributor

Since custom GH secrets are not propagated for forked PRs
A new step has been added to verify that actor is a member of Mellanox/cloud-orchestration team

@heyvister1 heyvister1 changed the title Fixing non-propagated custom GH token in forken PRs Fixing non-propagated custom GH token in forked PRs Nov 18, 2024
@heyvister1 heyvister1 changed the title Fixing non-propagated custom GH token in forked PRs chore: Fixing non-propagated custom GH token in forked PRs Nov 18, 2024
A new step has been added to verify that actor is a member of
Mellanox/cloud-orchestration team
@killianmuldoon
Copy link
Contributor

What happens if some one creates a PR to this action with a script to exfiltrate the token before the check runs?

@heyvister1
Copy link
Contributor Author

What happens if some one creates a PR to this action with a script to exfiltrate the token before the check runs?

He needs to gain GH_TOKEN first, but he should be blocked on the first step which checks his membership

Comment on lines +38 to +42
response=$(curl -H "Authorization: Bearer $GH_TOKEN" \
-H "Accept: application/vnd.github+json" \
"https://api.github.com/orgs/Mellanox/teams/cloud-orchestration/members/$ACTOR")

if [[ $(echo "$response" | jq -r '.message') == "Not Found" ]]; then
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does the GH API return an appropriate status code (404?) if the actor is not part of the organization?
If so, this could be shortened to if curl -f ... ; then?

@killianmuldoon
Copy link
Contributor

He needs to gain GH_TOKEN first, but he should be blocked on the first step which checks his membership

What if I create an MR which changes that first step?

@heyvister1
Copy link
Contributor Author

heyvister1 commented Nov 19, 2024

He needs to gain GH_TOKEN first, but he should be blocked on the first step which checks his membership

What if I create an MR which changes that first step?

So this is not only related to my PR change, if anyone can create its own workflow file which will be engaged in PR then we're in a bad shape.
For current status, docs repo can be triggered manually by maintainers. So non-privileged collaborators cannot engage it.
The following workflow is triggered by network-operator PRs which is executing this workflow from main branch only. So others PRs theoretically should not affects our workflow security posture.

@maze88
Copy link
Collaborator

maze88 commented Nov 24, 2024

He needs to gain GH_TOKEN first, but he should be blocked on the first step which checks his membership

What if I create an MR which changes that first step?

The current trigger configuration doesn't trigger on PRs, so shouldn't this not be a problem?

And either way - we can configure the repository (Settings -> Actions -> General -> Approval for running fork pull request workflows from contributors to Require approval for all external contributors.

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

Successfully merging this pull request may close these issues.

3 participants