Back to skill

Security audit

Yield Farming Agent

Security checks for vulnerabilities and agentic risk

Overview

This skill is a disclosed autonomous DeFi agent, but it can run recurring wallet-signed transactions with weak safety controls and insecure contract/accounting assumptions.

Review carefully before installing. Treat this as testnet-only unless the executor is constrained, the contracts are audited and fixed, private-key handling is hardened, live execution requires explicit approval, and per-cycle spending, gas, contract allowlists, slippage, monitoring, and emergency stop controls are added.

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

T09 · Insecure Skill Coding Practices

Error
Location
contracts/artifacts/build-info/a5d75f9256251cc8c46c7f853791cdf4.json:1
Finding

Repeated harvest calls can drain deposited vault assets

Content
View full analysis
0, "No shares to harvest"); yieldAmount = calculateUserYield(msg.sender); require(yieldAmount > 0, "No yield available"); require( IERC20(underlying).transfer(msg.sender, yieldAmount), "Yield transfer failed" ); accumulatedYield += yieldAmount; return yieldAmount; } function calculateUserYield(address user) public view returns (uint256) { if (shareBalance[user] == 0) { return 0; } uint256 userAssets = calculateAssetsFromShares(shareBalance[user]); return (userAssets * 27) / 100000; } ``` ### Technical Analysis The packaged compiler build information embeds the source of `YieldVault.sol`. Its reward calculation depends only on the caller's current shares. It does not track the caller's previously claimed rewards, reward debt, or elapsed accrual period. Calling `harvest()` transfers tokens to the caller but does not decrease `totalAssets`, clear accrued rewards, or advance a per-user reward checkpoint. Consequently, the same nominal yield remains claimable after every successful call. The transfer is funded from the vault's underlying-token balance, which includes user deposits rather than a separately accounted reward reserve. ### Attack Path 1. The attacker acquires underlying tokens and approves the vault. 2. The attacker deposits enough tokens to receive a positive share balance. 3. The attacker calls `harvest()`. 4. The contract calculates a positive reward from the unchanged share balance. 5. The attacker repeats `harvest()` without waiting for any new yield. 6. Each call transfers additional underlying tokens from the vault. 7. Ca ...[truncated 404 chars]
Remediation
View remediation

T09 · Insecure Skill Coding Practices

Error
Location
contracts/artifacts/build-info/a5d75f9256251cc8c46c7f853791cdf4.json:1
Finding

Compound creates unbacked assets and shares

Content
View full analysis
0, "No shares to compound"); uint256 yieldAmount = calculateUserYield(msg.sender); require(yieldAmount > 0, "No yield to compound"); newShares = calculateSharesFromAssets(yieldAmount); shareBalance[msg.sender] += newShares; totalShares += newShares; totalAssets += yieldAmount; accumulatedYield += yieldAmount; return newShares; } ``` ### Technical Analysis The function increases `totalAssets` and mints shares without receiving tokens or realizing yield from an external protocol. The calculated `yieldAmount` is an accounting value derived from the caller's existing shares; it is not backed by a corresponding increase in the vault's actual underlying-token balance. There is also no reward checkpoint. A caller can repeatedly invoke `compound()` and mint additional shares from the same nominal yield. The newly minted shares then increase the caller's future calculated assets and yield, allowing the discrepancy between accounting and actual token holdings to grow. ### Attack Path 1. The attacker deposits underlying tokens and receives shares. 2. The attacker calls `compound()`. 3. The contract calculates nominal yield without collecting any new tokens. 4. The contract increases both the attacker's shares and `totalAssets`. 5. The attacker repeatedly calls `compound()` to create additional unbacked shares. 6. The attacker withdraws shares while the vault still holds real tokens deposited by other users. 7. The vault eventually becomes insolvent or later withdrawals fail. ### Impact Assessment The flaw allows artificial inflation of a caller's claim on ...[truncated 252 chars]
Remediation
View remediation

T09 · Insecure Skill Coding Practices

Error
Location
tx-executor.js:11
Finding

Autonomous transaction execution lacks chain, destination, spending, gas, and slippage safeguards

Content
View full analysis
Remediation
View remediation

T09 · Insecure Skill Coding Practices

Error
Location
scheduler.js:163
Finding

