T09 · Insecure Skill Coding Practices
- Location
scripts/gitverse.py:11- Finding
Bearer Token Disclosure Through an Unrestricted API Base URL
- Content
View full analysis
Vulnerability Details
File Location:
scripts/gitverse.py, lines 11 and 28–33
Vulnerability Type: Unvalidated credential-bearing network destination
Risk Level: HighVulnerable Code
python BASE_URL = os.environ.get("GITVERSE_BASE_URL", "https://api.gitverse.ru")python def request(method, path, body=None): url = BASE_URL + path data = json.dumps(body).encode() if body is not None else None req = urllib.request.Request(url, data=data, method=method) req.add_header("Authorization", "Bearer " + get_token()) req.add_header("Accept", ACCEPT) req.add_header("Content-Type", "application/json") try: with urllib.request.urlopen(req) as resp:Technical Analysis
The application accepts
GITVERSE_BASE_URLwithout validating its scheme, hostname, port, or trust relationship. Therequest()function then unconditionally attaches the GitVerse bearer token to requests sent to that destination.Consequently, an attacker who can influence the process environment or persuade a user to configure a malicious base URL can redirect authenticated requests to an attacker-controlled server. For example, setting
GITVERSE_BASE_URLtohttps://attacker.examplecauses any subsequent command to transmit the token in theAuthorizationheader to that server. Anhttp://URL can also transmit the credential without transport encryption.The use of
urllib.request.urlopen()additionally provides no application-level restriction preventing authenticated requests from following redirects to an untrusted origin.Attack Path
- The attacker controls or influences
GITVERSE_BASE_URL, such as through a launcher, shell configuration, CI environment, or untrusted setup instructions. - The value is set to an attacker-controlled HTTPS endpoint or a plaintext HTTP endpoint.
- The user invokes any CLI operation, including a read-only command such as `repos lis ...[truncated 1025 chars]
- The attacker controls or influences
- Remediation
View remediation
Remediation Suggestions
- Parse the configured URL with
urllib.parse.urlsplit()and require thehttpsscheme. - Restrict credential-bearing requests to an explicit allowlist, using
api.gitverse.ruby default. - If private GitVerse deployments must be supported, require users to register trusted hosts explicitly rather than accepting an unrestricted environment override.
- Reject URLs containing unexpected user information, fragments, ports, or malformed hostnames.
- Disable automatic redirects or implement a redirect handler that rejects every cross-origin redirect before resending an authorization header.
- Build URLs from validated components rather than concatenating an unrestricted base string with a path.
- Display a clear warning and require explicit confirmation before sending credentials to a newly configured host.
- Use narrowly scoped, short-lived tokens so that disclosure has limited impact.
- Document that any configured API server receives the bearer token.
- Add tests covering HTTP destinations, unapproved hosts, hostname-confusion inputs, and cross-origin redirects.
- Parse the configured URL with
