T09 · Insecure Skill Coding Practices
- Location
scripts/shareholder.py:17- Finding
User-Controlled API Origin Can Receive the Gangtise Authorization Token
- Content
View full analysis
Vulnerability Details
File Location:
scripts/shareholder.py:17-20, 133-146, 184
Vulnerability Type: Authorization token disclosure through an unvalidated, environment-controlled API origin
Risk Level: MediumVulnerable Code
python GANGTISE_FUNDAMENTAL_DOMAIN = os.getenv( "GANGTISE_DOMAIN", "https://open.gangtise.com/application/open-fundamental" ) TOP_HOLDERS_URL = f"{GANGTISE_FUNDAMENTAL_DOMAIN}/capital-structure/top-holders"python payload = { "securityCode": security_code, "holderType": holder_type, "period": period or ["latest"], } if start_date: payload["startDate"] = start_date if end_date: payload["endDate"] = end_date if fiscal_year: payload["fiscalYear"] = fiscal_year try: r = requests.post(TOP_HOLDERS_URL, headers=headers, json=payload, timeout=120)python headers = {"Authorization": GTS_AUTHORIZATION}Technical Analysis
The shareholder API origin is read from the
GANGTISE_DOMAINenvironment variable without validating its scheme or hostname. The resulting URL is subsequently used for an HTTP request carryingGTS_AUTHORIZATIONin theAuthorizationheader.This differs from the other audited API destinations, which are fixed to the documented
https://open.gangtise.comservice. The Skill documentation does not declare a requirement to contact arbitrary API origins, so this override exceeds the minimum network privileges needed for the stated functionality.An attacker who can influence the process environment does not need to modify the Skill files. By setting
GANGTISE_DOMAINto an attacker-controlled server, the attacker can cause the legitimate shareholder command to transmit the bearer token and query parameters to that server. HTTPS does not mitigate this issue when the attacker controls a valid HTTPS endpoint.Attack Path
- The attacker influences the environment used to launch the Skill, such as a shell profile, deployment manifest, wrapper, CI ...[truncated 1321 chars]
- Remediation
View remediation
Remediation Suggestions
- Remove the undocumented environment override and define the endpoint as a fixed official URL:
python GANGTISE_FUNDAMENTAL_DOMAIN = ( "https://open.gangtise.com/application/open-fundamental" )-
If alternate endpoints are genuinely required, parse and validate the URL before use:
- Require the
httpsscheme. - Require an exact hostname from a small explicit allowlist.
- Reject embedded credentials, unexpected ports, IP literals, redirects to other hosts, and hostname suffix tricks.
- Maintain separate credentials for production, staging, and development.
- Require the
-
Do not attach a production authorization header unless the final destination has passed validation.
-
Disable automatic redirects for authenticated requests or revalidate every redirect destination before forwarding credentials:
python r = requests.post( TOP_HOLDERS_URL, headers=headers, json=payload, timeout=120, allow_redirects=False, )-
Apply the same centralized endpoint validation policy to every authenticated network request in the Skill.
-
Rotate or revoke affected tokens if the Skill has run in an environment where
GANGTISE_DOMAINmay have been modified, and review API access logs for requests from unexpected clients or locations.