Scheduler and decision engine use incompatible result schemas

Content
View full analysis
0.3) { return actions; } switch (decision.recommended_action) { case 'HARVEST': case 'COMPOUND': case 'REBALANCE': // ... } ``` ### Technical Analysis `YieldFarmingAgent.decide()` does not return `recommended_action`, `target_vault_id`, `confidence_score`, or `rebalance_risk` at the top level. Its action is represented as `executionRecord.decision.action.action`. The scheduler consequently reads undefined fields. Formatting the undefined confidence value can throw, while safety comparisons against `undefined` evaluate to false rather than rejecting the action. This is a fail-open pattern: absent risk fields do not trigger the intended confidence or risk barriers. The current mismatch generally prevents documented autonomous operation, but partial future integration changes could activate execution while leaving the missing-field checks ineffective. ### Attack Path 1. The scheduler calls `YieldFarmingAgent.decide()`. 2. The engine returns the nested execution-record schema. 3. The scheduler reads nonexiste ...[truncated 669 chars]
Remediation
View remediation

T09 · Insecure Skill Coding Practices

Error
Location
scheduler.js:137
Finding

Scheduler makes decisions without reading the signing wallet's actual position

Content
View full analysis
Remediation
View remediation

T09 · Insecure Skill Coding Practices

Error
Location
scheduler.js:406
Finding

Rebalance confuses asset value with share quantity and performs a non-atomic transfer

Content
View full analysis
Remediation
View remediation

T09 · Insecure Skill Coding Practices

Warning
Location
tx-executor.js:116
Finding

Transaction executor calls do not match the packaged contract interface

Content
View full analysis
Remediation
View remediation

T09 · Insecure Skill Coding Practices

Warning
Location
notifications.js:195
Finding

Arbitrary error context can be transmitted to Telegram without redaction

Content
View full analysis
0) { notifMessage += `\n📋 Context:\n`; Object.entries(context).forEach(([key, value]) => { const valueStr = typeof value === 'string' ? value : JSON.stringify(value); notifMessage += ` • ${key}: \`${valueStr}\`\n`; }); } const result = await this.sendTelegram(notifMessage); } ``` The destination is Telegram: ```javascript const options = { hostname: 'api.telegram.org', port: 443, path: `/bot${this.telegramBotToken}/sendMessage`, method: 'POST' }; ``` ### Technical Analysis `notifyError()` serializes every property in the supplied context and sends the resulting message to Telegram. There is no field allowlist, recursive secret redaction, size limit, or confirmation requirement. The audited scheduler does not currently invoke this method, so a direct private-key exfiltration path from the existing scheduler was not confirmed. Nevertheless, the exported notification API is unsafe for its documented purpose because callers commonly attach configuration objects, request details, stack metadata, provider URLs, or authentication information to error context. The bot token is also included in the HTTPS URL path. This is required by Telegram's API format but makes local HTTP debug logs and proxy logs sensitive. ### Attack Path 1. Notifications are configured with a Telegram bot token and chat ID. 2. An integration catches an error and calls `notif ...[truncated 714 chars]
Remediation
View remediation
Vulnerability Patterns
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
  • Excessive AgencyUnrestricted Tool Access, Autonomous Decision Making, Scope Creep
  • MCP Tool PoisoningHidden Instructions, Unicode Deception, Parameter Description Injection
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
Findings (125)

Missing User Warnings

High
Category
Not specified by scanner
Confidence
97% confidence
Finding

The scheduler is documented as running autonomously every hour through a read-decide-execute loop that can deploy HARVEST, COMPOUND, and REBALANCE transactions, yet there is no clear recurring-execution warning or strong guardrails. Because this is an automated blockchain agent, the lack of warning materially increases the chance of unattended transaction submission, repeated losses, or cascading failures if configuration, decision logic, or upstream data are wrong.

Content

No source excerpt is available for this finding.

Missing User Warnings

High
Category
Not specified by scanner
Confidence
98% confidence
Finding

The 'Next Steps for Full Automation' section gives concrete instructions for unattended transaction execution, private-key signing, scheduled execution, and notification wiring without requiring human approval, guardrails, or warning language. In the context of an autonomous DeFi agent, this directly facilitates deployment of a bot that can move assets continuously based on incomplete or manipulated inputs, turning design flaws or bad assumptions into repeated on-chain losses.

