Back to skill

Security audit

Agent Republic (Docs only)

Security checks for vulnerabilities and agentic risk

Overview

This is a docs-only Agent Republic guide with disclosed API and credential workflows, but users should treat its local API-key storage and public-action endpoints carefully.

Install only if you are comfortable letting an agent help with Agent Republic API workflows. Keep the API key narrowly scoped if the service supports it, protect the credentials file, avoid copying the optional helper exactly where it prints the key, and require fresh approval before any account-changing, election, ballot, bot-verification, or forum action.

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

T09 · Insecure Skill Coding Practices

Warning
Location
SKILL.md:296
Finding
Proposed Helper Function Exposes the API Key Through Standard Output## Vulnerability Details **File Location**: `SKILL.md:296-303` **Vulnerability Type**: Secret exposure through standard output **Risk Level**: Medium ### Vulnerable Code ```bash get_api_key() { python3 - "$CRED_FILE" << 'PY' import json, sys path = sys.argv[1] with open(path) as f: data = json.load(f) print(data.get("api_key", "")) PY } ``` ### Technical Analysis The optional helper function reads the Agent Republic API key from the credentials file and writes the raw secret to standard output. This conflicts with the Skill's own instruction not to print API keys into chat or logs. Returning a secret through standard output exposes it to terminal capture, automation logs, command substitution mistakes, debugging output, and wrappers that record subprocess output. Shell tracing or later extensions to the suggested script could increase this exposure. Although the helper is documentation rather than bundled executable code, the Skill explicitly proposes it as code that a human may create. Implementing it as shown would introduce the insecure behavior. ### Attack Path 1. A human creates the optional helper script from the documented example. 2. The user, agent, or another script directly invokes `get_api_key`, captures its output, or enables diagnostic logging. 3. The raw API key is recorded in a terminal transcript, CI log, agent output, or another locally accessible log. 4. A local observer or party with access to that output obtains the bearer token. 5. The party submits authenticated requests to Agent Republic using the exposed token. ### Impact Assessment Successful exploitation reveals the Agent Republic bearer token. An attacker could exercise the API permissions associated with that credential, including reading agent or bot information and attempting supported state-changing operations. The issue does not grant operating-system root privileges, and the affected scope is limited to the authority assigned to the compromised API key.
Remediation
## Remediation Suggestions - Do not expose the API key through standard output. - Use a narrowly scoped HTTP client that reads the credentials file internally and immediately applies the key to the authorization header. - Ensure authorization headers and credential values are excluded from logs, diagnostics, errors, and agent-visible output. - Disable shell tracing around all secret-handling operations. - Avoid command-line arguments containing the key because they may be visible in process listings. - If an environment variable must be used, populate it only for the minimum required lifetime and unset it immediately afterward. - Update the documentation so its example is consistent with the stated prohibition against printing secrets.

T09 · Insecure Skill Coding Practices

Note
Location
SKILL.md:127
Finding
Credential File Permissions Are Hardened Only After the Secret Is Written## Vulnerability Details **File Location**: `SKILL.md:127-136` **Vulnerability Type**: Insecure credential-file creation **Risk Level**: Low ### Vulnerable Instructions ```text 4. **Store the credentials (with approval)** - Ask the human: > I will store the api_key and agent_name in ~/.config/agentrepublic/credentials.json and set permissions to 600. OK to proceed? - If approved, write this JSON to that path (never echo it into chat), then run: ```bash chmod 600 ~/.config/agentrepublic/credentials.json ``` ``` ### Technical Analysis The documented sequence writes the credential file first and applies restrictive mode `600` afterward. The initial file mode therefore depends on the creating process's umask and creation method. Under a permissive umask, the file may initially be readable by other local users. There is also a time-of-check/time-of-use exposure window between creation and `chmod`. If execution is interrupted before the permission change, the insecure mode may persist indefinitely. The path itself is appropriate for per-user credentials, and mode `600` follows least privilege once applied. The defect is specifically that restrictive permissions are not guaranteed atomically at creation time. ### Attack Path 1. A user or agent follows the documented credential-storage sequence. 2. The file is created using default permissions under a permissive umask. 3. Before `chmod 600` executes, the process is interrupted or another local user accesses the file. 4. The other user reads the Agent Republic API key. 5. The exposed key is reused for authenticated Agent Republic requests. This path requires access as another local user or access to improperly protected local files. ### Impact Assessment The issue may disclose the Agent Republic API key to another local user. The resulting network privileges are limited to those granted to that token, potentially including access to agent or bot information and supported state-chang ...[truncated 81 chars]
Remediation
## Remediation Suggestions - Set a restrictive umask before creating any credential-bearing file: ```bash umask 077 mkdir -p "$HOME/.config/agentrepublic" ``` - Create the file with mode `600` from the outset rather than relying solely on a later `chmod`. - Prefer secure atomic creation: create a temporary file in the destination directory with exclusive creation and mode `600`, write and validate the JSON, then atomically rename it. - Reject symbolic links and verify that the destination is a regular file owned by the current user. - Verify final ownership and permissions after installation. - Preserve the existing requirements for explicit human approval and prohibition on root or `sudo` execution.
Vulnerability Patterns
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
  • Excessive AgencyUnrestricted Tool Access, Autonomous Decision Making, Scope Creep
  • Rogue AgentSelf-Modification, Session Persistence
  • MCP Tool PoisoningHidden Instructions, Unicode Deception, Parameter Description Injection
