T09 · Insecure Skill Coding Practices
Warning
- Location
- scripts/geekbi_auth.py:65
- Finding
- Bearer tokens are unnecessarily replicated across multiple local storage locations## Vulnerability Details **File Location**: `scripts/geekbi_auth.py:65-90`, `scripts/geekbi_auth.py:371-379`, and `scripts/geekbi_auth.py:631-648` **Vulnerability Type**: Excessive storage of plaintext bearer tokens **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"), ) 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)}") ``` ```python token_data = response["data"] access_token = token_data.get("accessToken") if not isinstance(access_token, str) or not access_token: raise ValueError("Login token response does not contain accessToken") expires_in = int(token_data.get("expiresIn", 0)) def save_token(latest): latest_server = latest["s ...[truncated 3065 chars]
- Remediation
- ## Remediation Suggestions 1. Store authentication state in exactly one Skill-specific user configuration location. 2. Replace the `temu-research-skill` directory with a unique Mercado Libre Skill identifier. 3. Remove `_skill_state_path()` and `_workspace_state_path()` from production credential storage. 4. Prefer the operating system's credential manager or keychain for bearer-token material. Keep only non-sensitive metadata in JSON. 5. Implement a migration that reads any legacy state once, moves it into the new secure store, and securely removes all legacy copies. 6. Enforce restrictive ACLs on Windows as well as mode `0700` for directories and `0600` for files on POSIX systems. 7. Fail closed when secure token storage cannot be established rather than falling back to the Skill or working directory. 8. Add tests confirming that authentication never creates `.geekbi/agent-auth.json` in the project or current working directory.
