T09 · Insecure Skill Coding Practices
Error
- Location
- skills/smyx_common/scripts/util.py:572
- Finding
- Authentication Credentials Can Be Forwarded to Arbitrary HTTP(S) Destinations<![CDATA[ ## Vulnerability Details **File Location**: `skills/smyx_common/scripts/util.py`, lines 572–646 **Vulnerability Type**: Unrestricted credential forwarding and plaintext transport **Risk Level**: High ### Vulnerable Code ```python if not url.startswith("https://") and not url.startswith("http://"): url = cls.BASE_URL + url headers['App-Id'] = ConstantEnum.APP__ID # ConstantEnum.CURRENT__USER_NAME = ConstantEnum.CURRENT__OPEN_ID = "ou_86fdd8e0d5f116c18a9dd550abefe6d2" if not (ApiEnum.API_SECRET_KEY or ConstantEnum.CURRENT__USER_NAME or ConstantEnum.CURRENT__OPEN_ID): OpenIdUtil.resolve_current_open_id(use_current=False) 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 current__user_name = found_user.username 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") current_user_info = new_current_user.get("userInfo") if current_user_info: current_user_info["token"] = new_current_user.get("token") current_user_info["openToken"] = new_current_user.get( "openToken") user_model = User.load(current_user_info) user = user_dao.save( user_model ) except Exception as e: CommonUtil.trace_exception_stack(e) ...[truncated 3282 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Permit only relative API paths in the shared authenticated request wrapper. 2. Resolve relative paths against a fixed, trusted HTTPS origin. 3. If absolute URLs are operationally required, parse them with `urllib.parse.urlparse` and enforce an exact scheme, hostname, and port allowlist. 4. Reject plaintext HTTP, embedded credentials, protocol-relative URLs, loopback addresses, private-network addresses, and cloud metadata endpoints. 5. Attach authentication headers only after confirming that the final destination is a trusted origin. 6. Disable automatic cross-origin redirects or validate every redirect target before following it. 7. Separate authenticated API requests from generic unauthenticated URL retrieval. 8. Add tests proving that credentials are not attached to unapproved hosts or plaintext destinations. 9. Rotate any credentials that may already have been sent to an untrusted destination. ]]>
