T09 · Insecure Skill Coding Practices
- Location
python/template.py:57- Finding
Hardcoded Eastmoney API Credential Exposed in Source and Metadata
- Content
View full analysis
Vulnerability Details
File Location:
python/template.py:57-67; duplicated inskill.yaml:12-16
Vulnerability Type: Hardcoded reusable API credential
Risk Level: HighVulnerable Code
python/template.py:57-67:python api_key = "mkt_HFeitkf4UQNDF8rpr6wZMVfweIxmPegsR1jJK0kF0_I" url = "https://mkapi2.dfcfs.com/finskillshub/api/claw/query" payload = { "toolQuery": json.dumps({ "func": "get_quote_list_ts", "params": [symbols, 1] }) } headers = {"Content-Type": "application/json", "apiKey": api_key} resp = requests.post(url, json=payload, headers=headers, timeout=15)skill.yaml:12-16:yaml token_required: - name: "东方财富MX API" key: "mkt_HFeitkf4UQNDF8rpr6wZMVfweIxmPegsR1jJK0kF0_I" usage: "A股/港股/美股实时行情查询"Technical Analysis
A reusable Eastmoney MX API credential is embedded directly in both executable source code and public Skill metadata. Any person or process that can read, clone, cache, package, or inspect the Skill can recover the credential without authorization.
The implementation automatically places the credential in the
apiKeyHTTP header and sends it to the documented HTTPS endpoint. Transmitting an API credential to its intended provider is necessary for authenticated market-data access, but distributing the provider credential inside the Skill is not necessary and violates least-secret-exposure principles.The stock-symbol query supplied through
symbolsis also transmitted to Eastmoney. That transmission is consistent with the declared financial-data functionality, and the reviewed code does not collect environment variables, private keys, local files, or unrelated user information.Attack Path
- An attacker obtains the Skill package or reads its repository, installation directory, package cache, or generated metadata.
- The attacker extracts the plaintext token from
skill.yamlor `python/template.p ...[truncated 933 chars]
- Remediation
View remediation
Remediation Suggestions
- Immediately revoke and rotate the exposed Eastmoney API token.
- Remove the token from
python/template.py,skill.yaml, repository history, release archives, caches, and published Skill packages. - Require each user to supply a separately issued credential through an environment variable or supported secret manager:
python import os api_key = os.environ.get("EASTMONEY_API_KEY") if not api_key: raise RuntimeError("EASTMONEY_API_KEY is not configured") - Do not place secret values in Skill metadata. Metadata should declare only the required secret name.
- Apply server-side least privilege, endpoint restrictions, quota limits, expiration, and rotation policies to replacement credentials.
- Avoid logging request headers or exception objects that could expose the token.
- Add automated secret scanning to development and release workflows.
- Clearly disclose that stock symbols and related query parameters are sent to Eastmoney when this function is invoked.
