T09 · Insecure Skill Coding Practices
Warning
- Location
- a2a_client.py:14
- Finding
- Bearer Token and Sensitive A2A Traffic Can Be Transmitted Over Plaintext HTTP<![CDATA[ ## Vulnerability Details **File Location**: `a2a_client.py`, lines 14 and 20-25 **Vulnerability Type**: Plaintext transmission of authentication credentials and sensitive data **Risk Level**: Medium ### Vulnerable Code ```python DEFAULT_REGISTRY = "http://localhost:8000" class A2AClient: """Client for A2A Protocol communication""" def __init__(self, registry_url=DEFAULT_REGISTRY, api_key=None): self.registry_url = registry_url.rstrip("/") self.session = requests.Session() if api_key: self.session.headers["Authorization"] = f"Bearer {api_key}" ``` ### Technical Analysis The client accepts an unrestricted registry URL and automatically adds the supplied API key to the session's `Authorization` header. It does not require HTTPS when authentication is enabled. Although the default URL is a loopback address, callers can provide an arbitrary remote `http://` URL through the constructor or the `--registry-url` command-line option. Requests to such a registry transmit the bearer token without transport encryption. Messages, task descriptions, task results, and agent registration information sent through the same connection are also exposed. The session-wide authorization header can additionally be exposed if request handling follows a redirect in an unsafe deployment scenario. The implementation does not independently enforce a trusted destination or an HTTPS-only redirect policy. ### Attack Path 1. A victim receives or configures a remote A2A registry URL using the `http://` scheme. 2. The victim supplies an API key through the `--api-key` option or the `A2AClient` constructor. 3. The constructor stores the key in the session-wide `Authorization: Bearer ...` header. 4. The victim performs an A2A operation such as agent registration, message submission, or task submission. 5. The request and bearer token travel over an unencrypted network connection. 6. An attacker able to observe or manipulate the n ...[truncated 704 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Require an `https://` registry URL whenever an API key is configured. 2. Allow plaintext HTTP only for explicitly validated loopback development addresses such as `127.0.0.1`, `::1`, or `localhost`. 3. Reject URLs containing unexpected user information, unsupported schemes, or untrusted destinations. 4. Apply an explicit redirect policy and prevent credentials from being forwarded to a different origin. 5. Provide a deliberate development-only override if plaintext transport is necessary, and display a clear warning when it is enabled. 6. Use certificate verification, which `requests` enables by default, and do not introduce a `verify=False` bypass. Example validation: ```python from urllib.parse import urlparse parsed = urlparse(registry_url) is_loopback = parsed.hostname in {"localhost", "127.0.0.1", "::1"} if api_key and parsed.scheme != "https" and not is_loopback: raise ValueError("HTTPS is required when API-key authentication is enabled") ``` ]]>
