Summary
Togoder Security scanned the npm package x402@0.7.3 on Oct 4, 2026. An AI review of 23 source files produced 10 medium, 22 low severity findings. The overall verdict is medium: the findings flag risky but common patterns (dynamic code, unsafe defaults, broad file or network access) rather than confirmed malware.
Findings 32
Transaction signing and submission
NPS-CC1F85C4E27E
The library signs and submits blockchain transactions (EVM writeContract for transferWithAuthorization, Solana signTransactionWithSigner/sendTransaction). This is core functionality for a payment protocol library, but represents high-impact financial operations that could be abused if the signing key is compromised.
Insecure Cryptographic Key Handling
NPS-F5AE4A0B0DD1
The function createSignerFromBase58 accepts a private key directly as a base58 string and decodes it using base58.decode. While this is a legitimate pattern for Solana wallets, handling raw private keys in source code (even from external input) carries risk if the key is logged, leaked, or intercepted. No direct exfiltration detected, but it is a sensitive operation.
external network dependency
NPS-06AE0617A23F
The module imports several functions from sibling chunks (chunk-SQV4BQTM.mjs, chunk-3EQVFRKV.mjs, chunk-K4TZLEOT.mjs) that are not shown in this file. The actual wallet signing implementations (createPaymentHeader, signPaymentHeader) reside in chunk-SQV4BQTM.mjs and are not audited here. Malicious behavior could be hidden in those chunks, particularly around key handling or network transmission of signed headers.
Cryptographic wallet signing operations
NPS-F07C15887FDC
Code signs EIP-712 typed data (TransferWithAuthorization) and constructs Solana token transfer transactions. This is expected for x402 payment protocol functionality but involves private key operations and transaction signing. Ensure the library is trusted and the signing logic (recipients, amounts) cannot be manipulated by untrusted input to redirect funds.
insufficient analysis scope
NPS-1D6524AB0F9F
The provided file is a re-export barrel file that imports four functions (createPaymentHeader, preparePaymentHeader, selectPaymentRequirements, signPaymentHeader) from a bundled chunk file (chunk-F22J6Y36.mjs) and re-exports them. The actual implementation logic, including any network requests, credential handling, or cryptographic operations, resides in the referenced chunks which were not provided for review. The function names suggest payment header creation, signing, and payment requirement selection — operations that could involve sensitive key material or external network calls if implemented maliciously. A complete security assessment requires inspection of chunk-F22J6Y36.mjs and the other chunk files.
Indirect import of obfuscated/unreviewed chunks
NPS-923FF7B9F478
This ESM entry point re-exports settle and verify from ../chunk-YWMHVYTD.mjs and side-effect imports several additional chunk files (chunk-EAFXNFCO.mjs, chunk-SQV4BQTM.mjs, chunk-3EQVFRKV.mjs, chunk-K4TZLEOT.mjs, chunk-EMSAO3AI.mjs). The actual logic is hidden in those chunks, which are not provided for review. Bundler-generated chunk names provide no insight into their contents, and side-effect-only imports execute code at module load time. Without inspecting the chunks, malicious behavior such as data exfiltration, credential harvesting, network requests, process spawning, or dynamic code execution cannot be ruled out.
Side-effect module loading at import time
NPS-109C94748FCE
The file imports several chunks solely for their side effects (no bindings are used from chunk-EAFXNFCO.mjs, chunk-SQV4BQTM.mjs, chunk-3EQVFRKV.mjs, chunk-K4TZLEOT.mjs, chunk-EMSAO3AI.mjs). Any top-level code in those modules will run immediately when this facilitator module is imported, which is a common vector for install/import-time malicious execution.
Unverifiable implementation in imported chunks
NPS-35470861514F
The analyzed file is only an entry point re-exporting from several bundled chunks. All sensitive logic (payment header creation, signing, settlement, verification) resides in the imported .mjs files, which were not provided for review. Security cannot be confirmed without examining those chunks.
Potential cryptocurrency payment/settlement code
NPS-240D3C0D47FD
The module exports functions named createPaymentHeader, preparePaymentHeader, signPaymentHeader, settle, and verify, and defines x402Version. The name 'x402' strongly suggests a cryptocurrency payment protocol (HTTP 402 Payment Required, often used with stablecoins/wallets). While the top-level file itself contains no direct malicious logic, these exports indicate that the package likely handles signing and settling crypto payments. This warrants manual review of the imported chunks (chunk-F22J6Y36.mjs, chunk-YWMHVYTD.mjs, etc.), which contain the actual implementations. Malicious variants could steal private keys, rewrite wallet addresses, or drain funds during 'sign' or 'settle' operations.
Cryptocurrency/payment functionality surface
NPS-633F22539DF7
Exported symbols (decodeXPaymentResponse, processPriceToAtomicAmount, getDefaultAsset, getNetworkId, svm) indicate this module handles crypto payment/x402-style flows and Solana VM operations. This is not inherently malicious, but payment/wallet-related code is a high-value target for malicious modification, so the underlying chunk implementations should be audited.
dynamic_require
NPS-650AA87D5E21
Uses a dynamic require('crypto').webcrypto fallback for nonce generation, but only as a fallback when globalThis.crypto is unavailable; this is a legitimate cryptographic primitive usage and not obfuscation or arbitrary code execution.
network_requests
NPS-B1571C70A854
References Solana RPC URLs (api.devnet.solana.com, api.mainnet-beta.solana.com) and default RPC endpoints for a payment protocol library. These are expected for the library's documented functionality (creating USDC payment header transactions) and are not data exfiltration.
Hardcoded smart contract addresses
NPS-E3B404BD3980
The config object contains hardcoded USDC contract addresses across multiple chains. These are legitimate USDC contract addresses (e.g., 0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913 on Base) and are not malicious, but hardcoded addresses could be a vector if altered by a malicious fork.
RPC/API endpoint configuration
NPS-1796FB07479A
Hardcoded Solana RPC endpoints (api.devnet.solana.com, api.mainnet-beta.solana.com) and WebSocket URLs are used for network communication. This is expected behavior for a payment scheme library but exposes interactions with external infrastructure.
Dynamic require of crypto module
NPS-58547286AF98
The createNonce function uses a dynamic require('crypto').webcrypto fallback for Node.js environments. While the require target is static, dynamic require calls can be flagged as a potential obfuscation vector.
Cryptographic nonce generation
NPS-2C63E8680324
createNonce uses crypto.getRandomValues (via globalThis.crypto or Node's webcrypto) to generate 32-byte random nonces. This is correct cryptographic practice and not a vulnerability.
Smart wallet bytecode retrieval
NPS-95A097573DD9
The verify function calls client.getCode({ address: payerAddress }) to check if a payer is a deployed smart wallet. This is standard validation but performs an external chain query.
Potential Insecure Base64 Decoding
NPS-4ABE85CB25D1
safeBase64Decode and decodeXPaymentResponse use base64 decoding and JSON.parse on potentially untrusted input (HTTP header). While not malicious, it could lead to prototype pollution or denial-of-service if not validated. The regex Base64EncodedRegex limits characters but does not enforce length or content safety for subsequent JSON parsing.
Network Endpoint Hardcoded
NPS-BFA4D649E267
Hardcoded Solana RPC URLs (devnet/mainnet) and WebSocket URLs are present. This is typical for blockchain libraries but could be a vector for man-in-the-middle if not using TLS or if endpoints are compromised. Not malicious by itself.
Dynamic Regular Expression Construction
NPS-926865AC877F
computeRoutePatterns constructs regular expressions from user-supplied route patterns. Although it escapes special characters, the use of dynamic regex can lead to ReDoS (Regular Expression Denial of Service) if patterns are malicious. The input is likely internal, but this is a potential risk.
crypto_wallet_signing_capability
NPS-EC1204206733
The module provides functions like createSigner() and createSignerFromBase58() that accept private keys and create EVM/SVM wallet signers. This is expected functionality for a payment/x402 library, not wallet draining, but it indicates the package handles sensitive key material.
hardcoded_rpc_endpoints
NPS-18F191F204FB
Default Solana RPC URLs (api.devnet.solana.com, api.mainnet-beta.solana.com) and various EVM chain RPC endpoints are hardcoded, but these are public, well-known endpoints and their usage is typical for blockchain client libraries.
base64_decode_and_json_parse
NPS-379F695990E0
settleResponseFromHeader() decodes attacker-controllable header input via Base64 and JSON.parse. Errors would throw but no eval or dynamic execution is involved; input is only parsed, not executed.
cryptocurrency payment signing
NPS-123FD3264B60
The module implements cryptocurrency payment header creation, preparation, and signing for EVM and SVM (Solana) networks. While these are legitimate blockchain operations, the module handles private key signing operations through wallet clients. No private keys are directly handled or exfiltrated in this file, but it's part of a payment signing flow that interacts with wallets—security-sensitive functionality that should be reviewed in full context.
no obvious malicious patterns
NPS-F3D735F9D759
No environment variable harvesting, no child_process spawning, no eval/new Function, no obfuscation, no filesystem manipulation outside package scope, and no install-time execution were observed in this specific file. The code is a thin orchestration layer selecting between EVM/SVM signing paths based on payment requirements.
Network RPC calls
NPS-4B79F35A8A78
Fetches latest blockhash and simulates transactions via RPC client. URLs come from paymentRequirements/config parameters, not hardcoded malicious endpoints. Standard blockchain interaction.
Dynamic require / module loading
NPS-278CDCE9C969
Uses __require("crypto") to load Node.js crypto module at runtime for fallback webcrypto access. While used for legitimate nonce generation, dynamic require patterns should be reviewed in third-party packages.
Potentially suspicious module re-exports
NPS-815474B0A4C8
This file is a pure re-export barrel file that imports from an opaque chunk (chunk-3EQVFRKV.mjs) and re-exports symbols including crypto/payment-related names such as decodeXPaymentResponse, processPriceToAtomicAmount, safeBase64Decode, and svm (Solana Virtual Machine) exports. The actual implementation is not visible in this file and must be reviewed in the referenced chunk files to determine intent.
Obfuscated/opaque chunk filenames
NPS-0BCB8303E2F9
Imports reference hashed chunk filenames (chunk-3EQVFRKV.mjs, chunk-K4TZLEOT.mjs, chunk-EMSAO3AI.mjs). While common in bundled ESM output, these opaque names prevent straightforward auditing of the actual logic, which is relevant for security review of a third-party package.
Dynamic network endpoint construction
NPS-5625B6E820F7
URLs are constructed dynamically as ${url}/verify, ${url}/settle, ${url}/supported, and ${url}/discovery/resources?${urlParams}. The 'list' function builds a query string from arbitrary config object values, which are passed to a remote server. No obvious SSRF guard restricts the facilitator URL to HTTPS or expected hosts.
External network communication with dynamic endpoint
NPS-A00AAFA2D173
The code sends HTTP requests to a facilitator URL that defaults to 'https://x402.org/facilitator' but can be overridden by the caller. Request bodies include 'paymentPayload' and 'paymentRequirements' (payment data) serialized via toJsonSafe. This is a payment verification/settlement client, which is expected behavior for its purpose, but it does transmit potentially sensitive payment payloads to a remote server and follows caller-supplied URLs.
Authorization header injection from external auth provider
NPS-CD02D46EA25D
The code calls facilitator.createAuthHeaders() and merges the result into outgoing request headers (authHeaders.verify/settle/supported/list) without validation. If the caller supplies a malicious or compromised facilitator object, arbitrary headers (including credentials) could be attached or leaked to the facilitator URL. However, this is caller-controlled behavior, not an inherent exfiltration by the package itself.
Files reviewed
| File | Verdict | What the reviewer saw |
|---|---|---|
| dist/cjs/schemes/index.js | medium | The file is a legitimate x402 payment scheme library that performs expected blockchain interactions (transaction signing, RPC calls) with no obfuscation, credential harvesting, or malicious exfiltration patterns detected. |
| dist/cjs/shared/index.js | medium | The code appears to be a legitimate blockchain payment library (x402) with no obvious malicious patterns, but it handles sensitive private keys and performs dynamic base64 decoding and regex construction, warranting medium-level caution. |
| dist/esm/chunk-F22J6Y36.mjs | medium | This file orchestrates cryptocurrency payment header signing for EVM and SVM chains; no direct malicious patterns are present, but the actual signing implementations in imported chunks (chunk-SQV4BQTM.mjs) require separate audit as they handle sensitive wallet operations. |
| dist/esm/chunk-SQV4BQTM.mjs | medium | Legitimate x402 payment client code with expected wallet-signing and RPC interactions; no clear malicious patterns, but dynamic require and transaction-signing flows warrant caution. |
| dist/esm/client/index.mjs | medium | Barrel re-export file is itself safe, but the referenced implementation chunks were not provided and contain payment-signing logic that warrants further review. |
| dist/esm/facilitator/index.mjs | medium | The facade file itself contains no overt malicious code, but it re-exports from and side-effect-imports multiple bundled chunks that are not shown, so the package cannot be fully cleared without reviewing those chunks. |
| dist/esm/index.mjs | medium | The entry point is benign on its own but exposes cryptocurrency payment signing/settlement APIs whose implementations in the imported chunks require review for wallet-key theft or address rewriting. |
| dist/esm/shared/index.mjs | medium | This file is only a re-export shim; no malicious behavior is directly visible, but the referenced opaque chunks containing crypto/payment logic cannot be verified from this file and should be audited. |
| dist/esm/verify/index.mjs | medium | The module is a legitimate-looking x402 payment facilitator client that performs expected outbound HTTP requests; no obfuscation, credential harvesting, install-time execution, process spawning, or code execution was detected, though it forwards payment payloads to caller-configurable remote endpoints. |
| dist/cjs/client/index.js | safe | The code is a legitimate x402 payment client library for EVM/SVM USDC transfers; no malicious patterns such as credential harvesting, exfiltration, obfuscation, backdoors, or shell execution were detected. |
| dist/cjs/facilitator/index.js | safe | The code is a legitimate x402 payment facilitator library that verifies and settles EVM and Solana USDC payments with no malicious patterns detected. |
| dist/cjs/index.js | safe | No malicious patterns detected; the code is a legitimate x402 payment protocol library with standard cryptographic operations and no data exfiltration, credential harvesting, obfuscation, or backdoor behaviors. |
| dist/cjs/shared/evm/index.js | safe | No malicious patterns detected; the code is a standard EVM/USDC utility module with hardcoded public token addresses and no exfiltration, obfuscation, or dynamic execution. |
| dist/cjs/types/index.js | safe | The module is a standard blockchain/payment (x402) schema and wallet utility library with no evidence of exfiltration, obfuscation, install-time hooks, shell execution, or credential harvesting. |
| dist/cjs/verify/index.js | safe | No malicious patterns detected; the code is a standard x402 payment verification client with type validation and facilitator HTTP calls. |
| dist/esm/chunk-3EQVFRKV.mjs | safe | No malicious patterns detected; the code is a legitimate x402 payment protocol library handling multi-chain wallet creation, transaction signing, and schema validation with no exfiltration, obfuscation, or suspicious behavior. |
| dist/esm/chunk-EAFXNFCO.mjs | safe | No malicious patterns detected; the code is a legitimate cryptocurrency payment scheme implementation for EVM and SVM chains with no data exfiltration, credential harvesting, obfuscation, or other red flags. |
| dist/esm/chunk-EMSAO3AI.mjs | safe | The file is a simple configuration module mapping chain IDs to USDC contract addresses and names, with no malicious patterns detected. |
| dist/esm/chunk-K4TZLEOT.mjs | safe | The code is a standard USDC ERC-20 ABI definition and utility functions for reading balances and versions via viem; no malicious patterns detected. |
| dist/esm/chunk-YWMHVYTD.mjs | safe | No malicious patterns detected |
| dist/esm/schemes/index.mjs | safe | No malicious patterns detected; this is a simple barrel re-export module. |
| dist/esm/shared/evm/index.mjs | safe | This file is a simple re-export module for EVM/USDC balance utility functions with no malicious, obfuscated, or network-active code. |
| dist/esm/types/index.mjs | safe | This is a standard ESM barrel file re-exporting symbols from a bundled chunk, with no executable code, network calls, credential access, obfuscation, or other malicious patterns. |
Frequently asked questions
Is x402 safe to use?
No confirmed malware was found in x402@0.7.3, but the review flagged 10 medium, 22 low severity findings for risky patterns worth checking before you rely on it.
Does x402 contain malware?
No malware was identified in x402@0.7.3 when Togoder Security scanned it on Oct 4, 2026. A new version can still introduce malicious code, so scan the exact versions in your lockfile.
How was x402 checked?
Togoder Security downloaded the published npm package and had an AI model read its 23 source files, looking for install scripts, credential access, network exfiltration, obfuscation, backdoors and crypto-wallet theft. The results are cached by file hash and shown here.
How do I scan x402 together with the rest of my dependencies?
Upload your lockfile at https://security.togoder.click/scan or call the API documented at https://security.togoder.click/api-docs. Files that have already been scanned, like the ones in x402@0.7.3, cost nothing.