T09 · Insecure Skill Coding Practices
- Location
scripts/feishu_utils.py:12- Finding
TLS Certificate Verification Disabled for Credential-Bearing Feishu API Requests
- Content
View full analysis
Vulnerability Details
File Locations:
scripts/feishu_utils.py:12-29SKILL.md:41-60references/oauth.md:41-54references/drive.md:126-127
Vulnerability Type: CWE-295 — Improper Certificate Validation
Risk Level: HighVulnerable Code
scripts/feishu_utils.py:12-29:python def get_access_token(app_id, app_secret): url = 'https://open.feishu.cn/open-apis/auth/v3/tenant_access_token/internal' data = json.dumps({'app_id': app_id, 'app_secret': app_secret}).encode() req = urllib.request.Request(url, data=data, method='POST') req.add_header('Content-Type', 'application/json') ctx = ssl._create_unverified_context() with urllib.request.urlopen(req, context=ctx, timeout=10) as r: resp = json.loads(r.read()) return resp.get('tenant_access_token', '') def call_api(url, method, token, payload=None): ctx = ssl._create_unverified_context() data = json.dumps(payload, ensure_ascii=False).encode() if payload else None req = urllib.request.Request(url, data=data, method=method) req.add_header('Authorization', f'Bearer {token}') req.add_header('Content-Type', 'application/json') with urllib.request.urlopen(req, context=ctx, timeout=30) as r: return json.loads(r.read())SKILL.md:41-60:python def get_app_access_token(app_id, app_secret): url = 'https://open.feishu.cn/open-apis/auth/v3/tenant_access_token/internal' data = json.dumps({'app_id': app_id, 'app_secret': app_secret}).encode() req = urllib.request.Request(url, data=data, method='POST') req.add_header('Content-Type', 'application/json') ctx = ssl._create_unverified_context() with urllib.request.urlopen(req, context=ctx, timeout=10) as r: return json.loads(r.read()).get('tenant_access_token') def call_feishu_api(url, method, token, payload=None): ctx = ssl._create_unverified_context() da ...[truncated 4573 chars]- Remediation
View remediation
Remediation Suggestions
-
Remove every use of
ssl._create_unverified_context()from executable code and documentation. -
Use Python's default verified TLS behavior:
python with urllib.request.urlopen(req, timeout=10) as response: result = json.loads(response.read()) -
If an explicit context is required, create a verified default context:
python ctx = ssl.create_default_context() with urllib.request.urlopen(req, context=ctx, timeout=10) as response: result = json.loads(response.read()) -
Do not add a production configuration option that permits certificate verification to be disabled.
-
Restrict API URLs to the expected HTTPS origin, such as
https://open.feishu.cn, before attaching bearer tokens. This is particularly important for the genericcall_apifunction, which accepts a caller-supplied URL. -
Validate API responses and fail closed on TLS, HTTP, JSON, and Feishu API errors.
-
Update every example in
SKILL.md,references/oauth.md, andreferences/drive.mdso users do not copy insecure TLS handling into production code. -
Rotate the Feishu application secret and revoke active access and refresh tokens if the affected code has been used over an untrusted or intercepted network.
-
Review application scopes and retain only those required for the intended operation, especially Drive write access, permission administration, and Bitable deletion.
-
