T09 · Insecure Skill Coding Practices
- Location
scripts/gitea_api.py:38- Finding
Site-Administrator Token Is Transmitted Over Plaintext HTTP
- Content
View full analysis
dict: return {"Authorization": f"token {ADMIN_TOKEN}", "Content-Type": "application/json"} def api(method: str, path: str, *, json_body: dict | None = None, params: dict | None = None, ok: tuple[int, ...] = (200, 201, 204)): if not GITEA_URL: raise GiteaError("GITEA_URL is not configured") resp = requests.request( method, f"{GITEA_URL}/api/v1{path}", headers=headers(), json=json_body, params=params, timeout=30, ) ``` ### Technical Analysis The example configuration specifies a public IP address using unencrypted HTTP. `setup.sh` copies this example into `.env` when no configuration exists, and every Gitea API request places `GITEA_ADMIN_TOKEN` in the `Authorization` header. HTTP provides neither transport confidentiality nor server authentication. An attacker positioned on the client network, gateway, hosting network, or another part of the routing path can inspect the bearer token. An active man-in-the-middle attacker can also modify requests and responses. Because the credential is a bearer token, possession is sufficient for reuse; the attacker does not need the administrator's password. ### Attack Path 1. An operator runs `setup.sh`, which copies `env-example.txt` to `.env`. 2. The operator supplies a site-administrator token but leaves the example HTTP endpoint unchanged. 3. Any initialization or repository-management command invokes `gitea_api.api()`. 4. The token is transmitted in an HTTP `Authorization` header. 5. A network-path attacker captures the request. 6. The attacker reuses the token against the Gitea API to perform administrator-authorized o ...[truncated 358 chars]- Remediation
View remediation
