- Location
- scripts/sellersprite_market_research.py:36
- Finding
- Credential-Bearing Requests Can Be Redirected to Arbitrary Endpoints<![CDATA[
## Vulnerability Details
**File Location**: `scripts/sellersprite_market_research.py:36-76`; related onboarding destinations at `scripts/onboarding.py:76-85, 231-244, 404-405, 419-421, 458-459`
**Vulnerability Type**: Unvalidated credential destination override
**Risk Level**: High
### Vulnerable Code Snippet
```python
def get_api_base() -> str:
"""Gateway base address: environment override, otherwise production."""
return (os.environ.get("LINKFOX_TOOL_GATEWAY")
or "https://tool-gateway.linkfox.com").rstrip("/")
def get_api_url():
sys.path.insert(
0,
os.path.join(
os.path.dirname(os.path.abspath(__file__)),
"..",
"..",
"_shared",
),
)
return get_api_base() + API_PATH
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",
)
```
Onboarding applies the same pattern to more sensitive authentication flows:
```python
def _agent_base() -> str:
return _env_base(
"LINKFOX_AGENT_API_URL",
"https://tool-gateway.linkfox.com",
"LINKFOX_TOOL_GATEWAY",
)
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",
)
```
Credential-bearing requests include:
```python
resp = _http_post(f"{_agent_user_base()}/a
...[truncated 2349 chars]
- Remediation
- <![CDATA[
## Remediation Suggestions
1. Enforce `https://` for every credential-bearing endpoint.
2. Apply an explicit allowlist containing only the expected LinkFox hostnames.
3. Reject URLs containing user information, unexpected ports, fragments, or non-HTTPS schemes.
4. Disable custom origins in production. If overrides are needed for development, require an explicit development flag and separate non-production credentials.
5. Validate the final URL after parsing and before constructing the request.
6. Remove `MESSAGE_ID`, `MODE_ID`, `APP_NAME`, and other metadata unless each field has a documented operational requirement and user consent.
7. Use short-lived, narrowly scoped tokens and rotate any credentials that may have been used with an untrusted endpoint.
]]>