Content

No source excerpt is available for this finding.

Credential Access

High
Category
Privilege Escalation
Confidence
60% confidence
Finding

Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Content

Scanner excerpt · RESPUESTAS_PREGUNTAS.md (reported line 126)May include surrounding context.

md
cat > .gitignore << 'EOF'
node_modules/
.env
.env.local
*.log
.DS_Store
dist/

Credential Access

High
Category
Privilege Escalation
Confidence
60% confidence
Finding

Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.

Content

Scanner excerpt · contracts/DEPLOYMENT.md (reported line 473)May include surrounding context.

md
cat > .gitignore << 'EOF'
node_modules/
.env
.env.local
*.log
.DS_Store
dist/

Tp4

High
Category
MCP Tool Poisoning
Confidence
97% confidence
Finding

The description suggests an autonomous yield farming agent that makes decisions and executes actions on BNB Chain. The code does not implement agent behavior, strategy logic, or deterministic execution of farming transactions. Instead, it is a read-only blockchain reader for BNB testnet contracts: it loads contract instances, queries vault/user data, listens to events, and performs non-transactional simulations. While smart contract integration on BNB Chain is present, the primary purpose is materially narrower and different from the declared autonomous yield farming functionality.

Content

No source excerpt is available for this finding.

Tp4

High
Category
MCP Tool Poisoning
Confidence
98% confidence
Finding

The declared description describes a fully functional autonomous yield farming agent operating on BNB Chain. However, the supplied code chunk is only a TypeScript declaration file for a contract ABI export. It defines type-level/module-level exports and does not implement farming logic, transaction execution, decision-making, chain access, triggers, or any runtime smart contract interactions. This is a material mismatch in primary purpose and implemented capabilities.

Content

No source excerpt is available for this finding.

Tp4

High
Category
MCP Tool Poisoning
Confidence
94% confidence
Finding

The description claims an autonomous yield farming agent, but the code chunk is just an ABI specification describing callable contract functions and events for a vault. While the ABI is related to yield farming and smart contract integration at an interface level, it does not itself implement an agent, decision logic, scheduling, execution flow, or BNB Chain-specific behavior. Therefore the declared description materially overstates what this code actually does.

Content

No source excerpt is available for this finding.

Tp4

High
Category
MCP Tool Poisoning
Confidence
95% confidence
Finding

The declared description suggests an operational autonomous yield farming agent that interacts with smart contracts and makes automated execution decisions on BNB Chain. The supplied code instead is a deployment helper/stub: it loads environment variables, defines an ABI and vault configuration mapping, checks account balance, simulates per-vault deployment readiness, and saves a JSON report. Although it references smart contract integration concepts and BNB Testnet resources, its primary purpose is deployment preparation/documentation rather than autonomous yield farming. There are no triggers, scheduling, strategy logic, on-chain deposit/withdraw/harvest/compound calls, or decision-making mechanisms implemented. Therefore the description materially overstates and misrepresents the actual behavior.

Content

No source excerpt is available for this finding.

Tp4

High
Category
MCP Tool Poisoning
Confidence
98% confidence
Finding

The supplied code does not implement a yield farming agent or any autonomous on-chain strategy behavior. It only defines project configuration for Hardhat: compiler options, network endpoints, account loading from environment variables, chain IDs, local/testnet settings, and block explorer verification configuration. While this may support smart contract development on BNB Chain, it is not itself an autonomous agent, does not perform yield farming, and contains no execution or decision-making logic. Therefore the description materially overstates and misrepresents the actual behavior of this code chunk.

Content

No source excerpt is available for this finding.

Tp4

High
Category
MCP Tool Poisoning
Confidence
98% confidence
Finding

The declared description suggests a full autonomous yield farming agent operating on BNB Chain, likely involving strategy logic, contract interactions, and automated execution. The supplied code does not perform yield farming, strategy management, or transactional smart contract operations. Instead, it is a utility script for checking a deployer wallet's BNB Testnet balance and current gas price, then estimating deployment cost. This is a materially different primary purpose, so the description does not accurately represent the code.

Content

No source excerpt is available for this finding.

Tp4

