T09 · Insecure Skill Coding Practices
- Location
scripts/generate_deep_research_report.py:111- Finding
API Credential Exposure Through Unrestricted Redirect Following
- Content
View full analysis
Vulnerability Details
File Location:
scripts/generate_deep_research_report.py, lines 111-119
Vulnerability Type: Credential disclosure through unsafe redirect handling
Risk Level: Mediumpython async with httpx.AsyncClient(timeout=REPORT_TIMEOUT, follow_redirects=True) as client: resp = await client.post( FIRST_COVERAGE_URL, json={"query": query}, headers={ "Content-Type": "application/json", "em_api_key": EM_API_KEY, }, ) resp.raise_for_status()Technical Analysis
The HTTP client automatically follows redirects while the request contains the sensitive
EM_API_KEYvalue in the customem_api_keyheader. Custom authentication headers do not necessarily receive the same cross-origin stripping protections as standardized authorization headers.If the fixed Eastmoney endpoint is compromised or misconfigured to return a redirect to another origin, the client may propagate the custom header to the redirected destination. The user-provided query may also be transmitted to that destination, depending on the redirect status and resulting request behavior.
The initial endpoint uses HTTPS and is statically configured, which limits exploitation to circumstances where the service, its infrastructure, or its redirect behavior can be influenced. Nevertheless, unrestricted redirect handling creates an avoidable credential-disclosure boundary.
Attack Path
- An attacker compromises the configured API service, an upstream component, or otherwise gains influence over its HTTP redirect response.
- The endpoint returns a redirect to an attacker-controlled HTTPS origin.
- Because
follow_redirects=True, the client automatically follows the redirect. - The custom
em_api_keyheader may be propagated to the redirected destination. - The attacker captures the API credential and potentially the user's research query.
- The ...[truncated 525 chars]
- Remediation
View remediation
Remediation Suggestions
- Disable automatic redirect following by setting
follow_redirects=False. - If redirects are operationally required, process each redirect manually and require:
- The
httpsscheme. - An exact hostname and port allowlist.
- No HTTPS-to-HTTP downgrade.
- A bounded number of redirects.
- The
- Never forward
em_api_keyto a destination whose origin differs from the configured API origin. - Reconstruct redirected requests explicitly rather than reusing credential-bearing headers.
- Consider using a standardized authorization mechanism if supported by the service.
- Add tests that simulate same-origin and cross-origin redirects and verify that credentials are never sent to an unapproved origin.
- Disable automatic redirect following by setting
