T09 · Insecure Skill Coding Practices
Warning
- Location
- src/index.ts:29
- Finding
- Privileged Wallet Signer Trusts an Unrestricted RPC Endpoint<![CDATA[ ## Vulnerability Details **File Location**: `src/index.ts`, lines 29-41 **Vulnerability Type**: Unrestricted external trust boundary around a privileged transaction signer **Risk Level**: Medium ### Complete Code Snippet ```typescript const privateKey = process.env.XPR_PRIVATE_KEY; const account = process.env.XPR_ACCOUNT; const permission = process.env.XPR_PERMISSION || 'active'; const rpcEndpoint = process.env.XPR_RPC_ENDPOINT; if (!privateKey) throw new Error('XPR_PRIVATE_KEY is required for NFT write operations'); if (!account) throw new Error('XPR_ACCOUNT is required for NFT write operations'); if (!rpcEndpoint) throw new Error('XPR_RPC_ENDPOINT is required for NFT write operations'); const { Api, JsonRpc, JsSignatureProvider } = await import('@proton/js'); const rpc = new JsonRpc(rpcEndpoint); const signatureProvider = new JsSignatureProvider([privateKey]); const api = new Api({ rpc, signatureProvider }); ``` ### Technical Analysis The Skill accepts `XPR_RPC_ENDPOINT` directly from the environment without enforcing HTTPS, verifying the endpoint hostname, pinning the expected chain ID, or otherwise establishing that the endpoint belongs to the intended XPR network. The RPC client is then connected to a signing API holding the wallet's private key. The code does not explicitly transmit the raw private key through `fetch`. The key is provided locally to `JsSignatureProvider`, while signed transactions and public transaction details are sent to the configured RPC endpoint. Nevertheless, the RPC endpoint supplies chain state and ABI information used during transaction construction and serialization. A malicious or compromised endpoint could return deceptive chain information, malicious ABI data, or incorrect transaction context. The default permission is `active`, which is commonly broader than the NFT-specific authority required by this Skill. Consequently, the signer may possess more authority than the declared AtomicAssets and AtomicMarket ...[truncated 1461 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Require RPC endpoints to use HTTPS and reject plaintext HTTP URLs. 2. Maintain an allowlist of trusted XPR mainnet and testnet RPC hostnames. Require explicit administrative approval for custom endpoints. 3. Query and verify the chain ID against a pinned expected value before enabling any signing operation. 4. Verify that configured contract accounts and network selection match the intended XPR deployment. 5. Use a dedicated wallet key with a custom permission restricted to the necessary `atomicassets`, `atomicmarket`, and approved token-contract actions. 6. Do not default to `active`; require an explicitly configured restricted permission for production writes. 7. Separate read-only RPC configuration from the transaction-submission endpoint so an untrusted read provider cannot automatically become part of the signing workflow. 8. Document the RPC trust boundary and warn operators that the endpoint participates in transaction construction and submission. ]]>
