T09 · Insecure Skill Coding Practices
- Location
scripts/utils.py:47- Finding
Authorization Token and Sensitive Query Disclosure Through Configurable API Origins
- Content
View full analysis
Vulnerability Details
File Location:
scripts/utils.py:47-55,scripts/kb.py:70-81,scripts/get_file.py:54-101
Vulnerability Type: Unvalidated configurable network destination receiving authorization credentials
Risk Level: HighVulnerable Code
python GANGTISE_DATA_DOMAIN = os.getenv( "GANGTISE_DOMAIN", "https://open.gangtise.com/application/open-data" ) GANGTISE_INSIGHT_DOMAIN = os.getenv( "GANGTISE_INSIGHT_DOMAIN", "https://open.gangtise.com/application/open-insight" ) RAG_URL = f"{GANGTISE_DATA_DOMAIN}/ai/search/knowledge_base" FILE_URL = f"{GANGTISE_DATA_DOMAIN}/ai/resource/download" SUMMARY_DOWNLOAD_URL = f"{GANGTISE_INSIGHT_DOMAIN}/summary/v2/download/file" COMPANY_ANNOUNCEMENT_DOWNLOAD_URL = f"{GANGTISE_INSIGHT_DOMAIN}/announcement/download/file" REPORT_DOWNLOAD_URL = f"{GANGTISE_INSIGHT_DOMAIN}/broker-report/download/file" FOREIGN_REPORT_DOWNLOAD_URL = f"{GANGTISE_INSIGHT_DOMAIN}/foreign-report/download/file"The search endpoint is subsequently given the bearer token and user query:
python headers = { "Authorization": GTS_AUTHORIZATION, } payload = { "query": query, "startTime": datetime.datetime.strptime(start_date, "%Y-%m-%d").timestamp() * 1000 if start_date else None, "endTime": datetime.datetime.strptime(end_date, "%Y-%m-%d").timestamp() * 1000 if end_date else None, "resourceTypes": [FILE_TYPE_MAP[file_type] for file_type in file_types] if file_types else None, "top": limit, } response = requests.post(RAG_URL, headers=headers, json=payload, timeout=300)Download endpoints receive the same token:
python headers = { "Authorization": GTS_AUTHORIZATION, } # ... if file_type in url_map: response = requests.get( url_map[file_type], headers=headers, params=params_map[file_type], timeout=300, ) else: params = { "sou ...[truncated 2468 chars]- Remediation
View remediation
Remediation Suggestions
- Pin API origins to the documented Gangtise HTTPS endpoints whenever custom deployments are not explicitly required.
- If endpoint configuration is necessary, parse each URL with
urllib.parse.urlparseand enforce:- The
httpsscheme. - An exact allowlist of approved hostnames.
- An expected port.
- No embedded username or password.
- An approved base path.
- The
- Reject IP literals, loopback addresses, link-local addresses, and unexpected subdomains unless explicitly required and approved.
- Disable redirects for credential-bearing requests or validate every redirect destination before following it.
- Do not forward the
Authorizationheader across origins. - Use short-lived, narrowly scoped tokens and revoke potentially exposed tokens.
- Add tests proving that arbitrary HTTP origins, lookalike domains, and cross-origin redirects are rejected.
- Avoid including sensitive server response bodies in user-facing error messages.
