T09 · Insecure Skill Coding Practices
Warning
- Location
- scripts/healthcheck.py:174
- Finding
- Automatic Credential Access and Redirect-Based Credential Disclosure<![CDATA[ ## Vulnerability Details **File Location**: `scripts/healthcheck.py:61-69`, `scripts/healthcheck.py:174-190`; credential sources and destinations are configured in `data/platforms.json:3-23` **Vulnerability Type**: Automatic access to credentials owned by other Skills and insufficient destination controls for authenticated requests **Risk Level**: Medium ### Vulnerable Code ```python def load_auth_token(config_path, key): """Load an auth token from a config file.""" expanded = os.path.expanduser(config_path) try: with open(expanded) as f: data = json.load(f) return data.get(key, "") except (OSError, json.JSONDecodeError, KeyError): return "" ``` ```python # Auth check (separate request) auth_url = platform.get("auth_url") auth_config = platform.get("auth_config") auth_key = platform.get("auth_key") if auth_url and auth_config and auth_key: token = load_auth_token(auth_config, auth_key) if token: auth_header = platform.get("auth_header", "Authorization") auth_prefix = platform.get("auth_prefix", "Bearer ") auth_req = Request(auth_url, headers={ "User-Agent": "PlatformHealthCheck/1.0", auth_header: f"{auth_prefix}{token}", }) try: auth_resp = urlopen(auth_req, timeout=TIMEOUT) result.auth_status = "OK" if auth_resp.status < 400 else "FAIL" except HTTPError as e: result.auth_status = "FAIL" if e.code in (401, 403) else "OK" except Exception: result.auth_status = "ERROR" ``` Relevant configuration: ```json { "name": "ClawQuests", "url": "https://clawquests.com/api/v1/quests?limit=1", "auth_url": "https://clawquests.com/api/v1/agents/me", "auth_header": "Authorization", "auth_prefix": "Bearer ", "auth_config": "~/.clawdbot/skills/clawquests/config.json", "auth_key": "api_key", "category": "bounties" }, { "name": "The Colony", "url": "https://the ...[truncated 3649 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. **Make authenticated checks explicitly opt-in** - Add a flag such as `--check-auth`. - Perform connectivity checks without opening credential files unless the user explicitly enables authentication testing. 2. **Disclose credential behavior** - Document every credential path, key name, and receiving hostname in `SKILL.md`. - Warn users that authentication checks transmit reusable credentials over the network. 3. **Enforce an authentication destination allowlist** - Maintain a fixed mapping between each credential source and its permitted HTTPS hostname. - Reject configuration entries whose `auth_url` hostname does not exactly match the approved service. - Do not permit user-info components, nonstandard schemes, or untrusted ports. 4. **Prevent unsafe authenticated redirects** - Disable redirects for requests carrying credentials, or implement a custom redirect handler. - If redirects are necessary, only follow them when the destination remains HTTPS and has the exact same hostname and approved port as the original URL. - Strip all authentication headers before any cross-origin redirect. 5. **Reduce credential privileges** - Use dedicated, read-only health-check tokens where platforms support them. - Avoid reusing tokens capable of state-changing account operations. - Provide clear token revocation and rotation guidance. 6. **Restrict credential-file access** - Prefer credentials explicitly supplied by the user through a narrowly scoped configuration. - Validate resolved paths against an approved set rather than accepting arbitrary paths from platform configuration. - Check that credential files have restrictive filesystem permissions. 7. **Separate uptime and authentication results** - Treat authentication checks as a distinct operation so ordinary availability monitoring does not require access to unrelated Skill secrets. ]]>
