Get the free coreGet core

Malware in a GitHub repository: how to check a repo before you run it

Updated 6 min readSection 05 / Threats
SHORT ANSWER

A GitHub malware repository does not need you to run its program. It can run something when you open the folder, install packages or build the project. Read the files that execute on their own first: .vscode/tasks.json, npm scripts, Xcode projects and, in a project folder someone shared, git hooks. A scan finds only known malware, so open an unknown repo in isolation.

Already ran it? Stop using the Mac for anything sensitive and disconnect it from the network. Then follow the cleanup steps in If you already ran it: clean the Mac first, then change passwords from another device you trust.

Cloning a repo only copies files. The harm starts when something runs them, and three ordinary actions can do that: opening the folder in an editor, installing dependencies, or building the project. A fourth, committing, matters only if someone handed you a whole project folder that carries its own git hooks (scripts git runs at set points). A normal git clone does not bring hooks along. Below is what to read, in order, and then how to open the repo where a surprise costs little.

01Files to read before you run a GitHub malware repository

Look at these in a terminal or a plain text viewer, not in an editor that may run them. The whole check takes a couple of minutes, and none of the steps needs the code to run.

File or placeWhat to look forWhen it runs
.vscode/tasks.jsonA task with runOn set to folderOpenWhen the folder opens
package.jsonpreinstall, install and postinstall entriesAfter packages are installed
Xcode project filesUnexpected build phases and settingsWhile the project is built
.git/hooks in a shared project folderHook files you did not write, in a folder someone gave youOn later commits in that project
.claude/settings.jsonHooks defined in the projectIn agent sessions; hooks are scripts that run at set points
.mcp.jsonProject-scoped MCP serversIn agent sessions; MCP servers are programs an agent can call
README setup stepsCommands to paste into a terminalWhenever you paste them

For the first row, two commands do the job:

cat .vscode/tasks.json
grep folderOpen .vscode/tasks.json

The .vscode folder is routinely ignored in security reviews, which is why it comes first. Reviewing .mcp.json does not show every server a session can load. Hooks and MCP are explained on Claude Code hooks.

02Where a GitHub malware repository hides its code

Four cases show the pattern, so the table above is not abstract.

03What each of these files does

A task in tasks.json is a command that VS Code runs for you. With runOn set to folderOpen it runs the moment the containing folder is opened, and VS Code executes the specified command automatically. That is why simply opening a cloned repository in the editor can compromise the system.

An npm script is a command in package.json. In npm 11 the preinstall, install and postinstall scripts run after the modules are installed, in order, with nothing in between. npm 12 blocks dependency install scripts by default until you approve them. A git hook is a script that git runs at a set point, such as before a commit; XCSSET uses the pre-commit kind to stay on the machine. A clone does not copy hooks, so they matter in a project folder passed around as files, which is how XCSSET spreads. An Xcode project can run code while it is built. In each case the file looks like configuration, which is why it gets skipped in a quick read.

04Can you scan a repository for malware?

A scan is worth running but it does not decide anything. macOS includes XProtect, built-in antivirus technology for signature-based detection and removal of malware. A signature describes malware that is already known. A Banshee variant went undetected by antivirus engines on VirusTotal for over two months, and a DigitStealer disk image was flagged by none of them at analysis time.

TruffleHog is a different kind of tool: it finds secrets such as keys and passwords, not malware. So the order is: read the auto-run files, run a scanner if you like, then open the repo in isolation.

05Open it in isolation

The advice for unfamiliar code is a dedicated, isolated environment, for example a non-persistent virtual machine. A VM is a computer simulated inside your Mac that you can delete afterwards.

If you stay in VS Code, new unfamiliar folders open in Restricted Mode, which limits tasks, the terminal, extensions and AI agents. Automatic tasks never run in an untrusted workspace, and when in doubt you leave the folder in Restricted Mode. Restricted Mode cannot stop a malicious extension from running code. In Cursor, workspace trust is off by default, and for untrusted repos the docs point to a basic text editor.

A container is a lighter option than a VM: an isolated box on your Mac where the code runs. VS Code can open a repo in an isolated container volume to review it without impacting your local work. Use that as a second layer, because dev containers are meant for trusted repositories. A copyable setup with Docker's own tool is on Claude Code in Docker.

If you open the repo with an AI agent, look first and run the agent only in the isolated environment. The advisories that affected Claude Code are listed on Claude Code security.

06A README that asks you to paste a command

Never run commands copied from websites, emails or messages unless you trust the source and understand what they do. That includes curl-to-bash combinations. A README that asks for a pasted command deserves the same suspicion as an email that asks for your password, even when the repository has many stars and a tidy history. If you need a README command, read it first, and if you cannot say what each part does, do not paste it. What these stealers take once they run is covered on infostealers.

07If you already ran it

Treat the Mac as exposed, since a stealer takes browser data, Keychain, SSH keys and cloud credentials. Clean it, change passwords from another device you trust, then revoke GitHub credentials; the steps in order are on how to check for an infostealer and GitHub account hacked. On a personal account you delete tokens and SSH keys one by one in GitHub settings, because the one-step "revoke all credentials" option is only for some enterprise accounts. Read the first step on that page before you revoke, because on an infected Mac a background process can react to a revoked token.

08A GitHub malware repository: what to remember

A GitHub malware repository works through files that run on their own, and you can read them in a couple of minutes. A scan covers only known samples, so read first and open unknown repos in isolation.

Artificial Immunity's free, open-source core watches VS Code tasks, git hooks, package scripts and program starts and reports what it finds.

FAQ

How to check a GitHub repo for malware?

Read the files that run on their own before you open or install anything: .vscode/tasks.json, package.json scripts, Xcode project files and, in a shared project folder, .git hooks. Then open the repo in an isolated environment.

How to scan a GitHub repo for malware?

A scan helps only against known samples. A Banshee variant stayed undetected by antivirus engines for over two months, and a DigitStealer sample was undetected at analysis time. Reading the auto-run files is the stronger check.

How to know if a GitHub repository is safe?

You cannot prove it, you can only reduce the risk: inspect and verify projects downloaded or cloned from repositories and review recruiter-provided repositories before running scripts.

Are GitHub files virus free?

No. Banshee spread through malicious GitHub repositories, and XCSSET spreads through compromised GitHub repositories disguised as legitimate tools.

What are the top 3 malware?

There is no official ranking. The families tied to GitHub repositories are Banshee, XCSSET and the backdoors planted through tasks.json files.

How do I run a scan for malware?

macOS includes XProtect, built-in antivirus technology for signature-based detection and removal of malware. Signatures describe known malware, so a new repo trick needs the manual checks above.

Sources

  1. Microsoft Security Blog, XCSSET
  2. Microsoft Security Blog, XCSSET evolves again
  3. Moonlock, XCSSET
  4. Microsoft Security Blog, Contagious Interview
  5. OpenSourceMalware, TasksJacker
  6. Check Point, Banshee stealer
  7. Jamf Threat Labs, DigitStealer
  8. VS Code docs, tasks
  9. VS Code docs, Workspace Trust
  10. npm docs, scripts and config
  11. Claude Code docs, MCP
  12. Malwarebytes, AMOS cleanup guidance
  13. Artificial Immunity
  14. Pro Git, Git hooks
  15. Cursor security notice, rotate from a trusted system
  16. GitHub docs, managing personal access tokens
  17. GitHub docs, reviewing your SSH keys
  18. GitHub docs, revoking your credentials
Cloning repos on the Mac where your agents work? Artificial Immunity watches VS Code tasks, git hooks and package scripts there.Get the free core