Back to skill

Security audit

Clarity Clinical

Security checks for vulnerabilities and agentic risk

Overview

This is a coherent clinical variant lookup skill, but it needs review because its API-key handling can expose the key on redirects and its clinical-data sharing boundaries could be clearer.

Review before installing if you will use a CLARITY_API_KEY or submit sensitive clinical, patient-adjacent, or proprietary variant information. Use only non-sensitive gene or variant queries unless authorized, and prefer a hardened version that disables or validates redirects before sending the API key.

Vulnerability Patterns
  • Insecure Skill Coding PracticesFinds exploitable flaws such as hardcoded secrets or command injection
  • Skill Instruction HijackingAlters the agent's session goals or safety constraints when the skill loads
  • Agent Memory PoisoningWrites attacker-controlled rules into memory that affect later sessions
  • Remote Payload Retrieval and ExecutionFetches external code whose behavior can change after review
  • Embedded Malicious CodeShips malicious scripts inside the skill and executes them locally
Findings (1)

T09 · Insecure Skill Coding Practices

Warning
Location
scripts/api_client.py:24
Finding
Custom API Key May Be Disclosed Through Cross-Origin HTTP Redirects<![CDATA[ ## Vulnerability Details **File Location**: `scripts/api_client.py`, lines 24–53 **Vulnerability Type**: Credential disclosure through unconstrained redirects **Risk Level**: Medium ### Complete Code Snippet ```python def get_headers() -> Dict[str, str]: """ Get HTTP headers for API requests. Reads CLARITY_API_KEY from environment variable if present. Returns: Dict with Accept header and optional X-API-Key header """ headers = { "Accept": "application/json" } api_key = os.environ.get("CLARITY_API_KEY") if api_key: headers["X-API-Key"] = api_key return headers def api_get(endpoint: str, params: Optional[Dict[str, Any]] = None) -> Any: """ Perform GET request to Clarity Protocol API with error handling. """ url = API_BASE + endpoint try: response = requests.get( url, params=params, headers=get_headers(), timeout=30 ) ``` ### Technical Analysis The client places the `CLARITY_API_KEY` credential in a custom `X-API-Key` request header and calls `requests.get()` without configuring redirect handling. The Requests library follows redirects by default. Requests has special handling that can remove the standard `Authorization` header when a redirect crosses origin boundaries. That protection does not automatically apply to arbitrary authentication headers such as `X-API-Key`. Consequently, the custom API key can remain attached when the client follows a redirect from `clarityprotocol.io` to a different host. Network access and transmission of the API key to the declared Clarity Protocol service are necessary and documented aspects of the Skill. Forwarding that credential to an arbitrary redirected origin is not necessary for the declared clinical-variant query functionality and exceeds the minimum required credential scope. Exploitation requires the Clarity endpoint or its response path to produce an ...[truncated 1406 chars]
Remediation
<![CDATA[ ## Remediation Suggestions 1. Disable automatic redirects for authenticated API requests: ```python response = requests.get( url, params=params, headers=get_headers(), timeout=30, allow_redirects=False, ) ``` 2. If redirects are required, process them manually and validate every destination before following it: - Require the `https` scheme. - Compare parsed hostnames exactly rather than using suffix or substring checks. - Permit only an explicit allowlist of trusted Clarity Protocol hosts. - Reject redirects containing user information, unexpected ports, or unapproved domains. 3. Never copy `X-API-Key` to a redirected request when the scheme, hostname, or port changes. Rebuild headers for each redirect and include the credential only when the destination is the exact approved API origin. 4. Apply a strict redirect limit to prevent redirect loops and unexpected request chains. 5. Add automated tests that return same-origin and cross-origin redirects and verify that `X-API-Key` is absent from every request sent outside the approved origin. A hardened implementation should use a dedicated session and explicitly reject cross-origin redirects: ```python from urllib.parse import urlparse ALLOWED_ORIGIN = ("https", "clarityprotocol.io", 443) response = requests.get( url, params=params, headers=get_headers(), timeout=30, allow_redirects=False, ) if response.is_redirect: location = response.headers.get("Location", "") target = urlparse(location) target_port = target.port or (443 if target.scheme == "https" else None) if (target.scheme, target.hostname, target_port) != ALLOWED_ORIGIN: raise RuntimeError("Refusing redirect to an untrusted origin") ``` ]]>
Vulnerability Patterns
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Trigger AbuseOverly Broad Trigger, Shadow Command Trigger, Keyword Baiting Trigger
  • MCP Least PrivilegeUnderdeclared Capability, Wildcard Permission, Missing Permission Declaration
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
Findings (3)

Lp3

Medium
Category
MCP Least Privilege
Confidence
92% confidence
Finding
The skill appears to require network access and may read an API key from the environment, but it does not explicitly declare permissions or allowed tools. This weakens policy enforcement and user visibility, making it easier for the skill to access external services or sensitive configuration without clear consent boundaries.

Vague Triggers

Medium
Confidence
90% confidence
Finding
The invocation description is broad enough to trigger on general biomedical or clinical questions, which can cause over-invocation of a networked skill. In practice this may send user queries to an external service when the user did not intend to use that integration, increasing privacy and data-minimization risk.

Missing User Warnings

Medium
Confidence
92% confidence
Finding
The skill documentation does not clearly warn that gene and variant queries are transmitted to clarityprotocol.io. In a clinical/genetics context, even seemingly technical queries can be sensitive, so lack of disclosure can lead to unintended sharing of research, patient-adjacent, or proprietary information with a third party.

Static analysis

No suspicious patterns detected.