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

Add warning that GITHUB_TOKENs cannot be passed to subsequent jobs #29386

Closed
wants to merge 6 commits into from

Conversation

MarkIannucci
Copy link
Contributor

@MarkIannucci MarkIannucci commented Oct 25, 2023

Why:

We've lost a ton of time attempting to pass tokens generated in one job to reusable workflows.

It seems we are not alone in this time loss. I also haven't found any documentation about the functionality which prohibits setting a job's output to a GITHUB_TOKEN other than this comment in an issue.

Closes:

What's being changed (if available, include any code snippets, screenshots, or gifs):

Check off the following:

  • I have reviewed my changes in staging, available via the View deployment link in this PR's timeline.

    • For content changes, you will also see an automatically generated comment with links directly to pages you've modified. The comment won't appear if your PR only edits files in the data directory.
  • For content changes, I have completed the self-review checklist.

@github-actions github-actions bot added the triage Do not begin working on this issue until triaged by the team label Oct 25, 2023
@github-actions
Copy link
Contributor

github-actions bot commented Oct 25, 2023

Automatically generated comment ℹ️

This comment is automatically generated and will be overwritten every time changes are committed to this branch.

The table contains an overview of files in the content directory that have been changed in this pull request. It's provided to make it easy to review your changes on the staging site. Please note that changes to the data directory will not show up in this table.


Content directory changes

You may find it useful to copy this table into the pull request summary. There you can edit it to share links to important articles or changes and to give a high-level overview of how the changes in your pull request support the overall goals of the pull request.

Source Preview Production What Changed
apps/creating-github-apps/authenticating-with-a-github-app/making-authenticated-api-requests-with-a-github-app-in-a-github-actions-workflow.md fpt
ghec
ghes@ 3.10 3.9 3.8 3.7 3.6
ghae
fpt
ghec
ghes@ 3.10 3.9 3.8 3.7 3.6
ghae

fpt: Free, Pro, Team
ghec: GitHub Enterprise Cloud
ghes: GitHub Enterprise Server
ghae: GitHub AE

@cmwilson21
Copy link
Contributor

@MarkIannucci Thanks so much for submitting a PR! I'll get this triaged for review ⚡

@cmwilson21 cmwilson21 added actions This issue or pull request should be reviewed by the docs actions team waiting for review Issue/PR is waiting for a writer's review content This issue or pull request belongs to the Docs Content team and removed triage Do not begin working on this issue until triaged by the team labels Oct 25, 2023
Copy link
Contributor

@skedwards88 skedwards88 left a comment

Choose a reason for hiding this comment

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

Thanks for opening this PR to share your learnings with others!

  • I think this might be more visible if we put it in the introductory text before the workflow, maybe after line 24
  • There are a couple other workflow examples that use the actions/create-github-app-token action. Can you update those places as well?

Comment on lines 64 to 68
{% warning %}

**Warning:** Automatic token protection prevents passing tokens generated with this method to subsequent jobs. By design, GitHub Runners are written to protect `GITHUB_TOKENS`. As a consequence, they will set the values of GITHUB_OUTPUTS to the empty string if they contain tokens issued with this functionality.

{% endwarning %}
Copy link
Contributor

Choose a reason for hiding this comment

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

A couple of suggestions to:

  • Use a note since we try to reserve warning callouts for potentially destructive actions
  • Add a potential workaround
  • Remove some text
Suggested change
{% warning %}
**Warning:** Automatic token protection prevents passing tokens generated with this method to subsequent jobs. By design, GitHub Runners are written to protect `GITHUB_TOKENS`. As a consequence, they will set the values of GITHUB_OUTPUTS to the empty string if they contain tokens issued with this functionality.
{% endwarning %}
{% note %}
**Note:** Due to automatic token protection, you cannot pass tokens generated with this method to downstream jobs. If you need to share the token with another job, you can store the token as an {% data variables.product.prodname_actions %} secret. For more information, see "[AUTOTITLE](/rest/actions/secrets#create-or-update-a-repository-secret)."
{% endnote %}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you for the review. The potential workaround is not viable as it allows a token fetched by one workflow to be used by any other workflow in the repo which could be used to escalate privileges (as long as the attack was well timed).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm happy to incorporate the comment elsewhere once we figure out the correct wording.

Copy link
Contributor

Choose a reason for hiding this comment

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

In that case, would it be better to omit the workaround and just say this?

{% note %}

**Note:** Due to automatic token protection, you cannot pass tokens generated with this method to downstream jobs.

{% endnote %}

@skedwards88 skedwards88 added more-information-needed More information is needed to complete review and removed waiting for review Issue/PR is waiting for a writer's review labels Oct 27, 2023
@cmwilson21
Copy link
Contributor

@MarkIannucci Feel free to ping us when this is ready for another review! 👍

@github-actions github-actions bot added the stale There is no recent activity on this issue or pull request label Nov 14, 2023
Copy link
Contributor

This PR has been automatically closed because there has been no response to to our request for more information from the original author. Please reach out if you have the information we requested, or open a new issue to describing your changes. Then we can begin the review process.

@github-actions github-actions bot closed this Nov 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
actions This issue or pull request should be reviewed by the docs actions team content This issue or pull request belongs to the Docs Content team more-information-needed More information is needed to complete review stale There is no recent activity on this issue or pull request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants