T09 · Insecure Skill Coding Practices
- Location
scripts/geekbi_auth.py:55- Finding
Bearer tokens and device authorization state are unnecessarily replicated across multiple local directories
- Content
View full analysis
Vulnerability Details
File Location:
scripts/geekbi_auth.py:55-75,scripts/geekbi_auth.py:349-361,scripts/geekbi_auth.py:637-648
Vulnerability Type: Excessive replication of plaintext authentication state
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"), )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_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_serve ...[truncated 3282 chars]- Remediation
View remediation
Remediation Suggestions
-
Use one canonical credential store. Store authentication state only in the operating-system user configuration directory. Remove the Skill-directory and working-directory stores from
_resolve_stores(). -
Prefer an operating-system credential manager. Store bearer tokens through facilities such as Windows Credential Manager, macOS Keychain, or Secret Service on Linux. Keep only non-sensitive metadata in the JSON state file.
-
Migrate legacy copies safely. During an upgrade:
- Read existing stores according to a documented migration order.
- Move valid state into the canonical protected store.
- Delete legacy Skill and workspace copies after successful migration.
- Warn the user when a legacy file cannot be removed.
-
Maintain strict file permissions. If file-based storage remains necessary, create the parent directory with owner-only access and the state file with mode
0600. On platforms where equivalent restrictions cannot be guaranteed, fail closed or use the platform credential manager. -
Minimize stored secrets. Do not persist device codes or authorization URLs longer than required. Remove expired and completed authorization state promptly.
-
Add automated security tests. Verify that authentication never creates
.geekbi/agent-auth.jsonin the current workspace or Skill directory and that migration deletes historical copies. -
Correct the configuration namespace. Review the stale-looking
"temu-research-skill"user configuration path and replace it with a project-specific Ozon Skill namespace to prevent unintended state sharing with another Skill.
-
