Back to skill

Security audit

MetaMask Smart Accounts KIt

Security checks for vulnerabilities and agentic risk

Overview

This is a coherent MetaMask smart-accounts developer guide, but its examples can authorize automated blockchain transactions if copied into real apps.

Install only if you are comfortable using developer guidance for smart accounts and delegated blockchain permissions. Treat all transaction and permission examples as capable of moving tokens, spending gas or sponsored gas, deploying contracts, or enabling recurring automated actions until expiry or revocation. Use testnets first, verify chain IDs, addresses, calldata, limits, and expiry values, and use secure signer custody rather than plaintext production private keys in environment variables.

Vulnerability Patterns
  • Insecure DependenciesIntroduces malicious components through unsafe dependency sources
  • 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
Findings (2)

T09 · Insecure Skill Coding Practices

Warning
Location
SKILL.md:550
Finding

Plaintext Session Private Key in Process Environment

Content
View full analysis

Vulnerability Details

File Location: SKILL.md, lines 550-556
Vulnerability Type: Plaintext sensitive-data handling
Risk Level: Medium

typescript
// Session account created from various sources
const sessionAccount = privateKeyToAccount(
  process.env.SESSION_KEY || generatePrivateKey() || hsmWallet.key
)

Technical Analysis

The skill recommends loading a wallet private key from the SESSION_KEY environment variable. Environment variables are plaintext process configuration and may be exposed through process inspection, CI/CD settings, diagnostic output, crash reports, support bundles, container metadata, or accidental logging.

This is especially sensitive because the resulting account is intended to redeem ERC-7710 or ERC-7715 delegations without repeated user interaction. Although caveats can constrain the delegated authority, possession of the session key gives an attacker the same authority as the legitimate automation service for every active delegation associated with that account.

The fallback expression also contains a logic flaw: when SESSION_KEY is absent, generatePrivateKey() returns a private key and is therefore truthy. Consequently, hsmWallet.key is unreachable under normal behavior. Moreover, an HSM integration should expose signing operations rather than export raw private-key material as hsmWallet.key.

Attack Path

  1. A user follows the skill and stores a session-account private key in SESSION_KEY.
  2. An attacker obtains access to the process environment through compromised CI/CD access, process diagnostics, container inspection, a crash dump, or another local information-disclosure path.
  3. The attacker extracts SESSION_KEY and reconstructs the session account using privateKeyToAccount.
  4. The attacker obtains or observes an active permission context or signed delegation associated with that session account.
  5. The attacker submits delegated transactions or ...[truncated 871 chars]
Remediation
View remediation

Remediation Suggestions

  1. Require an HSM, cloud KMS, or server-wallet integration that performs signing internally and never exports raw private-key material.
  2. Do not recommend persistent private keys in environment variables. If ephemeral keys are supported, generate them with a cryptographically secure library, retain them only in memory, and clearly define rotation and recovery behavior.
  3. Replace the fallback chain with explicit signer-source selection and fail closed when the configured secure signer is unavailable.
  4. Model the HSM signer as a signing interface rather than accessing hsmWallet.key.
  5. Grant session accounts narrowly scoped authority with short expiry periods, low spending limits, explicit targets and methods, redeemer restrictions, and limited call counts.
  6. Implement key rotation, delegation revocation, access auditing, and alerts for unexpected redemptions.
  7. Prevent secrets from appearing in logs, telemetry, crash dumps, CI output, and support bundles.

A safer design is:

typescript
if (!kmsSigner) {
  throw new Error('A non-exportable KMS or HSM signer is required')
}

const sessionAccount = createAccountFromSigner(kmsSigner)

T08 · Insecure Dependencies

Note
Location
SKILL.md:374
Finding

Unpinned Permissionless SDK Installation

Content
View full analysis

Vulnerability Details

File Location: SKILL.md, lines 374-377
Vulnerability Type: Mutable third-party dependency installation
Risk Level: Low

bash
npm install permissionless

Technical Analysis

