T09 · Insecure Skill Coding Practices
- Location
- scripts/room_client.py:210
- Finding
- Authentication Credentials Can Be Transmitted to an Arbitrary or Plaintext Endpoint<![CDATA[ ## Vulnerability Details **File Location**: `scripts/room_client.py:59, 210-229, 331-343, 520-529, 567-591` **Vulnerability Type**: Unrestricted authentication endpoint and insecure transport configuration **Risk Level**: High ### Complete Code Snippet ```python DEFAULT_BASE = os.environ.get('CW_BASE_URL', 'https://clankers.world') ``` ```python def authenticate_agent(prof, force=False): prof = normalize_profile(prof) aid = prof['agentId'] session = read_auth_session(aid) if not force and auth_session_valid(session): return session identity = ensure_agent_identity(aid, prof.get('displayName'), prof.get('ownerId')) payload = { 'participantId': identity['agentId'], 'kind': 'agent', 'emblemAI': {'accountId': identity['emblemAccountId']}, 'agentAuth': { 'workspaceId': identity['workspaceId'], 'workspaceName': identity['workspaceName'], 'recoveryPassword': read_recovery_password(identity), }, } out = req('POST', f"{prof['baseUrl']}/auth/emblem", payload) ``` ```python def normalize_profile(prof): prof = dict(prof or {}) aid = normalize_identifier(prof.get('agentId') or prof.get('id') or '') if aid in PLACEHOLDER_AGENT_IDS: raise SystemExit('No valid agent identity configured. Run: cw agent create <agent-id> or cw agent use <agent-id>') identity = ensure_agent_identity(aid, prof.get('displayName'), prof.get('ownerId')) prof['agentId'] = identity['agentId'] prof['displayName'] = identity['displayName'] prof['ownerId'] = identity['ownerId'] prof['workspaceId'] = identity['workspaceId'] prof['workspaceName'] = identity['workspaceName'] prof['emblemAI'] = {'accountId': identity['emblemAccountId']} prof['baseUrl'] = prof.get('baseUrl') or DEFAULT_BASE ``` ```python def req(method, url, payload=None, extra_headers=None): data, headers = None, {} if payload is not None: data = ...[truncated 3495 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Permit only `https://clankers.world` in normal production operation. 2. Parse the configured URL and reject plaintext HTTP, embedded credentials, fragments, unexpected ports, and unapproved hostnames. 3. Require an explicit development flag, such as `CW_ALLOW_CUSTOM_BASE_URL=1`, before accepting alternate origins. 4. Never send production recovery credentials or session tokens to development origins. 5. Disable or strictly validate cross-origin redirects for requests carrying credentials. 6. Display a prominent confirmation containing the destination hostname before authenticating to a non-production server. 7. Store an environment classification with each identity so production credentials cannot be reused against test endpoints. 8. Add automated tests verifying rejection of HTTP URLs, unapproved domains, deceptive subdomains, and redirect-based origin changes. ]]>
