Back to skill

Security audit

Cogmate Client

Security checks for vulnerabilities and agentic risk

Overview

The skill is a coherent Cogmate API client, but it handles access tokens in URLs, command lines, and HTTP examples in ways that can leak private knowledge access.

Review before installing. Use this only with Cogmate instances you trust, prefer HTTPS-only endpoints, use the lowest-scope and shortest-lived token available, and avoid typing real tokens directly into the provided helper-script command lines. If you already used these examples with a real token, rotate that token and check server or proxy logs for exposure.

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 (3)

T09 · Insecure Skill Coding Practices

Error
Location
SKILL.md:15
Finding
Access tokens and sensitive queries may be transmitted over plaintext HTTP<![CDATA[ ## Vulnerability Details **File Location**: `SKILL.md:15-21`, `SKILL.md:107-124`, `scripts/ask.sh:15-16`, `scripts/search.sh:14-15` **Vulnerability Type**: Plaintext transmission of credentials and potentially sensitive user data **Risk Level**: High ### Vulnerable Code ```bash curl -X POST "http://{COGMATE_URL}/api/ask?token=YOUR_TOKEN" \ -H "Content-Type: application/json" \ -d '{"question": "你的问题"}' ``` The documentation also provides an explicitly plaintext endpoint in its Python example: ```python COGMATE_URL = "http://example.com:8000" TOKEN = "your_token_here" response = requests.post( f"{COGMATE_URL}/api/ask", params={"token": TOKEN}, json={"question": "What are the key insights about X?"} ) ``` The helper scripts accept the URL without enforcing HTTPS: ```bash curl -s -X POST "${COGMATE_URL}/api/ask?token=${TOKEN}" \ -H "Content-Type: application/json" \ -d "{\"question\": \"${QUESTION}\"}" | \ python3 -c "import sys,json; r=json.load(sys.stdin); print(r.get('answer','No answer'))" ``` ```bash curl -s "${COGMATE_URL}/api/visual/facts?${PARAMS}" | \ python3 -c " ``` ### Technical Analysis Network communication is necessary for the Skill's declared Cogmate API-client functionality. However, transmitting reusable access tokens, questions, search terms, and API responses over unencrypted HTTP exceeds what is safely necessary. The documentation actively demonstrates plaintext HTTP, and the scripts do not validate the URL scheme. Consequently, TLS confidentiality, server authentication, and transport integrity are absent when a user follows the examples or supplies an HTTP endpoint. The transmitted questions and search terms may themselves contain private information. Responses may contain personal knowledge-base facts, creating bidirectional sensitive-data exposure. ### Attack Path 1. A victim follows the documented HTTP example or supplies an `http://` Cogmate URL to a helper script. 2. The script send ...[truncated 1014 chars]
Remediation
<![CDATA[ ## Remediation Suggestions 1. Require `https://` endpoints in both helper scripts and reject plaintext HTTP by default. 2. Validate the scheme before invoking `curl`, for example: ```bash case "$COGMATE_URL" in https://*) ;; *) echo "Error: Cogmate URL must use HTTPS." >&2; exit 1 ;; esac ``` 3. Replace all documented `http://` examples with HTTPS examples. 4. Do not add `curl -k` or otherwise disable certificate verification. 5. Where deployments need custom certificate authorities, support an explicit trusted CA file rather than bypassing TLS verification. 6. Consider an allowlist or explicit confirmation for unfamiliar hosts because the caller-selected endpoint receives both credentials and user data. 7. Clearly document that questions, searches, and returned knowledge may be sensitive and are transmitted to the configured Cogmate operator. ]]>

T09 · Insecure Skill Coding Practices

Warning
Location
scripts/ask.sh:3
Finding
Access tokens are exposed through command-line arguments and URL query parameters<![CDATA[ ## Vulnerability Details **File Location**: `SKILL.md:19-53`, `SKILL.md:110-121`, `scripts/ask.sh:3-15`, `scripts/search.sh:3-15` **Vulnerability Type**: Credential exposure through process arguments, shell history, and URL logging **Risk Level**: Medium ### Vulnerable Code From `scripts/ask.sh`: ```bash # Usage: ./ask.sh <cogmate_url> <token> "question" COGMATE_URL="${1%/}" TOKEN="$2" QUESTION="$3" if [ -z "$COGMATE_URL" ] || [ -z "$TOKEN" ] || [ -z "$QUESTION" ]; then echo "Usage: $0 <cogmate_url> <token> \"question\"" echo "Example: $0 http://example.com:8000 tok_xxx \"What do you know about AI?\"" exit 1 fi curl -s -X POST "${COGMATE_URL}/api/ask?token=${TOKEN}" \ ``` From `scripts/search.sh`: ```bash # Usage: ./search.sh <cogmate_url> <token> "search term" COGMATE_URL="${1%/}" TOKEN="$2" SEARCH="$3" if [ -z "$COGMATE_URL" ] || [ -z "$TOKEN" ]; then echo "Usage: $0 <cogmate_url> <token> [search_term]" echo "Example: $0 http://example.com:8000 tok_xxx \"AI\"" exit 1 fi PARAMS="token=${TOKEN}" [ -n "$SEARCH" ] && PARAMS="${PARAMS}&search=${SEARCH}" curl -s "${COGMATE_URL}/api/visual/facts?${PARAMS}" | \ ``` ### Technical Analysis Both scripts require the token as a positional command-line argument. Depending on the operating system and execution environment, process arguments may be visible to other local users, process-monitoring agents, audit systems, terminal logs, or shell history. The scripts then place the token in the URL query string. Query strings are commonly retained in reverse-proxy access logs, API server logs, network monitoring products, tracing platforms, browser or tooling history, and diagnostic output. HTTPS protects a URL while it is in transit but does not prevent endpoint-side or local process logging. This credential exposure is avoidable and therefore does not satisfy least-privilege handling of authentication material. ### Attack Path 1. A victim invokes a helper script with a valid t ...[truncated 985 chars]
Remediation
<![CDATA[ ## Remediation Suggestions 1. Do not accept tokens as command-line arguments. Read them from a protected environment variable, restricted configuration file, credential manager, or non-echoing standard-input prompt. 2. Prefer an authorization header if the API can be changed: ```bash curl --fail-with-body --silent --show-error \ -H "Authorization: Bearer ${COGMATE_TOKEN}" \ ... ``` 3. Update the server API so credentials are not required in query parameters. 4. If compatibility temporarily requires query-parameter authentication: - Redact query strings from server, reverse-proxy, telemetry, and monitoring logs. - Prevent verbose/debug output from printing the final URL. - Use short-lived, narrowly scoped tokens. - Rotate any token suspected of appearing in command history or logs. 5. Update all documentation and usage examples so they do not encourage users to type secrets directly into commands. 6. Recommend the minimum necessary scope, such as `qa_public` for Q&amp;A-only workflows instead of `full`. ]]>

T09 · Insecure Skill Coding Practices

Warning
Location
scripts/search.sh:13
Finding
Question and search inputs are interpolated without JSON or URL encoding<![CDATA[ ## Vulnerability Details **File Location**: `scripts/ask.sh:15-16`, `scripts/search.sh:13-15` **Vulnerability Type**: Improper construction of JSON and URL query parameters **Risk Level**: Medium ### Vulnerable Code From `scripts/ask.sh`: ```bash curl -s -X POST "${COGMATE_URL}/api/ask?token=${TOKEN}" \ -H "Content-Type: application/json" \ -d "{\"question\": \"${QUESTION}\"}" | \ python3 -c "import sys,json; r=json.load(sys.stdin); print(r.get('answer','No answer'))" ``` From `scripts/search.sh`: ```bash PARAMS="token=${TOKEN}" [ -n "$SEARCH" ] && PARAMS="${PARAMS}&search=${SEARCH}" curl -s "${COGMATE_URL}/api/visual/facts?${PARAMS}" | \ ``` ### Technical Analysis `ask.sh` inserts user-controlled text directly into a JSON string. A question containing quotation marks, backslashes, line breaks, or JSON syntax is not escaped. This can produce malformed JSON or alter the structure and semantics of the request body. `search.sh` concatenates user-controlled input directly into a URL query string. Characters such as `&`, `=`, `%`, `#`, and control characters are not percent-encoded. A crafted search value can therefore create additional query parameters or modify request parsing. The shell expansions are enclosed in double quotes, so the reviewed code does not establish direct shell-command execution. The confirmed issue is request-structure injection and malformed input, not command injection. ### Attack Path 1. An attacker supplies or persuades a victim to use a specially crafted question or search term. 2. For `ask.sh`, embedded quotation marks or JSON syntax are copied directly into the request body. 3. The request becomes malformed or contains attacker-influenced JSON structure. 4. For `search.sh`, an input such as `topic&layer=abstract&limit=500` is concatenated directly into the URL. 5. The Cogmate server interprets the injected separators as additional query parameters rather than as part of the intended search term. 6. The A ...[truncated 535 chars]
Remediation
<![CDATA[ ## Remediation Suggestions 1. Generate JSON with a JSON-aware encoder rather than string interpolation. For example: ```bash PAYLOAD="$(python3 -c 'import json,sys; print(json.dumps({"question": sys.argv[1]}))' "$QUESTION")" curl --fail-with-body --silent --show-error \ -X POST "${COGMATE_URL}/api/ask" \ -H "Content-Type: application/json" \ --data-binary "$PAYLOAD" ``` 2. Encode each query parameter independently with `curl --get` and `--data-urlencode`: ```bash curl --fail-with-body --silent --show-error --get \ "${COGMATE_URL}/api/visual/facts" \ --data-urlencode "token=${TOKEN}" \ --data-urlencode "search=${SEARCH}" ``` 3. After the API supports header-based authentication, remove the token from query construction entirely. 4. Validate input length and reject control characters where they have no legitimate use. 5. Add tests covering quotation marks, backslashes, Unicode, newlines, ampersands, equals signs, percent signs, empty input, and long input. 6. Enable explicit HTTP failure handling so malformed or rejected API responses are not silently presented as normal results. ]]>
Vulnerability Patterns
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
  • Supply ChainUnpinned Dependencies, External Script Fetching, Obfuscated Code
  • Excessive AgencyUnrestricted Tool Access, Autonomous Decision Making, Scope Creep
Findings (11)

Credential Access

High
Category
Privilege Escalation
Content
---
name: cogmate-client
description: Access Cogmate personal knowledge systems via API. Use when querying someone's Cogmate/模拟世界 for knowledge retrieval, semantic search, or Q&A. Requires valid access token from CogNexus (https://github.com/MaxiiWang/CogNexus). Triggers on: "ask Cogmate", "query knowledge base", "search Cogmate", "access 模拟世界".
---

# Cogmate Client
Confidence
70% confidence
Finding
Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Credential Access

High
Category
Privilege Escalation
Content
---
name: cogmate-client
description: Access Cogmate personal knowledge systems via API. Use when querying someone's Cogmate/模拟世界 for knowledge retrieval, semantic search, or Q&A. Requires valid access token from CogNexus (https://github.com/MaxiiWang/CogNexus). Triggers on: "ask Cogmate", "query knowledge base", "search Cogmate", "access 模拟世界".
---

# Cogmate Client
Confidence
70% confidence
Finding
Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Credential Access

High
Category
Privilege Escalation
Content
Browse or search facts.

**Parameters:**
- `token` (required): Access token
- `search` (optional): Search query
- `layer` (optional): Filter by layer (fact/connection/abstract)
Confidence
70% confidence
Finding
Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Credential Access

High
Category
Privilege Escalation
Content
### /api/visual/facts

**Query Parameters:**
- `token`: Access token (required)
- `search`: Search query (optional)
- `layer`: Filter by layer - fact/connection/abstract (optional)
- `limit`: Max results (optional, default 50)
Confidence
70% confidence
Finding
Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

External Transmission

Medium
Category
Data Exfiltration
Content
### Ask a Question

```bash
curl -X POST "http://{COGMATE_URL}/api/ask?token=YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"question": "你的问题"}'
```
Confidence
96% confidence
Finding
The curl example sends a secret in the request URL and uses an http:// endpoint, combining credential exposure with lack of transport security. This makes interception and downstream logging of the token much more likely, especially if copied directly by users.

Missing User Warnings

Medium
Confidence
97% confidence
Finding
The documentation explicitly instructs users to place access tokens in URL query parameters, including over plain HTTP in examples. Query-string tokens are commonly exposed through browser history, logs, reverse proxies, monitoring systems, shell history, and referrer leakage, making accidental credential disclosure materially more likely.

External Transmission

Medium
Category
Data Exfiltration
Content
TOKEN = "your_token_here"

# Ask a question (token in query params, question in body)
response = requests.post(
    f"{COGMATE_URL}/api/ask",
    params={"token": TOKEN},
    json={"question": "What are the key insights about X?"}
Confidence
93% confidence
Finding
This example code transmits the token to an external service as a URL parameter, which exposes it to intermediary logging and telemetry even if the transmission itself is intended. In context, the skill is designed to contact external Cogmate instances, so the issue is not the outbound request itself but the unsafe method of including the credential.

Missing User Warnings

Medium
Confidence
97% confidence
Finding
The documentation explicitly instructs clients to pass bearer-style access tokens in the URL query string. Query parameters are commonly exposed in browser history, server logs, reverse proxy logs, referrer headers, analytics systems, and shared screenshots, so this pattern increases the chance of token leakage even if TLS is used. In this context, the token grants access to protected API endpoints, making accidental disclosure security-relevant.

External Transmission

Medium
Category
Data Exfiltration
Content
exit 1
fi

curl -s -X POST "${COGMATE_URL}/api/ask?token=${TOKEN}" \
    -H "Content-Type: application/json" \
    -d "{\"question\": \"${QUESTION}\"}" | \
    python3 -c "import sys,json; r=json.load(sys.stdin); print(r.get('answer','No answer'))"
Confidence
95% confidence
Finding
The script places the authentication token in the URL query string when making the POST request. Query parameters are commonly exposed through shell history, process listings, reverse proxies, web server access logs, and monitoring systems, which can lead to credential disclosure even if the request otherwise succeeds.

Missing User Warnings

Medium
Confidence
89% confidence
Finding
The script performs a network POST request that transmits the supplied question and authentication token to a remote Cogmate server. While the header comments show usage, there is no confirmation prompt, runtime notice, or explicit warning to the user that their input and credential are being sent over the network.

Missing User Warnings

Medium
Confidence
98% confidence
Finding
The script accepts the API token as a positional command-line argument and then places it into the query string of the request URL. This exposes the token through shell history, process listings, proxy/server logs, browser or terminal history, and intermediary monitoring systems, which can lead to credential theft and unauthorized API access.

Static analysis

No suspicious patterns detected.