T09 · Insecure Skill Coding Practices
Warning
- Location
- scripts/geekbi_auth.py:66
- Finding
- Bearer Tokens Are Replicated Across Multiple Local Trust Boundaries<![CDATA[ ## Vulnerability Details **File Locations**: - `scripts/geekbi_auth.py:66-87` - `scripts/geekbi_auth.py:371-380` - `scripts/geekbi_auth.py:637-648` **Vulnerability Type**: Excessive credential storage and cross-workspace token exposure **Risk Level**: Medium ### Vulnerable Code ```python def _user_config_state_path(): return _absolute_path( user_config_path("GeekBI", appauthor=False, ensure_exists=True) / "temu-research-skill" / AUTH_FILE_NAME ) def _skill_state_path(): return _absolute_path(Path(__file__).parent.parent / AUTH_STATE_DIR / AUTH_FILE_NAME) def _workspace_state_path(): return _absolute_path(Path(os.getcwd()) / AUTH_STATE_DIR / AUTH_FILE_NAME) def _resolve_stores(): candidates = ( ResolvedStore(_user_config_state_path(), "user-config-directory"), ResolvedStore(_skill_state_path(), "skill-directory"), ResolvedStore(_workspace_state_path(), "working-directory"), ) ``` ```python def _write_state_files(stores, payload): normalized = _normalize_state(payload) errors = [] written = 0 for store in stores: try: _write_state_file(store, normalized) written += 1 except OSError as error: errors.append(f"{store.kind}: {_storage_probe_reason(error)}") ``` ```python def save_token(latest): latest_server = latest["servers"].get(server_key) if not isinstance(latest_server, dict): return False, False latest_pending = latest_server.get("pending") if not isinstance(latest_pending, dict): return False, False if latest_pending.get("deviceCode") != pending.get("deviceCode"): return False, False _remove_access_token(latest_server) latest_server["accessToken"] = access_token ``` ### Technical Analysis The authentication state contains a live GeekBI bearer token. Instead of keeping that credential in one private, user-s ...[truncated 2865 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Store authentication state only in a private operating-system user configuration directory or, preferably, an operating-system credential vault. 2. Remove `_skill_state_path()` and `_workspace_state_path()` from production credential storage. 3. Correct the path component from `temu-research-skill` to a unique Ozon Skill identifier. 4. Add migration logic that: - Reads an existing legacy state once. - Moves it into the canonical secure store. - Securely removes all legacy Skill-directory and workspace copies. 5. Do not mirror the complete authentication state merely to improve availability. Fail safely if the canonical secure store is unavailable. 6. On Windows and other non-POSIX systems, apply explicit user-only access-control lists rather than relying on inherited permissions. 7. Prefer storing a refresh handle or opaque session identifier in a system credential manager instead of a directly usable bearer token. 8. Ensure the `clear` operation removes every legacy copy and invalidates the server-side session where supported. 9. Document the credential location and retention period so users can audit and revoke stored authentication state. ]]>