High
Category
MCP Tool Poisoning
Confidence
98% confidence
Finding

The declared description suggests an operational autonomous yield farming agent that would make decisions and interact with deployed contracts to execute farming strategies. The supplied code does not implement such behavior. Instead, it is a deployment utility script for Hardhat that iterates over static vault configurations, deploys YieldVault contracts, checks wallet balance, logs results, and saves deployment data locally. While this does involve smart contract integration on BNB Testnet, the primary purpose is materially different from an autonomous agent, and there is no evidence of deterministic strategy execution or automated decision-making. Therefore the description does not accurately represent the code chunk.

Content

No source excerpt is available for this finding.

Tp4

High
Category
MCP Tool Poisoning
Confidence
98% confidence
Finding

The supplied code does not implement an autonomous yield farming agent. It does not connect to BNB Chain, monitor conditions, make decisions, or execute smart contract transactions. Instead, it is a development/build-time helper that writes ABI-related files and documentation to the local filesystem. While the embedded ABI describes vault functions like deposit, withdraw, harvest, and compound, the script itself only exports metadata and usage docs; it does not perform those actions. Therefore the declared description materially overstates and misrepresents the code’s actual behavior.

Content

No source excerpt is available for this finding.

Tp4

High
Category
MCP Tool Poisoning
Confidence
91% confidence
Finding

The core theme matches yield-farming decision-making: the code evaluates vaults, applies APR/risk logic, and outputs action recommendations. However, the declared description materially overstates behavior. There is no on-chain connectivity, RPC usage, wallet/signing, contract calls, or transaction submission, so 'smart contract integration' and practical 'autonomous yield farming' are not implemented. The code is an off-chain policy/decision module plus audit-hash generation and verification. It also claims deterministic execution, but the output includes a live timestamp and cycle number derived from Date.now(), so results are not fully deterministic across runs for identical inputs. Therefore the description does not accurately represent what the code chunk actually does.

Content

No source excerpt is available for this finding.

Tp4

High
Category
MCP Tool Poisoning
Confidence
98% confidence
Finding

The declared description presents the skill as a BNB Chain autonomous yield farming agent with deterministic execution, contract integration, and automated decision-making. However, the supplied code chunk is specifically a notification subsystem: it formats and sends Telegram messages over HTTPS, logs notification events to a local file, tracks APR-change thresholds for alerts, and exposes notification history/stats. It does not implement yield farming, blockchain interaction, smart contract calls, or autonomous execution logic. While notifications could be a supporting component of such an agent, this chunk itself performs materially different behavior and uses undeclared resources (Telegram network access and local file writes). Therefore this code does not accurately match the declared purpose.

Content

No source excerpt is available for this finding.

Tp4

High
Category
MCP Tool Poisoning
Confidence
96% confidence
Finding

The declared description presents the skill as an operational autonomous yield farming agent with deterministic execution, smart contract integration, and automated decision-making on BNB Chain. However, the supplied code chunk is specifically a test file (test.js) whose primary purpose is validating another module's behavior using mock data. While the tests do exercise decision-making logic and determinism-related properties, the code shown does not itself execute farming strategies, interact with smart contracts, or access BNB Chain resources. This is a material description-behavior mismatch because the actual chunk's primary function is testing, not autonomous yield farming.

Content

No source excerpt is available for this finding.

Tp4

High
Category
MCP Tool Poisoning
Confidence
93% confidence
Finding

The declared description presents the skill as the autonomous yield farming agent itself, implying operational decision-making and smart contract integration on BNB Chain. However, the supplied code chunk is specifically a test script (test.live.mock.js) for mocked/offline validation. Its primary function is to run tests against configuration, mock data, agent decision output, hash verification, ABI events, and risk filtering, then report results. While it does call YieldFarmingAgent.decide() and verifyRecord(), this is in a testing context with static mock inputs and no live RPC or contract execution. Therefore the code chunk's actual purpose is materially different from the declared operational agent behavior.

Content

No source excerpt is available for this finding.

Credential Access

High
Category
Privilege Escalation
Confidence
88% confidence
Finding

