- Location
- scripts/kalodata_video_search.py:36
- Finding
- Redirectable API Endpoints Can Exfiltrate Credentials and Authentication Data<![CDATA[
## Vulnerability Details
**File Location**: `scripts/kalodata_video_search.py:36-38, 58-76`; `scripts/kalodata_video_detail.py:36-38, 58-76`; `scripts/onboarding.py:76-85, 190-222, 378-421, 454-462`
**Vulnerability Type**: Credential disclosure through unvalidated, configurable network destinations
**Risk Level**: High
### Vulnerable Code
```python
def get_api_base() -> str:
"""Gateway base address: LINKFOX_TOOL_GATEWAY takes precedence."""
return (os.environ.get("LINKFOX_TOOL_GATEWAY")
or "https://tool-gateway.linkfox.com").rstrip("/")
def call_api(params):
api_url = get_api_url()
api_key = get_api_key()
data = json.dumps(params).encode("utf-8")
headers = {
"Authorization": api_key,
"Content-Type": "application/json",
"User-Agent": "LinkFox-Skill/2.0",
"SESSION_ID": os.environ.get("SESSION_ID", ""),
"MESSAGE_ID": os.environ.get("MESSAGE_ID", ""),
"MODE_ID": os.environ.get("MODE_ID", ""),
"APP_NAME": os.environ.get("APP_NAME", ""),
}
req = Request(api_url, data=data, headers=headers, method="POST")
```
The onboarding client uses the same pattern for more sensitive authentication operations:
```python
def _login_base() -> str:
return _env_base("LINKFOX_LOGIN_API_URL", "https://api.linkfox.com")
def _agent_user_base() -> str:
return _env_base("LINKFOX_AGENT_USER_API_URL",
"https://agent-api.linkfox.com")
def _http_post(url: str, body: dict, headers: dict, timeout: int = 30) -> dict:
try:
r = requests.post(url, json=body or {}, headers=headers, timeout=timeout)
return r.json()
```
### Technical Analysis
The destination hosts are selected from environment variables without enforcing HTTPS, validating the hostname, restricting ports, or applying an allowlist. Sensitive values are subsequently sent to the selected destinations.
The video clients send the LinkFox API key in the `Authorization` header. T
...[truncated 1552 chars]
- Remediation
- <![CDATA[
## Remediation Suggestions
- Pin production authentication and gateway traffic to approved HTTPS origins.
- Validate configured URLs with an explicit allowlist of scheme, hostname, port, and path prefix.
- Reject HTTP, embedded credentials, nonstandard ports, IP literals, and unapproved hosts.
- Disable endpoint overrides in production builds or require a separate explicit development-mode setting.
- Disable automatic redirects for credential-bearing requests, or verify that every redirect remains on the original approved origin.
- Never forward `Authorization`, OTPs, access tokens, or refresh tokens after a cross-origin redirect.
- Add automated tests proving that malicious environment-variable values are rejected before any request is sent.
- Rotate credentials if the scripts have been run in an environment where these variables may have been tampered with.
]]>