T09 · Insecure Skill Coding Practices
Warning
- Location
- scripts/geekbi_auth.py:68
- Finding
- Bearer token state is unnecessarily replicated across multiple filesystem locations## Vulnerability Details **File Location**: `scripts/geekbi_auth.py:68-82`, `scripts/geekbi_auth.py:371-380`, and `scripts/geekbi_auth.py:637-648` **Vulnerability Type**: Excessive credential persistence and insecure secret storage **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) ``` ```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 latest_server["accessTokenExpiresAt"] = now + max(0, expires_in - 30) ``` ### Technical Analysis The authentication state contains a reusable bearer access token. Instead of maintaining one protected user-level credential store, the implementation mirrors the same state into: 1. The operating-system user configuration directory; 2. The installed Skill directory; ...[truncated 2652 chars]
- Remediation
- ## Remediation Suggestions 1. Store authentication state only in one Ozon-specific user configuration location. 2. Remove `_skill_state_path`, `_workspace_state_path`, and credential mirroring. 3. Replace `temu-research-skill` with an Ozon-specific and application-specific directory name. 4. Prefer the operating system's credential vault, such as Keychain, Credential Manager, or Secret Service, for the bearer token. 5. If file storage remains necessary, preserve restrictive permissions and fail closed if they cannot be enforced. 6. Store only the minimum state required for authentication and avoid retaining expired device codes or tokens. 7. Add a migration routine that moves valid state to the protected store and deletes legacy copies from Skill and workspace directories. 8. Document token revocation and provide a command that reliably removes every legacy token copy. 9. Add tests confirming that successful authentication creates no credential-bearing file beneath the Skill installation or current working directory.
