T09 · Insecure Skill Coding Practices
- Location
scripts/seeker.js:4- Finding
Unrestricted API Base URL Exposes Tavily Credentials and Search Queries
- Content
View full analysis
Vulnerability Details
File Location:
scripts/seeker.js, lines 4 and 81–85
Vulnerability Type: Unvalidated credential-bearing endpoint configuration
Risk Level: HighVulnerable Code
js const BASE_URL = process.env.TAVILY_BASE_URL || "https://api.tavily.com";js const resp = await fetch(`${BASE_URL}/search`, { method: "POST", headers: { "Content-Type": "application/json", "Authorization": `Bearer ${apiKey}`, "X-Client-Source": "tavily-web-seeker" }, body: JSON.stringify(body), signal: AbortSignal.timeout(30000) });Technical Analysis
The
TAVILY_BASE_URLenvironment variable is used as the destination for API requests without validating its protocol, hostname, port, or origin. The resulting request includes a Tavily API key in theAuthorizationheader and the user's search query in the request body.Consequently, any party able to influence the process environment can redirect credential-bearing requests to an arbitrary endpoint. An
http://endpoint would also permit network interception because TLS is not required. This issue does not independently grant an external attacker control over the environment; exploitation requires prior influence over deployment configuration, process launch parameters, or another mechanism capable of setting the variable.Attack Path
- An attacker obtains the ability to modify the Skill's environment or deployment configuration.
- The attacker sets
TAVILY_BASE_URLto an HTTP or HTTPS server under their control. - A user invokes
webSeeker, causingsearchWithRetryto construct a request to the malicious base URL. - The request transmits the Tavily bearer token in the
Authorizationheader. - The request body also discloses the user's query, domain filters, result limits, search depth, and applicable time range.
- The attacker records the token and search data and may reuse the token against Tavily until it is revoked, expires, or reaches its usage limit.
...[truncated 738 chars]
- Remediation
View remediation
Remediation Suggestions
- Remove support for overriding the production endpoint if a custom Tavily endpoint is not operationally necessary.
- If endpoint customization is required, parse it with
URLand enforce all of the following before making a request:- The protocol must be
https:. - The hostname must match an explicit allowlist, preferably only
api.tavily.com. - User information in the URL must be prohibited.
- Unexpected ports, fragments, and path prefixes must be rejected.
- The protocol must be
- Compare the validated destination origin against the trusted Tavily origin before adding the
Authorizationheader. Never send credentials across redirects or to a different origin. - Configure the HTTP client to reject cross-origin redirects, or disable redirects and handle only explicitly approved same-origin redirects.
- Store endpoint configuration in trusted, access-controlled deployment settings rather than accepting an unrestricted process environment value.
- Rotate all API keys if there is evidence that the base URL was previously redirected or that requests were sent over plaintext HTTP.
- Add automated tests verifying that HTTP URLs, lookalike domains, embedded credentials, alternate ports, and unapproved hosts are rejected before any request containing an API key is sent.