The installation instruction does not specify an exact permissionless package version. It therefore resolves the registry version selected at installation time rather than a version reviewed alongside this skill. This makes generated projects less reproducible and allows their effective dependency contents to change without any modification to the audited skill.

The package name is obtained from the standard npm registry rather than an obviously malicious or typosquatted source, so there is no evidence that the current dependency is malicious. The risk arises from mutable resolution: a future compromised, malicious, or incompatible release could be installed automatically. npm dependencies may execute lifecycle scripts during installation and subsequently run with the privileges of the developer, build agent, or application process.

Attack Path

  1. A developer or automated agent follows the documented installation command.
  2. The npm registry resolves permissionless to a release that was not reviewed with this skill.
  3. An upstream maintainer account, publishing token, package release, or transitive dependency is compromised, or a future release introduces malicious behavior.
  4. npm downloads the affected release.
  5. Malicious code executes through an installation lifecycle script or when the dependency is imported by the application.
  6. The code gains access to resources available to the npm or application process, potentially including source code, build credentials, wallet configuration, and deployment secrets.

Impact Assessment

Exploitation could execute code with the privileges of the developer workstation, CI runner, build container, or deployed application using the dependency. The res ...[truncated 370 chars]

Remediation
View remediation

Remediation Suggestions

  1. Pin permissionless to an exact version that has been tested and reviewed, without ^, ~, or wildcard ranges:
bash
npm install --save-exact permissionless@<reviewed-version>
  1. Commit the generated lockfile and use npm ci in CI/CD and production builds.
  2. Verify package integrity, publisher provenance, release history, and transitive dependencies before adopting the selected version.
  3. Use dependency scanning and automated alerts, but require review before upgrading security-sensitive wallet and account-abstraction libraries.
  4. Disable npm lifecycle scripts where they are unnecessary, such as with npm ci --ignore-scripts, after confirming that required dependencies do not rely on them.
  5. Run dependency installation and builds in isolated, least-privileged environments without production wallet keys or unrelated deployment credentials.
Vulnerability Patterns
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
  • 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
  • Supply ChainUnpinned Dependencies, External Script Fetching, Obfuscated Code
Findings (12)

Anti-Refusal Statement

High
Category
Anti-Refusal
Confidence
80% confidence
Finding

Skill instructs the agent to omit warnings, disclaimers, or ethical commentary. Stripping safety caveats hides risk from the user and is a common jailbreak preamble.

Content

Scanner excerpt · references/delegations.md (reported line 290)May include surrounding context.

md
**⚠️ IMPORTANT:** Without caveats, delegations have infinite authority. Always use caveat enforcers.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

These examples perform delegation redemption and transaction submission without an explicit warning that they can execute irreversible on-chain actions and transfer tokens. Because this skill is specifically for smart accounts, delegations, and gasless execution, users may copy-paste examples into production-like contexts and unintentionally authorize asset movement or incur financial loss.

Content

No source excerpt is available for this finding.

Autonomous Decision Making

Medium
Category
Excessive Agency
Confidence
85% confidence
Finding

Skill enables autonomous high-impact decisions without human-in-the-loop verification. Critical operations (destructive commands, financial transactions, data deletion) should require explicit user confirmation.

Content

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

md
- `redeemer` - Limit redemption to specific addresses
- `id` - One-time delegation with ID
- `nonce` - Bulk revocation via nonce
- `deployed` - Auto-deploy contract
- `ownershipTransfer` - Ownership transfer only
- `nativeTokenPayment` - Require payment
- `nativeBalanceChange` - Validate native balance

Autonomous Decision Making

Medium
Category
Excessive Agency
Confidence
85% confidence
Finding

Skill enables autonomous high-impact decisions without human-in-the-loop verification. Critical operations (destructive commands, financial transactions, data deletion) should require explicit user confirmation.

Content

Scanner excerpt · references/delegations.md (reported line 589)May include surrounding context.

