T09 · Insecure Skill Coding Practices
- Location
src/index.js:2- Finding
Hard-Coded Polygon API Credential
- Content
View full analysis
Vulnerability Details
File Location:
src/index.js:2, with credential use atsrc/index.js:27
Vulnerability Type: Hard-coded secret and credential exposure through a URL query parameter
Risk Level: MediumComplete Code Snippet:
js import https from 'https'; const POLYGON_API_KEY = 'QR_WJk5DtOe_UU7ARlvcAASbX4rkuJCS'; // ... const url = `https://api.polygon.io/v2/aggs/ticker/${ticker}/range/1/day/${from}/${to}?adjusted=true&sort=asc&limit=500&apiKey=${POLYGON_API_KEY}`; https.get(url, (res) => {Technical Analysis
A reusable Polygon API credential is embedded directly in distributable source code. Any person or process with access to the Skill package can recover the credential without invoking the Skill. The key is also placed in the request URL's query string. Although the request uses HTTPS, URLs may be recorded by application diagnostics, HTTP instrumentation, proxy logs, or monitoring systems.
The external request is necessary for the declared stock-market data functionality, and no unrelated sensitive information is transmitted. The vulnerability is therefore not the existence of the network request, but the insecure management and transmission of its credential.
Attack Path
- Obtain or inspect a copy of the Skill package.
- Open
src/index.jsand extract the value assigned toPOLYGON_API_KEY. - Submit independent requests to Polygon using the exposed key.
- Consume the credential owner's quota or use any data-access capabilities associated with the key until it is revoked, restricted, or exhausted.
- Alternatively, recover the query-string credential from any infrastructure that records complete outbound request URLs.
Impact Assessment
An attacker can authenticate to Polygon within the permissions and service limits assigned to the exposed key. Potential effects include unauthorized API usage, quota exhaustion, degraded availability for legitimate Skill re ...[truncated 317 chars]
- Remediation
View remediation
Remediation Suggestions
- Revoke and rotate the exposed Polygon API key immediately.
- Remove the credential from source code and version history.
- Load the replacement credential from a protected environment variable or secret manager, for example:
js const POLYGON_API_KEY = process.env.POLYGON_API_KEY; if (!POLYGON_API_KEY) { throw new Error('POLYGON_API_KEY is not configured'); } - Avoid placing credentials in URLs. Use an authorization header if Polygon supports one for the applicable API.
- Apply provider-side restrictions, including minimum required API permissions, rate limits, spending limits, and monitoring alerts.
- Ensure logs, traces, proxy telemetry, and error reports redact credentials and query parameters.
- Add automated secret scanning to source-control and release pipelines to prevent recurrence.