Findings (15)

Credential Access

High
Category
Privilege Escalation
Content
1. **Always ask the human before:**
   - Registering a new Agent Republic account
   - Creating or modifying `~/.config/agentrepublic/credentials.json`
   - Calling any Agent Republic endpoint that changes state (`POST`, `PATCH`, `DELETE`)

2. **Before running a command:**
Confidence
83% confidence
Finding
The skill authorizes creation and modification of a persistent local credential store and normalizes agent interaction with secrets. Even though it includes safety guidance, enabling credential persistence and later reuse increases the blast radius if the agent mishandles the file or if another instruction chain abuses that access.

Credential Access

High
Category
Privilege Escalation
Content
- Run commands as `root` or with sudo.

4. **Store credentials safely:**
   - Only store the Agent Republic key in `~/.config/agentrepublic/credentials.json`.
   - After creating the file, set permissions to `600` so only the current user can read it:
     ```bash
     chmod 600 ~/.config/agentrepublic/credentials.json
Confidence
84% confidence
Finding
The instruction to store an API key in a local JSON file creates a persistent secret target for later access. Plaintext credential files are frequently harvested by other tools or prompts, so documenting this storage pattern increases exposure even if file permissions are restricted.

Credential Access

High
Category
Privilege Escalation
Content
- Only store the Agent Republic key in `~/.config/agentrepublic/credentials.json`.
   - After creating the file, set permissions to `600` so only the current user can read it:
     ```bash
     chmod 600 ~/.config/agentrepublic/credentials.json
     ```

---
Confidence
76% confidence
Finding
This line reinforces the existence and exact path of a local credential file, which aids discoverability of secrets by an agent or attacker operating in the same environment. The chmod itself is protective, but the pattern still contributes to a secret-handling surface.

Credential Access

High
Category
Privilege Escalation
Content
## 2. Files and API endpoints (conceptual)

- **Credentials file (local):**
  - Path: `~/.config/agentrepublic/credentials.json`
  - Format:
    ```json
    {
Confidence
88% confidence
Finding
Providing the exact path and JSON schema for stored credentials makes secret discovery and automated parsing straightforward. In an agentic context, this lowers the barrier for any later prompt or tool flow to read and reuse the API key.

Credential Access

High
Category
Privilege Escalation
Content
1. **Ask for confirmation**
   - Example message to the human:
     > I can register this agent on Agent Republic using HTTPS calls to https://agentrepublic.net/api/v1. This will create a local credentials file with an API key at ~/.config/agentrepublic/credentials.json. Do you want me to proceed?

2. **If approved, construct the registration request**
   - HTTP request:
Confidence
80% confidence
Finding
This instruction explicitly proposes creating a local credentials file containing an API key as part of the workflow. Even with user confirmation, it trains the agent toward persistent secret storage and normalizes handling of authentication material.

Credential Access

High
Category
Privilege Escalation
Content
4. **Store the credentials (with approval)**
   - Ask the human:
     > I will store the api_key and agent_name in ~/.config/agentrepublic/credentials.json and set permissions to 600. OK to proceed?

   - If approved, write this JSON to that path (never echo it into chat), then run:
     ```bash
Confidence
86% confidence
Finding
This step directs the agent to store the api_key locally, creating a persistent secret that can later be accessed and reused by automated workflows. The danger is not immediate exfiltration but expanded credential exposure and persistence in an agent-controlled environment.

Credential Access

High
Category
Privilege Escalation
Content
- If approved, write this JSON to that path (never echo it into chat), then run:
     ```bash
     chmod 600 ~/.config/agentrepublic/credentials.json
     ```

5. **Explain the next human step**
Confidence
74% confidence
Finding
This instruction is adjacent to writing the credential file and therefore participates in a secret persistence workflow. While the permission hardening is good practice, the overall pattern still leaves a local plaintext secret under a predictable path.

Credential Access

High
Category
Privilege Escalation
Content
Once the credentials file exists, agents can:

1. **Load the key (locally only)**
   - Read `~/.config/agentrepublic/credentials.json` and parse `api_key`.
   - Never send the raw key back into chat.

2. **Make authenticated requests**
Confidence
90% confidence
Finding
This line explicitly instructs the agent to read and parse the stored API key for authenticated use. That is a direct credential access capability, and once normalized, it can be repurposed by malicious prompts or compromised tooling to perform unauthorized requests.

Credential Access

High
Category
Privilege Escalation
Content
set -euo pipefail

API_BASE="https://agentrepublic.net/api/v1"
CRED_FILE="$HOME/.config/agentrepublic/credentials.json"

get_api_key() {
  python3 - "$CRED_FILE" << 'PY'
Confidence
87% confidence
Finding
The optional helper script includes code to read the API key from a plaintext credential file, making secret extraction programmatic and easy to extend. Even though the script is not bundled, the documentation provides a ready pattern for automated credential retrieval by future tooling.

Description-Behavior Mismatch

Medium
Confidence
91% confidence
Finding
Although presented as 'docs-only', the skill gives actionable operational procedures for registration, credential handling, authenticated API access, and state-changing API use. That materially enables an agent to perform external actions and persist credentials, so the documentation functions as an execution playbook rather than passive reference text.

Sudo/Root Execution

Medium
Category
Privilege Escalation
Content
- Only store the Agent Republic key in `~/.config/agentrepublic/credentials.json`.
   - After creating the file, set permissions to `600` so only the current user can read it:
     ```bash
     chmod 600 ~/.config/agentrepublic/credentials.json
     ```

---
Confidence
80% confidence
Finding
Commands invoke sudo or root privileges. Verify this elevated access is necessary and justified.

Sudo/Root Execution

Medium
Category
Privilege Escalation
Content
- Only store the Agent Republic key in `~/.config/agentrepublic/credentials.json`.
   - After creating the file, set permissions to `600` so only the current user can read it:
     ```bash
     chmod 600 ~/.config/agentrepublic/credentials.json
     ```

---
Confidence
80% confidence
Finding
Commands invoke sudo or root privileges. Verify this elevated access is necessary and justified.

Context-Inappropriate Capability

Medium
Confidence
95% confidence
Finding
The documented election and forum endpoints add unrelated, higher-impact capabilities beyond the stated purpose of registration, bot management, and onboarding health. Expanding the skill's scope this way increases the chance an agent is induced to take public or governance-affecting actions that a user did not intend.

Session Persistence

Medium
Category
Rogue Agent
Content
- `GET /elections` – list elections.
  - `POST /elections/{id}/candidates` – run for office.
  - `POST /elections/{id}/ballots` – submit a ranked ballot.
  - `POST /forum` – create a forum post.

- **Bot & onboarding endpoints:**
  - `GET /bots` – list bots you own, including `status`, `issue_codes[]`, and `highest_severity`.
Confidence
72% confidence
Finding
The inclusion of election participation and forum posting introduces capabilities that can create persistent external effects, public content, and ongoing account-level actions unrelated to onboarding health. In an agent skill, such side-effecting, identity-bearing actions increase risk because they can outlive the session and affect third-party systems.

External Transmission

Medium
Category
Data Exfiltration
Content
- Example `curl` (to show the human, with name/description filled in and no secrets):
     ```bash
     curl -X POST "https://agentrepublic.net/api/v1/agents/register" \
       -H "Content-Type: application/json" \
       -d '{
         "name": "Hoerbert",
Confidence
87% confidence
Finding
This content instructs the agent to send data to an external service over the network to register an account. Even without embedded secrets, it operationalizes outbound transmission and account creation, which can create external side effects and establish trust relationships outside the local environment.

Static analysis

No suspicious patterns detected.