← Sanil Dulal

June 2026 · 5 min read

The line of code that trusted everyone

How one hardcoded flag in Gitea — InsecureSkipVerify: true, sitting untouched since 2017 — could hand an attacker the keys to the whole internal API. The story behind my Gitea security advisory, GHSA-94v3-77j7-vm48.

affected
Gitea ≤ 1.26.4
fixed in
1.27.0
weakness
CWE-295 · Improper certificate validation
severity
7.5 High · CVSS 3.1 (CISA)

I have a habit that some people find boring and I find meditative: I read source code the way other people read the news. No fuzzer, no scanner, no running instance — just me, a repository, and the quiet suspicion that somewhere in all those files, someone wrote something they meant to fix later and never did.

That's how I ended up staring at a single line in Gitea, the self-hosted Git service that thousands of teams run to host their code. The line was in modules/private/internal.go, the HTTP client Gitea uses to talk to its own internal API. And it said this:

TLSClientConfig: &tls.Config{ InsecureSkipVerify: true }

If you've written Go, you know exactly what that flag does. It tells the TLS stack to stop checking whether the certificate on the other end of the connection is actually valid. Any certificate. Self-signed, wrong hostname, issued by nobody in particular — it doesn't matter. The client shrugs and trusts it. It's the digital equivalent of a bouncer who waves everyone through as long as they're holding something roughly the shape of an ID.

What made me sit up wasn't just the flag. It was the inconsistency. I went looking, and every other outbound TLS client in the entire codebase was secure by default and configurable — webhooks, migrations, MinIO storage, LDAP, SMTP, Redis, incoming mail. Every single one gave the operator a SkipTLSVerify toggle that defaulted to safe. This one client, the internal API, was the lone exception: hardcoded insecure, with no way to turn it off. That kind of asymmetry is usually where the bugs live.

So I traced it. If InsecureSkipVerify is only dangerous when the connection actually crosses a network, the real question was: does Gitea ever send this traffic somewhere an attacker could sit in the middle? The default deployment runs everything on one host over loopback, so the answer there is basically no — the traffic never leaves the machine.

But Gitea supports split-host setups. When an operator sets LOCAL_ROOT_URL to an https:// address pointing at a non-loopback target — the kind of thing you do in a multi-pod or separate-SSH-host topology — those internal calls go out over the actual network. And here's the part that took a while to piece together: the calls aren't made by the main server process at all. When you do a Git operation over SSH, Gitea execs a separate subprocess — gitea serv or gitea hook — and that subprocess calls back to the internal API over the network hop.

On every one of those requests, it sends a header: X-Gitea-Internal-Auth: Bearer <INTERNAL_TOKEN>. That token is the single, static credential that guards every internal endpoint. Not some low-value thing either — the internal API can shut down and restart the server, authorize SSH keys, execute git commands, control repository hooks, send mail as Gitea, and mint Actions runner tokens. It's the crown jewels. And the server-side check for it is a plain constant-time string comparison and nothing else. The code even carries a TODO admitting the weakness: 'use something like JWT or HMAC to avoid passing the token in the clear.'

So the whole chain lines up. Insecure TLS client, plus network hop, plus a high-privilege static token sent on every request. An attacker with an on-path position on that internal segment — ARP spoofing on a shared network, a malicious sidecar in the same cluster, DNS or route manipulation — can present any certificate they like. The client trusts it, completes the handshake, and hands over the INTERNAL_TOKEN in the clear. Game over.

To prove it wasn't theoretical, I built the real path rather than a toy demo. It's tempting to write a five-line Python script that accepts a self-signed cert and call it a day, but that only restates what the flag already means — it doesn't involve Gitea at all. Instead, I configured an instance with LOCAL_ROOT_URL pointed at an interceptable HTTPS target, stood up a rogue TLS listener presenting a throwaway self-signed certificate, and logged the auth header. Then I triggered a genuine internal call by doing an SSH git clone against the instance. sshd execs gitea serv, which dutifully calls the internal API — and my listener printed the line I was hoping for: [!] CAPTURED TOKEN.

The last step was confirming the token was as powerful as I thought. I replayed it straight against the Gitea HTTP port at /api/internal/manager/processes and got a 200 with live process data back. That same token also reaches the shutdown endpoint, the SSH key authorization endpoint, the serv command endpoint. Full internal-API access from one intercepted request.

There's a second, quieter aggravating factor I found along the way: the internal routes are mounted on the main public listener, not a locked-down loopback-only socket. So a stolen token isn't just usable during the man-in-the-middle — it's replayable afterward by anyone who can reach the Gitea HTTP port.

I reported it privately through GitHub's security advisory process rather than filing a public issue, because responsible disclosure matters when there's a real impact window. I wrote up the summary, the affected component, the verified exploit chain against a specific commit, a working proof of concept, and an honest severity breakdown — High for the split-host HTTPS deployments that are genuinely exposed, Low or informational for the default single-host setup where the call never leaves the box. Overstating severity helps no one and burns trust with maintainers; being precise about when it does and doesn't matter is part of the job.

It became advisory GHSA-94v3-77j7-vm48, and I'm credited as the reporter. The root cause turned out to be almost poetic in its ordinariness: that InsecureSkipVerify line had been sitting in the codebase since 2017, introduced in an old pull request and quietly carried forward through every release for the better part of a decade. Not obfuscated. Not clever. One readable line in an open-source project that thousands of people have looked at.

That's the thing I keep coming back to. The scary vulnerabilities aren't always the exotic ones. Sometimes it's a single boolean that everyone assumed someone else had already checked — a piece of TODO-shaped tech debt that had every opportunity to be fixed and simply never was. My whole contribution was noticing it was still there, and taking the time to prove why it mattered.