T09 · Insecure Skill Coding Practices
- Location
scripts/osint_api.py:37- Finding
Bearer API Key May Be Forwarded During Cross-Origin Redirects
- Content
View full analysis
Vulnerability Details
File Location:
scripts/osint_api.py, lines 37–49
Vulnerability Type: Authorization credential exposure through unrestricted redirects
Risk Level: Mediumpython def make_request(method, path, data=None): """Make an authenticated HTTPS request to the OSINT API.""" url = f"{BASE_URL}{path}" body = None headers = { "Content-Type": "application/json", "Authorization": f"Bearer {API_KEY}", } if data: body = json.dumps(data).encode("utf-8") req = Request(url, data=body, headers=headers, method=method) try: with urlopen(req, timeout=30) as resp:Technical Analysis
The request attaches
OSINT_API_KEYas a bearer credential and passes the request to Python'surllib.request.urlopen. The standard URL opener automatically processes HTTP redirects, but this implementation does not validate each redirect destination, enforce the documented hostname on the final URL, or explicitly remove theAuthorizationheader when an origin changes.Consequently, a redirect issued by the configured API service could cause the client to forward the authenticated request to an unintended host. Exploitation requires control or compromise of the API service, its redirect-producing infrastructure, or an equivalent trusted TLS termination point. Ordinary network interception is constrained by HTTPS certificate validation.
This behavior exceeds the documented network boundary that requests and credentials are sent only to
osint.ahsan-tariq-ai.xyz.Attack Path
- A user configures a valid
OSINT_API_KEYand invokes the helper. - The helper sends an authenticated request to the declared API host.
- An attacker who controls or has compromised the API endpoint returns an HTTP redirect to an attacker-controlled HTTPS origin.
- The client automatically follows the redirect without checking that the hostname remains ...[truncated 705 chars]
- A user configures a valid
- Remediation
View remediation
Remediation Suggestions
- Disable automatic redirect handling for authenticated requests, or use a custom
HTTPRedirectHandler. - Before following a redirect, parse and normalize the destination URL and require:
- The scheme to be exactly
https. - The hostname to be exactly
osint.ahsan-tariq-ai.xyz. - The port to be the expected HTTPS port.
- The scheme to be exactly
- Remove the
Authorizationheader whenever the scheme, hostname, or port changes. - Apply a small redirect limit to prevent redirect loops.
- Consider rejecting redirects entirely because the API has one fixed, documented origin.
- Add automated tests covering same-origin redirects, cross-origin redirects, scheme downgrades, and credential-header removal.
- Disable automatic redirect handling for authenticated requests, or use a custom
