T09 · Insecure Skill Coding Practices
- Location
SKILL.md:19- Finding
Environment-Configured Provider Bypasses the Declared Devnet Connection
- Content
View full analysis
Vulnerability Details
File Location:
SKILL.md, lines 19–21
Vulnerability Type: Provider and network configuration mismatch
Risk Level: Mediumts const connection = new Connection("https://api.devnet.solana.com", "confirmed"); const provider = AnchorProvider.env(); const program = new Program(idl as any, programId, provider);Technical Analysis
The example creates an explicit Solana devnet
connection, but never passes it to the Anchor provider. Instead,AnchorProvider.env()obtains the RPC endpoint and wallet from ambient environment variables such asANCHOR_PROVIDER_URLandANCHOR_WALLET.Therefore, the code does not enforce the Skill's stated devnet-only scope. The
Programinstance uses the environment-derived provider rather than the declared devnet connection. If those environment variables are stale, misconfigured, or attacker-controlled, operations can be routed through an unintended or malicious RPC endpoint and use an unintended local wallet. The example also lacks cluster identity verification and explicit confirmation of the selected wallet and network before transaction signing.Attack Path
- An attacker, compromised development environment, shell initialization file, or automation configuration changes
ANCHOR_PROVIDER_URLorANCHOR_WALLET. - The user follows the documented example under the assumption that the hardcoded devnet connection will be used.
AnchorProvider.env()loads the influenced RPC URL and wallet path.- The unused
connectionvariable provides no protection or network enforcement. - Subsequent method calls query chain state or submit signed transactions through the unintended provider.
- A malicious RPC service may return deceptive state or transaction data, collect transaction metadata, or interfere with transaction submission. If the selected wallet and referenced program are valid on another cluster, a transaction may also be submitted ...[truncated 678 chars]
- An attacker, compromised development environment, shell initialization file, or automation configuration changes
- Remediation
View remediation
Remediation Suggestions
- Construct the provider explicitly with the declared connection instead of using
AnchorProvider.env():ts const connection = new Connection("https://api.devnet.solana.com", "confirmed"); const wallet = /* explicitly selected and validated wallet */; const provider = new AnchorProvider(connection, wallet, { commitment: "confirmed", }); const program = new Program(idl as any, programId, provider); - Require deliberate wallet selection rather than silently accepting an ambient
ANCHOR_WALLETvalue. - Verify the RPC cluster identity, such as its genesis hash, before reading state or requesting a signature.
- Display the selected RPC endpoint, cluster, wallet public key, program ID, accounts, instruction data, and expected balance changes before signing.
- Require explicit user confirmation for every state-changing transaction.
- Validate that the loaded IDL declares the expected program address and obtain the IDL from a pinned, trusted project artifact.
- Package or otherwise make available the referenced
idl.jsonandthe_trench.tsfiles so that the complete client interface can be reviewed and integrity-checked.
- Construct the provider explicitly with the declared connection instead of using
