Back to skill

Security audit

clawmegle staking

Security checks for vulnerabilities and agentic risk

Overview

This staking skill mostly does what it says, but it handles real wallet transactions and credentials with weak safeguards and contains an exploitable shell/Python input-handling flaw.

Review carefully before installing. Use only a low-value dedicated wallet or tightly scoped Bankr key, restrict config-file permissions, verify contract addresses independently, and require human confirmation before any approve, stake, unstake, claim, or reward-deposit transaction. Do not pass untrusted amounts to deposit-rewards.sh until its input parsing is fixed.

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

Error
Location
scripts/deposit-rewards.sh:34
Finding
Arbitrary Python Code Execution Through Unsanitized Reward Amounts<![CDATA[ ## Vulnerability Details **File Location**: `scripts/deposit-rewards.sh`, lines 34–36 **Vulnerability Type**: Command injection through dynamically constructed Python source **Risk Level**: High ### Vulnerable Code ```bash # Convert amounts to wei ETH_WEI=$(python3 -c "print(int(float('$ETH_AMOUNT') * 10**18))") CLAWMEGLE_WEI=$(python3 -c "print(int(float('$CLAWMEGLE_AMOUNT') * 10**18))") ``` Related unsafe interpolation also occurs at lines 47 and 68: ```bash CLAWMEGLE_HEX=$(python3 -c "print(format($CLAWMEGLE_WEI, '064x'))") ``` ### Technical Analysis The script accepts `ETH_AMOUNT` and `CLAWMEGLE_AMOUNT` from command-line arguments and directly inserts them into source code supplied to `python3 -c`. Shell quoting does not make this safe because the untrusted value becomes part of the Python program. A crafted argument can terminate the Python string passed to `float()`, add another Python statement, and comment out or otherwise neutralize the remaining syntax. Python then executes the injected statement with the privileges of the user running the script. The script performs no strict decimal validation before constructing the Python program. Consequently, this is not limited to malformed numeric input or denial of service; it creates a general local code-execution primitive. The subsequent interpolation of `CLAWMEGLE_WEI` into additional Python source should also be removed as a defense-in-depth measure. ### Attack Path 1. An attacker influences an argument passed to `scripts/deposit-rewards.sh`. This may occur through direct invocation, an automation workflow, or an agent that forwards an untrusted amount. 2. The attacker supplies text that closes the quoted Python value and introduces an additional Python statement, such as importing an operating-system interface and invoking a local command. 3. Bash substitutes the crafted value into the `python3 -c` source string. 4. Python parses and executes the injected statement while converting ...[truncated 1134 chars]
Remediation
<![CDATA[ ## Remediation Suggestions Never interpolate untrusted values into executable Python source. Pass each amount as a positional argument and parse it as data: ```bash ETH_WEI=$(python3 - "$ETH_AMOUNT" <<'PY' from decimal import Decimal, InvalidOperation import re import sys raw = sys.argv[1] if not re.fullmatch(r"(?:0|[1-9][0-9]*)(?:\.[0-9]{1,18})?", raw): raise SystemExit("Invalid ETH amount") try: value = Decimal(raw) except InvalidOperation: raise SystemExit("Invalid ETH amount") if value < 0: raise SystemExit("Amount must not be negative") wei = value * Decimal(10**18) if wei != wei.to_integral_value(): raise SystemExit("Amount has more than 18 decimal places") print(int(wei)) PY ) ``` Apply equivalent validation to `CLAWMEGLE_AMOUNT`. Additional hardening should include: 1. Use `decimal.Decimal` rather than binary floating-point arithmetic to avoid rounding errors in financial values. 2. Reject negative values, signs, exponent notation, `NaN`, infinity, whitespace, and more than 18 decimal places. 3. Enforce an application-appropriate maximum amount to prevent oversized transactions and resource abuse. 4. Pass `CLAWMEGLE_WEI` as a Python argument when formatting it, rather than embedding it in Python source: ```bash CLAWMEGLE_HEX=$(python3 - "$CLAWMEGLE_WEI" <<'PY' import sys value = int(sys.argv[1]) if value < 0 or value >= 2**256: raise SystemExit("Amount is outside uint256 range") print(format(value, "064x")) PY ) ``` 5. Add automated tests using malformed input containing quotes, semicolons, newlines, shell metacharacters, exponent notation, negative values, and values outside the `uint256` range. 6. Require explicit transaction confirmation displaying the validated decimal amount, wei amount, chain, token, and destination contract before submitting a deposit. ]]>

T09 · Insecure Skill Coding Practices

Warning
Location
SKILL.md:54
Finding
Transaction-Capable Bankr API Key May Be Stored with Insecure File Permissions<![CDATA[ ## Vulnerability Details **File Location**: `SKILL.md`, lines 54–61; duplicated in `README.md`, lines 47–54 **Vulnerability Type**: Insecure storage permissions for a sensitive API credential **Risk Level**: Medium ### Vulnerable Code ```bash mkdir -p ~/.clawdbot/skills/bankr cat > ~/.clawdbot/skills/bankr/config.json << 'EOF' { "apiKey": "bk_YOUR_API_KEY_HERE", "apiUrl": "https://api.bankr.bot" } EOF ``` ### Technical Analysis The documented setup writes a Bankr API key to a plaintext JSON file without explicitly setting a restrictive `umask`, directory mode, or file mode. The resulting permissions depend on the user's current umask and any pre-existing directory permissions. In an environment with a permissive umask, the configuration file may be readable by members of the user's group or by other local users. The documentation specifically instructs users to enable Bankr “Agent API” access, which is required for transactions, so disclosure may expose more than read-only account information. Plaintext credential storage may be necessary for the dependent tool, but the file should be created with owner-only permissions. The current instructions do not establish that protection. ### Attack Path 1. A user follows the documented configuration steps on a shared system or in an environment with a permissive umask. 2. `config.json` is created with group-readable or world-readable permissions, or it is placed inside a directory that does not sufficiently restrict traversal. 3. Another local user or compromised process enumerates the predictable path `~/.clawdbot/skills/bankr/config.json`. 4. The unauthorized party reads the Bankr API key. 5. The key is used against the Bankr API within the permissions granted to it. 6. If transaction authority is enabled and no additional confirmation control blocks the request, the exposed credential may be used to initiate unauthorized wallet operations. ### Impact Assessment The immediate impact is disclos ...[truncated 774 chars]
Remediation
<![CDATA[ ## Remediation Suggestions Update both `SKILL.md` and `README.md` to create the credential directory and file with explicit owner-only permissions: ```bash install -d -m 700 "$HOME/.clawdbot/skills/bankr" umask 077 cat > "$HOME/.clawdbot/skills/bankr/config.json" <<'EOF' { "apiKey": "bk_YOUR_API_KEY_HERE", "apiUrl": "https://api.bankr.bot" } EOF chmod 600 "$HOME/.clawdbot/skills/bankr/config.json" ``` Additional hardening should include: 1. Verify ownership and permissions before using the credential: ```bash test "$(stat -c '%a' "$HOME/.clawdbot/skills/bankr/config.json")" = "600" || { echo "Refusing to use insecure Bankr config permissions"; exit 1; } ``` 2. Refuse configuration files owned by another user or stored through an unexpected symbolic link. 3. Prefer an operating-system credential store or secret manager if supported by the Bankr integration. 4. Use a dedicated API key with the minimum permissions required for staking operations. 5. Enable transaction confirmation, destination allowlisting, spending limits, and withdrawal restrictions where Bankr supports them. 6. Never include real API keys in documentation, logs, shell history, support requests, or source control. 7. Document immediate key revocation and rotation procedures for suspected disclosure. ]]>
Vulnerability Patterns
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Excessive AgencyUnrestricted Tool Access, Autonomous Decision Making, Scope Creep
  • Rogue AgentSelf-Modification, Session Persistence
  • Trigger AbuseOverly Broad Trigger, Shadow Command Trigger, Keyword Baiting Trigger
  • MCP Tool PoisoningHidden Instructions, Unicode Deception, Parameter Description Injection
Findings (26)

Tp4

High
Category
MCP Tool Poisoning
Confidence
98% confidence
Finding
The declared description is specifically about staking $CLAWMEGLE and managing related rewards. The provided code does not perform staking, reward checks, claims, wallet transactions, or Bankr API calls itself. Instead, it only locates another script on disk and delegates execution to it. That is a materially different primary purpose from the declared staking functionality, so this is a mismatch.

Tp4

High
Category
MCP Tool Poisoning
Confidence
97% confidence
Finding
The declared description presents a user-facing staking management skill: staking tokens, checking rewards, claiming earnings, and managing a staking position. The supplied code does something materially different and much narrower: it funds the staking contract's rewards pool by optionally approving CLAWMEGLE and then calling depositRewards with ETH and token amounts. The script even states that this is not for staking and that staking should use a different script. Depositing protocol rewards is not the same as staking, checking rewards, claiming, or position management, so the primary purpose does not accurately match the code chunk.

Tp4

High
Category
MCP Tool Poisoning
Confidence
92% confidence
Finding
The code chunk’s actual behavior is narrower than the declared description. It performs a two-step staking operation via Bankr: approval plus contract call to stake a specified amount of CLAWMEGLE on Base. There is no implementation for reading reward state, claiming ETH/CLAWMEGLE rewards, unstaking, or other position-management actions. The description also claims support for direct wallet transactions, but this code uses only a Bankr shell wrapper. This is a material description-to-behavior mismatch because the declared purpose presents a broader multi-function staking skill than the supplied code actually provides.

Tp4

High
Category
MCP Tool Poisoning
Confidence
91% confidence
Finding
The code’s primary purpose partially overlaps with the description because it does stake CLAWMEGLE tokens. However, the declared purpose describes a multi-function staking skill with reward checking, earnings claiming, broader position management, and dual support paths (Bankr API plus direct wallet transactions). This specific code chunk only implements one narrow action: direct on-chain staking through cast send using a private key. That makes the description materially broader than the actual behavior of the supplied code chunk.

Ae1

High
Category
analysis-evasion
Content
./scripts/stake-bankr.sh 1000
Confidence
100% confidence
Finding
Referenced artifact was not completely inspected

Ae1

High
Category
analysis-evasion
Content
./scripts/unstake-bankr.sh 500
Confidence
100% confidence
Finding
Referenced artifact was not completely inspected

Missing User Warnings

High
Confidence
98% confidence
Finding
The documentation instructs users to export a private key into the shell environment without a strong warning about key theft, shell history exposure, process inspection, or wallet-draining risk. In an agent-driven setting, encouraging raw private-key handling materially increases the blast radius of any compromise and bypasses safer signing patterns.

Ae1

High
Category
analysis-evasion
Content
- [Bankr Transaction Format](references/bankr-format.md)
Confidence
100% confidence
Finding
Referenced artifact was not completely inspected

Description-Behavior Mismatch

High
Confidence
97% confidence
Finding
The script’s documented purpose is administrative reward funding, not end-user staking, claiming, or position management as described in the skill metadata. In an agent setting, this capability can cause the agent to send ETH and approve/transfer CLAWMEGLE to a staking contract under the guise of normal user operations, creating a dangerous mismatch between declared scope and actual authority.

Context-Inappropriate Capability

High
Confidence
97% confidence
Finding
This code performs privileged reward distributor actions: it approves CLAWMEGLE spending and submits a depositRewards transaction with ETH value to the staking contract. That is materially different from helping a user manage their own staking position, and if exposed through an agent skill it could be abused to drain the operator wallet into protocol reward funding or to execute unintended token approvals.

Missing User Warnings

Medium
Confidence
93% confidence
Finding
The heartbeat instructs the agent to run a claim script automatically once a reward threshold is met, but it does not require explicit user confirmation or prominently warn that claiming is a state-changing onchain transaction. In an autonomous agent setting, this can cause unintended blockchain actions, gas expenditure, and asset movement based only on periodic checks rather than fresh user approval.

Missing User Warnings

Medium
Confidence
95% confidence
Finding
The decision logic says that if the position is staked and the agent 'want[s] to exit,' it should call unstake, but it provides no explicit warning that unstaking is a state-changing transaction that can materially alter the user's position and may have irreversible market or timing consequences. In a staking-management skill, this is especially dangerous because an agent could translate ambiguous intent into immediate onchain execution affecting custody, rewards, and strategy.

Session Persistence

Medium
Category
Rogue Agent
Content
## Setup (One-Time)

### 1. Create Bankr Account

1. Go to **[bankr.bot](https://bankr.bot)** and sign up with email
2. Enter the OTP sent to your email
Confidence
60% confidence
Finding
Skill establishes unauthorized persistence across sessions via cron jobs, startup scripts, or state files. Session persistence allows an attacker to maintain access beyond the current interaction.

Missing User Warnings

Medium
Confidence
95% confidence
Finding
The README instructs users to place a Bankr API key in a local config file but does not warn about credential sensitivity, filesystem permissions, or avoiding source control exposure. Because the key appears to grant agent API access over wallets, leakage could enable unauthorized account actions, balance queries, or transaction initiation depending on API scope.

Missing User Warnings

Medium
Confidence
95% confidence
Finding
The README encourages users to run stake, claim, and unstake scripts but does not clearly warn that these actions submit live on-chain transactions that move assets and consume gas. In a wallet/agent skill context, this can cause users or autonomous agents to trigger irreversible fund movements without adequate operator awareness, increasing the risk of unintended staking, claims, or gas spending.

Description-Behavior Mismatch

Medium
Confidence
94% confidence
Finding
The top-level description omits that the skill can deposit rewards for all stakers, which is materially different from ordinary user staking and claiming. Understating that capability can cause an agent or operator to invoke the skill in a broader-trust context than intended, increasing the chance of unintended fund movement.

Vague Triggers

Medium
Confidence
92% confidence
Finding
The description is broad enough to match generic token-management requests, which can cause over-triggering of a skill that handles financial transactions. In agent systems, ambiguous activation increases the risk of the wrong skill being selected and submitting approvals, staking, or reward-deposit actions in an unintended context.

Session Persistence

Medium
Category
Rogue Agent
Content
### Step 2: Get Your API Key

1. **Go to [bankr.bot/api](https://bankr.bot/api)**
2. **Create a new API key**
3. **Enable "Agent API" access** (required for transactions)
4. **Copy the key** (starts with `bk_`)
Confidence
84% confidence
Finding
The skill tells users to persist a long-lived Bankr API key in a predictable plaintext path under the home directory. Persistent agent-capable credentials stored locally can be reused by malware, other local users, or compromised tooling to initiate transactions or query wallet data without further authentication.

Intent-Code Divergence

Medium
Confidence
89% confidence
Finding
The file makes strong security assurances such as 'No admin keys' and 'Audited patterns' while earlier stating the contract deployment is pending. Security claims about a not-yet-deployed or not-yet-verified contract can create false trust and may lead users to authorize transactions without independent verification of the actual deployed bytecode and ownership model.

Missing User Warnings

Medium
Confidence
94% confidence
Finding
The document provides copy-pastable raw transaction and approval examples for staking, claiming, and unstaking without any safety guidance about verifying contract addresses, calldata, token approvals, chain selection, or the irreversible nature of signed on-chain actions. In an agent skill context, this is more dangerous because an automated system may relay or construct these transactions for users, increasing the chance of accidental fund movement or overbroad approvals without informed confirmation.

Missing User Warnings

Medium
Confidence
91% confidence
Finding
The documentation includes concrete on-chain interaction examples for a staking contract without clearly warning that these functions can trigger irreversible asset movements, token approvals, claims, and gas expenditure. In an agent skill context, this omission is more dangerous because automated systems or users may treat the examples as safe operational guidance and execute value-bearing transactions without sufficient confirmation or risk awareness.

Missing User Warnings

Medium
Confidence
92% confidence
Finding
The script constructs and prints an ERC-20 approve transaction followed by a staking transaction that can move real funds, but it does not present any explicit warning, confirmation step, or summary of the financial consequences. In an agent skill context, this is more dangerous because an automated system may surface or execute these steps with reduced human scrutiny, increasing the chance of accidental irreversible token approval and staking.

Missing User Warnings

Medium
Confidence
88% confidence
Finding
The script requires a raw PRIVATE_KEY in an environment variable and uses it directly for transaction signing. While this is common in automation, it increases the risk of credential exposure through shell history, process environment leakage, CI logs, or accidental reuse in unsafe contexts, especially since the skill is intended for agent-driven wallet operations on mainnet.

Missing User Warnings

Medium
Confidence
96% confidence
Finding
The script performs two live on-chain actions—token approval and staking—without any explicit user confirmation, dry-run summary, or prominent warning that assets will be moved irreversibly. In an agent skill context, this is more dangerous because automated systems may invoke the script with user-supplied amounts or as part of a workflow, making accidental approvals and staking more likely.

Missing User Warnings

Medium
Confidence
95% confidence
Finding
The script directly submits an on-chain unstake transaction using the configured private key without any interactive confirmation, dry-run summary, or explicit warning that this is an irreversible blockchain action. In an agent skill context, this is more dangerous because an automated workflow, prompt injection, or parameter mistake could trigger immediate unstaking and reward claiming without the operator noticing before funds are moved.

Static analysis

No suspicious patterns detected.