T09 · Insecure Skill Coding Practices
Error
- Location
- skills/smyx_common/scripts/util.py:296
- Finding
- Silent Registration Discloses API Keys or User Identifiers as Phone and Identity Data<![CDATA[ ## Vulnerability Details **File Location**: `skills/smyx_common/scripts/util.py:296-307, 322-342`; related identity instructions in `SKILL.md:49-56` **Vulnerability Type**: Credential and personal identifier disclosure through identity-field confusion **Risk Level**: High ### Vulnerable Code ```python def _get_or_create_user(username): _url = ApiEnum.BASE_URL_HEALTH + "/sys/phoneLogin" open_id = username _data = { "silent": 1, "register": 1, "openId": open_id, "mobile": username, "source": ConstantEnum.DEFAULT__SKILL_HUB_NAME } try: _response = requests.post(_url, json=_data) if _response.status_code == 200: _response_json = _response.json() if _response_json and _response_json.get("success"): return _response_json and _response_json.get("result") except Exception as _e: CommonUtil.trace_exception_stack(_e) return {} ``` ```python current__user_name = ApiEnum.API_SECRET_KEY or ConstantEnum.CURRENT__USER_NAME or ConstantEnum.CURRENT__OPEN_ID found_user = None if (not ApiEnum.TOKEN or not ApiEnum.OPEN_TOKEN) and current__user_name: try: from .dao import UserDao, User user_dao = UserDao() found_user = user_dao.get_by_username(current__user_name) if found_user: ApiEnum.TOKEN = found_user.token ApiEnum.OPEN_TOKEN = found_user.open_token if not ApiEnum.TOKEN or not ApiEnum.OPEN_TOKEN: new_current_user = _get_or_create_user(current__user_name) if new_current_user: ApiEnum.TOKEN = new_current_user.get("token") ApiEnum.OPEN_TOKEN = new_current_user.get("openToken") ``` ### Technical Analysis The request layer conflates three security domains: 1. An API secret used for service authentication. 2. A platform or application user identifier. 3. A telephone number submitted through the `mobile` field. `ApiEn ...[truncated 2090 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Remove `ApiEnum.API_SECRET_KEY` from identity selection. Maintain separate, strongly typed fields for API credentials, open-id values, usernames, and phone numbers. 2. Never submit a credential in `openId`, `mobile`, username, or other identity fields. 3. Require explicit user consent before account registration. Replace silent registration with a documented authentication flow. 4. Send only the minimum identifier required by the service. Do not duplicate a value into both `openId` and `mobile`. 5. Validate phone numbers and open-id values according to separate schemas before transmission. 6. Clearly disclose the destination host, purpose, fields transmitted, retention policy, and account-creation behavior. 7. Add a bounded timeout and explicit TLS verification policy to the registration request. 8. Where possible, use a scoped, short-lived authorization token issued through the platform rather than collecting usernames or phone numbers. 9. Add tests proving that API keys can never reach identity or profile endpoints. ]]>