The setup instructions direct users to create and edit a .env.local file for configuration, which strongly implies storage of sensitive data such as RPC credentials, bot tokens, or wallet-related secrets. In an autonomous on-chain agent context, encouraging secret handling through local environment files without accompanying hardening guidance increases the chance of credential leakage, accidental commits, or compromise leading to unauthorized transactions or monitoring abuse.

Content

Scanner excerpt · SKILL.md (reported line 31)May include surrounding context.

1. Configure

bash
cp config.deployed.json .env.local
# Edit with your contract addresses and RPC endpoint

Ae1

High
Category
analysis-evasion
Confidence
100% confidence
Finding

Referenced artifact was not completely inspected

Content

Scanner excerpt · SKILL.md (reported line 140)May include surrounding context.

md
- `SKILL.md` - This file

Missing User Warnings

High
Category
Not specified by scanner
Confidence
96% confidence
Finding

The document advertises autonomous transaction execution for deposit, withdraw, harvest, compound, and rebalance actions without a prominent warning that the system can move funds on-chain without per-action user approval. In a DeFi agent context, normalizing unattended execution materially increases the risk of unintended financial loss from bad strategy logic, compromised config, wrong vault addresses, or operator misunderstanding.

Content

No source excerpt is available for this finding.

Missing User Warnings

High
Category
Not specified by scanner
Confidence
98% confidence
Finding

The usage example calls scheduler.start() immediately after initialization, which encourages operators to enable unattended transaction execution with minimal friction and no nearby warning. In this skill's context, that can directly trigger live on-chain actions and losses if the configuration, vault set, wallet, or network selection is wrong.

Content

No source excerpt is available for this finding.

Credential Access

High
Category
Privilege Escalation
Confidence
91% confidence
Finding

Creating and relying on a .env file for deployment secrets is a real credential-handling risk in this context because the same guide later instructs users to place a private key there. For autonomous yield-farming infrastructure, compromise of local plaintext secrets can enable wallet takeover and unauthorized contract interactions.

Content

Scanner excerpt · contracts/DEPLOYMENT.md (reported line 91)May include surrounding context.

bash
cd contracts
cp .env.example .env

2. Edit .env with Your Values

Credential Access

High
Category
Privilege Escalation
Confidence
93% confidence
Finding

Telling users to open .env directly for editing is part of a workflow that handles raw private keys in plaintext on disk. In this agent's smart-contract deployment context, that raises the risk of accidental exposure through editors, swap files, backups, malware, or shoulder-surfing.

Content

Scanner excerpt · contracts/DEPLOYMENT.md (reported line 97)May include surrounding context.

2. Edit .env with Your Values

bash
nano .env
# or
vim .env

Credential Access

High
Category
Privilege Escalation
Confidence
93% confidence
Finding

The instruction to fill .env with sensitive values, including a raw private key, creates a credential exposure issue rather than merely referencing configuration. Because this project concerns blockchain automation, any leaked deployer key can be immediately abused for transactions and fund theft.

Content

Scanner excerpt · contracts/DEPLOYMENT.md (reported line 99)May include surrounding context.

bash
nano .env
# or
vim .env

Fill in:

Credential Access

High
Category
Privilege Escalation
Confidence
94% confidence
Finding

The troubleshooting advice explicitly encourages inspecting .env for PRIVATE_KEY presence, reinforcing a plaintext secret workflow. This increases the chance of exposing or mishandling the key during debugging, especially on shared terminals, recorded sessions, or compromised workstations.

Content

Scanner excerpt · contracts/DEPLOYMENT.md (reported line 382)May include surrounding context.

1. "PRIVATE_KEY is not set"

bash
# Ensure .env file exists and has PRIVATE_KEY
cat .env | grep PRIVATE_KEY

# Should output: PRIVATE_KEY=1234567890...

Credential Access

High
Category
Privilege Escalation
Confidence
95% confidence
Finding

Showing expected output that includes the PRIVATE_KEY value normalizes printing or revealing secret material during troubleshooting. Even partial examples can encourage unsafe operator behavior that leads to shell scrollback, logs, screenshots, or terminal recording leaks.

Content

Scanner excerpt · contracts/DEPLOYMENT.md (reported line 383)May include surrounding context.

bash
# Ensure .env file exists and has PRIVATE_KEY
cat .env | grep PRIVATE_KEY

# Should output: PRIVATE_KEY=1234567890...