T09 · Insecure Skill Coding Practices
- Location
scripts/feishu_bot_creator.py:15- Finding
Configurable API Base Allows Credential and Access-Token Exfiltration
- Content
View full analysis
Vulnerability Details
File Location:
scripts/feishu_bot_creator.py, lines 15 and 31–37; bearer tokens are subsequently transmitted using the same configurable base URL at lines 54–59, 89–94, and 113–118.
Vulnerability Type: Unrestricted sensitive-data transmission endpoint
Risk Level: HighVulnerable Code
python # Feishu API base URL FEISHU_API_BASE = os.environ.get("FEISHU_API_BASE", "https://open.feishu.cn")python def get_access_token(self): """Get access token""" url = f"{FEISHU_API_BASE}/open-apis/auth/v3/tenant_access_token/internal" payload = { "app_id": self.app_id, "app_secret": self.app_secret } response = requests.post(url, json=payload) data = response.json()Subsequent authenticated calls use the same unrestricted endpoint pattern:
python url = f"{FEISHU_API_BASE}/open-apis/application/v4/app/create" headers = { "Authorization": f"Bearer {self.access_token}", "Content-Type": "application/json" } response = requests.post(url, json=payload, headers=headers)Technical Analysis
The script must transmit the Feishu app ID and app secret to obtain a tenant access token, which is necessary for its declared functionality. However, the destination is controlled entirely through the
FEISHU_API_BASEenvironment variable.The code does not enforce HTTPS, validate the destination hostname, restrict the endpoint to an approved allowlist, or prevent requests to an attacker-controlled service. Consequently, a modified process environment can redirect the initial credential exchange to any HTTP or HTTPS server. The same configurable base is then used for API requests carrying a bearer token in the
Authorizationheader.The lack of explicit timeouts also permits an untrusted endpoint to leave the process blocked indefinitely. The
requestslibrary follows redirects by default, while the code does ...[truncated 1631 chars]- Remediation
View remediation
Remediation Suggestions
- Pin production requests to the official endpoint,
https://open.feishu.cn, instead of accepting an unrestricted environment variable. - If alternate endpoints are required for legitimate regional or testing deployments, parse the URL and enforce:
- The
httpsscheme. - An explicit allowlist of trusted hostnames.
- No embedded username or password.
- No unexpected ports.
- A fixed or validated path prefix.
- The
- Reject loopback, private-network, link-local, and metadata-service destinations unless a documented test mode explicitly requires them.
- Disable redirects for credential-bearing requests with
allow_redirects=False, or validate every redirect target against the same allowlist. - Add bounded connection and response timeouts, for example:
python response = requests.post( url, json=payload, timeout=(5, 30), allow_redirects=False, ) - Use a dedicated
requests.Sessionwith centralized endpoint validation so every authenticated request receives identical protections. - Document any supported endpoint override as a high-trust administrator setting rather than a normal user-controlled option.
- Pin production requests to the official endpoint,
