# x402@0.7.3 security report (npm)

- Verdict: **Needs review** (risk level: medium)
- Scanned: 2026-10-04T16:46:31.000Z
- Files reviewed: 23
- Findings: 10 medium, 22 low severity findings
- Report: https://security.togoder.click/npm/x402
- Source: Togoder Security (https://security.togoder.click), AI source-code review

## 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

### [medium] Transaction signing and submission

Finding ID: `NPS-CC1F85C4E27E`

File: `dist/cjs/schemes/index.js:785`

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.

### [medium] Insecure Cryptographic Key Handling

Finding ID: `NPS-F5AE4A0B0DD1`

File: `dist/cjs/shared/index.js:209`

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.

### [medium] external network dependency

Finding ID: `NPS-06AE0617A23F`

File: `dist/esm/chunk-F22J6Y36.mjs:1`

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.

### [medium] Cryptographic wallet signing operations

Finding ID: `NPS-F07C15887FDC`

File: `dist/esm/chunk-SQV4BQTM.mjs`

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.

### [medium] insufficient analysis scope

Finding ID: `NPS-1D6524AB0F9F`

File: `dist/esm/client/index.mjs`

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.

### [medium] Indirect import of obfuscated/unreviewed chunks

Finding ID: `NPS-923FF7B9F478`

File: `dist/esm/facilitator/index.mjs:1`

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.

### [medium] Side-effect module loading at import time

Finding ID: `NPS-109C94748FCE`

File: `dist/esm/facilitator/index.mjs:5`

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.

### [medium] Unverifiable implementation in imported chunks

Finding ID: `NPS-35470861514F`

File: `dist/esm/index.mjs:2`

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.

### [medium] Potential cryptocurrency payment/settlement code

Finding ID: `NPS-240D3C0D47FD`

File: `dist/esm/index.mjs:18`

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.

### [medium] Cryptocurrency/payment functionality surface

Finding ID: `NPS-633F22539DF7`

File: `dist/esm/shared/index.mjs`

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.

### [low] dynamic_require

Finding ID: `NPS-650AA87D5E21`

File: `dist/cjs/client/index.js`

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.

### [low] network_requests

Finding ID: `NPS-B1571C70A854`

File: `dist/cjs/client/index.js`

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.

### [low] Hardcoded smart contract addresses

Finding ID: `NPS-E3B404BD3980`

File: `dist/cjs/schemes/index.js:55`

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.

### [low] RPC/API endpoint configuration

Finding ID: `NPS-1796FB07479A`

File: `dist/cjs/schemes/index.js:153`

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.

### [low] Dynamic require of crypto module

Finding ID: `NPS-58547286AF98`

File: `dist/cjs/schemes/index.js:590`

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.

### [low] Cryptographic nonce generation

Finding ID: `NPS-2C63E8680324`

File: `dist/cjs/schemes/index.js:590`

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.

### [low] Smart wallet bytecode retrieval

Finding ID: `NPS-95A097573DD9`

File: `dist/cjs/schemes/index.js:1000`

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.

### [low] Potential Insecure Base64 Decoding

Finding ID: `NPS-4ABE85CB25D1`

File: `dist/cjs/shared/index.js:78`

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.

### [low] Network Endpoint Hardcoded

Finding ID: `NPS-BFA4D649E267`

File: `dist/cjs/shared/index.js:150`

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.

### [low] Dynamic Regular Expression Construction

Finding ID: `NPS-926865AC877F`

File: `dist/cjs/shared/index.js:400`

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.

### [low] crypto_wallet_signing_capability

Finding ID: `NPS-EC1204206733`

File: `dist/cjs/types/index.js`

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.

### [low] hardcoded_rpc_endpoints

Finding ID: `NPS-18F191F204FB`

File: `dist/cjs/types/index.js`

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.

### [low] base64_decode_and_json_parse

Finding ID: `NPS-379F695990E0`

File: `dist/cjs/types/index.js`

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.

### [low] cryptocurrency payment signing

Finding ID: `NPS-123FD3264B60`

File: `dist/esm/chunk-F22J6Y36.mjs`

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.

### [low] no obvious malicious patterns

Finding ID: `NPS-F3D735F9D759`

File: `dist/esm/chunk-F22J6Y36.mjs`

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.

### [low] Network RPC calls

Finding ID: `NPS-4B79F35A8A78`

File: `dist/esm/chunk-SQV4BQTM.mjs`

Fetches latest blockhash and simulates transactions via RPC client. URLs come from paymentRequirements/config parameters, not hardcoded malicious endpoints. Standard blockchain interaction.

### [low] Dynamic require / module loading

Finding ID: `NPS-278CDCE9C969`

File: `dist/esm/chunk-SQV4BQTM.mjs:99`

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.

### [low] Potentially suspicious module re-exports

Finding ID: `NPS-815474B0A4C8`

File: `dist/esm/shared/index.mjs`

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.

### [low] Obfuscated/opaque chunk filenames

Finding ID: `NPS-0BCB8303E2F9`

File: `dist/esm/shared/index.mjs:13`

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.

### [low] Dynamic network endpoint construction

Finding ID: `NPS-5625B6E820F7`

File: `dist/esm/verify/index.mjs`

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.

### [low] External network communication with dynamic endpoint

Finding ID: `NPS-A00AAFA2D173`

File: `dist/esm/verify/index.mjs:12`

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.

### [low] Authorization header injection from external auth provider

Finding ID: `NPS-CD02D46EA25D`

File: `dist/esm/verify/index.mjs:15`

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

- `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.

AI analysis is guidance, not a guarantee. Methodology: https://security.togoder.click/methodology