md
- `redeemer` - Limit redemption to specific addresses
- `id` - One-time delegation with ID
- `nonce` - Bulk revocation via nonce
- `deployed` - Auto-deploy contract
- `ownershipTransfer` - Ownership transfer only
- `nativeTokenPayment` - Require payment
- `nativeBalanceChange` - Validate native balance

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
93% confidence
Finding

The session account example normalizes loading a private key from an environment variable and even combines it with ad hoc key generation in a single expression, but it provides no warning about secure key custody, logging exposure, CI/CD leaks, or the risks of storing hot keys on backend infrastructure. In this skill’s context, those keys can redeem delegations and move assets within granted scopes, so unsafe handling can directly lead to unauthorized on-chain actions and fund loss.

Content

No source excerpt is available for this finding.

Autonomous Decision Making

Medium
Category
Excessive Agency
Confidence
85% confidence
Finding

Skill enables autonomous high-impact decisions without human-in-the-loop verification. Critical operations (destructive commands, financial transactions, data deletion) should require explicit user confirmation.

Content

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

md
**`0xb9f0f171` — InvalidDelegator()**
- **Cause:** Attempting to enable/disable from wrong address, or counterfactual account
- **Fix:** Only delegator can enable/disable; for counterfactual, first UserOp auto-deploys

**`0x05baa052` — CannotUseADisabledDelegation()**
- **Cause:** Delegation was disabled by delegator

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
90% confidence
Finding

This example explicitly promotes daily automated token swaps redeemed by a backend using delegated permissions, but it does not clearly warn that the approval enables ongoing asset movement after the initial consent. In a Web3 wallet context, omission of this warning can normalize dangerous patterns and lead developers to implement flows where users do not fully understand that a dapp-controlled session account can continue moving approved assets until expiry or revocation.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
89% confidence
Finding

The gaming example requests recurring native-token spending for in-game purchases, but it does not plainly state that the permission allows repeated ETH transfers over time. Because native token losses are immediate and broadly usable, insufficient warning in this context increases the risk that developers ship consent flows that under-communicate recurring spending authority to end users.

Content

No source excerpt is available for this finding.

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
89% confidence
Finding

The documentation includes an example that signs a delegation using a raw private key but does not warn readers against embedding secrets in source code, committing them to repositories, or exposing them in client-side contexts. In a Web3 permissions system, misuse of a private key directly compromises the signing authority and can enable unauthorized delegation creation or asset movement.

Content

No source excerpt is available for this finding.

Whitespace Padding

Medium
Category
Prompt Injection
Confidence
70% confidence
Finding

Large whitespace padding was detected (a block of blank lines or a long run of spaces). This can push injected instructions below or to the right of the visible area so a human reviewer never sees them while the agent still reads them. Manual review of the hidden content is recommended.

Content

Scanner excerpt · references/smart-accounts.md (reported line 11)May include surrounding context.

md
### Core Concepts

| Concept                  | Description                                                                                            |
| ------------------------ | ------------------------------------------------------------------------------------------------------ |
| **User Operation**       | Package of instructions signed by user, specifying executions for the smart account                    |
| **Bundler**              | Service that collects user operations, packages them into a single transaction, and submits to network |

Missing User Warnings

Medium
Category
Not specified by scanner
Confidence
95% confidence
Finding

The document shows how to deploy a smart account by sending a user operation, which can create on-chain state changes and consume gas or sponsored gas, but it does not clearly warn users that this action may spend funds or trigger irreversible blockchain effects. In a Web3 developer skill focused on account deployment and transaction submission, omission of this warning increases the chance that users copy and run code without understanding financial and state consequences.

Content

No source excerpt is available for this finding.

Excessive Permissions

Low
Category
Privilege Escalation
Confidence
80% confidence
Finding

Skill requests more permissions than appear necessary for its stated functionality. Review if elevated access is justified.

Content

Scanner excerpt · references/advanced-permissions.md (reported line 490)May include surrounding context.

Extending Clients

Wallet Client for Requesting Permissions:

typescript
import { erc7715ProviderActions } from '@metamask/smart-accounts-kit/actions'

Static analysis

No suspicious patterns detected.