For: indie developers and small operators wary of GitHub's "accidental public repo" and secret-leak incidents, weighing whether to run a self-hosted Git server (bare git, or Gitea/Forgejo/GitLab). No attack steps here — just the decision of which is safer for your setup.
This site's view: self-hosting only works if you take over what GitHub did
This site itself runs a self-hosted Git server. But the reason isn't only "accidental exposure is scary" — it's separating the scope of impact: one compromised service must not cascade to others. And because we self-host, we always bundle in offsite backups to a separate server, never putting secrets in git, and automated dependency CVE monitoring. Self-hosting's safety comes not from "not using GitHub" but from doing yourself the work GitHub used to do.
1. What self-hosting genuinely removes
Your worry has a valid basis. GitHub's classic "public incidents" simply can't happen on a self-hosted server.
Public repos are continuously crawled by automated scanning bots. Commit an .env or an API key by mistake and bots pick it up before a human notices — exploited within minutes is common (real cases → a key leaked via a public repo and billed for fraud · an entire .env exposed). Self-hosting removes that public surface. "Meant to be private but was public," "a secret you thought you deleted lingering in a public fork" — those classes can't occur by design. That isn't a vague comfort; it's a real advantage.
2. The work you take on when you self-host
This is the crux. GitHub handled a lot of defense for you by default, out of sight. Self-host and those defenses don't exist unless you build them.
GitHub handled this
- Blocks secret commits (push protection)
- Auto dependency CVE alerts (Dependabot)
- Server operation, patching, TLS
- 2FA, fine-grained access, audit logs
- High availability, redundant backups
Now it's your job
- Add a pre-commit secret-detection hook
- Run dependency CVE monitoring yourself (cron)
- Patch the Git server's own vulnerabilities
- Key management = effectively all access control
- Lost data stays lost unless you prepare a restore
Two are especially easy to miss. First, a paradox: the secret leak you fear most is something GitHub actually stops for you, by machine. GitHub's push protection rejects commits containing what looks like an API key. A bare self-hosted git has no such check. Accidental exposure is gone, but the accidental commit isn't — so if you self-host, a pre-commit secret hook is mandatory.
Second, the Git server itself becomes a target. Feature-rich servers like GitLab have had multiple serious vulnerabilities (unauthenticated remote code execution, i.e. RCE-class), and an unpatched self-hosted server becomes the way in. More features, more attack surface. Plain bare git + SSH has the smallest surface; GitLab/Gitea are convenient but add the burden of chasing patches yourself.
3. How to make self-hosting safer than GitHub
The minimum set that makes self-hosting genuinely — not cosmetically — safe. Only with these is "safer than GitHub" true.
Stop secrets before the commit
Minimize and patch the Git server
Offsite backups + a tested restore
Separate keys, least privilege, non-root
Run dependency CVE monitoring yourself
4. Which should you choose?
Self-host isn't "pro" and GitHub isn't "amateur." Decide on whether you can keep operating it.
Self-host fits (if you meet the bar)
- you want to remove the public-exposure surface itself
- you can keep patching and backing up the server
- you don't want code held by a third party / you want to limit the scope of impact
- you can adopt the secret hook and dependency monitoring as a bundle
GitHub can be safer
- no capacity to keep patching/backing up → a neglected self-host is the most dangerous
- you want to lean on push protection / Dependabot auto-defense
- you can't provide availability / redundant backups yourself
- you can rigorously manage private repos (exposure is preventable by discipline)
In short, self-hosting means taking on the work GitHub was doing for you. Take it on and do it, and you remove a large incident class. Take it on and neglect it, and you can end up worse than GitHub: an unpatched server, a mis-committed secret, and a backup you can't restore. And supply-chain poisoning (like the xz-utils backdoor) is defended by continuous dependency monitoring wherever your code lives.
What this site does itself
This site runs a self-hosted Git server (plain bare git + SSH) and wires it so that every push is also copied to a backup on a separate server. Secrets (keys, passwords, connection strings) never go into git or docs, and dependency CVE monitoring runs via pnpm audit before every deploy and daily. "Not using GitHub" is not the goal — removing the accidental-exposure class while doing yourself all the work GitHub used to do is. Only doing both makes self-hosting safe.
Read next
-
A live example: GitLab CVE-2026-110264 (CVSS 10.0) (checking and updating a self-managed GitLab)
-
A live example: CVE-2026-60004 (code injection in Gitea) (running it yourself comes with updating it yourself)
-
Glossary: .env files and secrets
-
Incidents: a key leaked via a public repo · an entire .env exposed
-
Stacks: machine-monitor dependency CVEs with osv-scanner · not falling behind on CVEs
-
Supply chain: when one npm install empties your credentials (how private repos get copied public, and why token scope decides it)