T09 · Insecure Skill Coding Practices
- Location
scripts/geekbi_auth.py:53- Finding
Authentication Tokens Are Replicated into Skill and Working Directories
- Content
View full analysis
Vulnerability Details
File Location:
scripts/geekbi_auth.py:53-78,scripts/geekbi_auth.py:299-320, andscripts/geekbi_auth.py:631-650
Vulnerability Type: Plaintext sensitive-data storage and excessive credential replication
Risk Level: MediumVulnerable 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"), ) stores = [] seen_paths = set() for store in candidates: path_key = os.path.normcase(os.fspath(store.path)) if path_key in seen_paths: continue seen_paths.add(path_key) stores.append(store) return tuple(stores)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)}") if written == 0: reason = ";".join(errors) or "登录状态目录不可用" raise OSError(reason)python def save_token(latest): latest_server = latest["servers"].get(server_key) if not isinstance(latest_server, dict): return False, False latest_pending = latest_serv ...[truncated 3136 chars]- Remediation
View remediation
Remediation Suggestions
- Store authentication state only in the protected operating-system user configuration directory.
- Remove
_skill_state_path()and_workspace_state_path()from_resolve_stores()for production authentication data. - Prefer an operating-system credential manager or keyring for the bearer token; keep only non-sensitive metadata in JSON.
- If cross-Skill authentication reuse is required, provide a narrowly scoped local authentication broker rather than a token file readable by every same-user Skill.
- Continue enforcing restrictive permissions, atomic replacement, and file locking for any remaining state files.
- Add migration logic that securely deletes legacy token copies from Skill and workspace directories after moving the active state to the protected store.
- Implement token revocation and rotation controls so users can invalidate a potentially exposed session.
- Document the exact storage location and security boundary so users understand which local processes can access the session.
