-
Notifications
You must be signed in to change notification settings - Fork 13.4k
workflows/release-binaries: Remove .git/config file from artifacts #106310
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
Conversation
The .git/config file contains a auth token that can be leaked if the .git directory is included in a workflow artifact.
@llvm/pr-subscribers-github-workflow Author: Tom Stellard (tstellar) ChangesThe .git/config file contains an auth token that can be leaked if the .git directory is included in a workflow artifact. Full diff: https://github.com/llvm/llvm-project/pull/106310.diff 1 Files Affected:
diff --git a/.github/workflows/release-binaries-save-stage/action.yml b/.github/workflows/release-binaries-save-stage/action.yml
index e2f3eeadd15bea..63d00255f6d8fb 100644
--- a/.github/workflows/release-binaries-save-stage/action.yml
+++ b/.github/workflows/release-binaries-save-stage/action.yml
@@ -18,6 +18,10 @@ runs:
- name: Package Build and Source Directories
shell: bash
run: |
+ # Remove git directory so we avoid leaking secrets stored in .git/config.
+ # See https://unit42.paloaltonetworks.com/github-repo-artifacts-leak-tokens/
+ # This also helps reduce the size of the archive.
+ rm -Rf .git/
# Windows does not support symlinks, so we need to dereference them.
tar --exclude build/ ${{ (runner.os == 'Windows' && '-h') || '' }} -c . | zstd -T0 -c > ../llvm-project.tar.zst
mv ../llvm-project.tar.zst .
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you come across this from the article or was there some scanner involved here?
I'm assuming the token by default won't have a large amount of permissions though and should be ephemeral?
Speaking of that, do we want to tack on a
permissions:
contents: read
at the top?
It's from the article linked in the comment.
The called workflow inherits the caller permissions, so the tokens should be read-only and only usable while the workflow is running.
I'm not sure if the composite actions support top-level permissions, but I'll try it. |
Ah, it's an action. I did not realize that. |
Deleting the whole .git directory breaks the VersionFromVCS computation for stage2 and stage3.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
/cherry-pick ef50970 |
…lvm#106310) The .git/config file contains an auth token that can be leaked if the .git directory is included in a workflow artifact. (cherry picked from commit ef50970)
/pull-request #106821 |
…lvm#106310) The .git/config file contains an auth token that can be leaked if the .git directory is included in a workflow artifact. (cherry picked from commit ef50970)
The .git/config file contains an auth token that can be leaked if the .git directory is included in a workflow artifact.