T09 · Insecure Skill Coding Practices
- Location
scripts/register_onchain.py:121- Finding
ACN API Key Can Be Transmitted to an Arbitrary or Insecure Endpoint
- Content
View full analysis
str: """Look up the ACN agent ID via /api/v1/agents/me using the API key.""" import httpx async with httpx.AsyncClient() as client: resp = await client.get( f"{acn_url}/api/v1/agents/me", headers={"Authorization": f"Bearer {api_key}"}, timeout=15, ) ``` ```python async with httpx.AsyncClient() as client: resp = await client.post( f"{acn_url}/api/v1/onchain/agents/{agent_id}/bind", json={"token_id": token_id, "chain": chain, "tx_hash": tx_hash}, headers={"Authorization": f"Bearer {api_key}"}, timeout=30, ) resp.raise_for_status() ``` ```python parser.add_argument( "--acn-url", default=os.getenv("ACN_API_URL", "https://api.acnlabs.dev"), help="ACN server base URL", ) ``` ### Technical Analysis The script accepts the ACN server URL from either the `--acn-url` argument or the `ACN_API_URL` environment variable. It removes a trailing slash but does not validate: - Whether the URL uses HTTPS. - Whether the hostname belongs to an approved ACN deployment. - Whether the URL contains embedded user information. - Whether an unexpected port is present. - Whether redirects remain on the validated origin. The script subsequently sends the full ACN bearer API key to this URL in an `Authorization` header. Therefore, a malicious wrapper, poisoned environment variable, deceptive command, or configuration mistake can redirect the credential to an attacker-controlled server. The documentation advises users to verify the URL manually, but this does not provide an enforceable security boundary. It also conflicts with the statement in `SKILL.md` that all API calls use HTTPS b ...[truncated 1612 chars]- Remediation
View remediation
