library / Blockchain ideas / Developer tools / BI0113
Plaintext account data scanner
Yes, anyone can read it. This scanner takes a program id, collects accounts its recent transactions touched, reads their raw data through one hosted RPC key and flags readable text such as emails, links and secret-looking strings, so you see what a stranger sees.
The short answer
Yes. Every account on Solana is readable by anyone with an RPC connection, and a program derived address is no exception. A PDA has no private key, which stops others from signing for it. It does nothing to hide its bytes. getAccountInfo on a PDA returns the full data field to any caller. The transactions that wrote those bytes stay in the ledger too, and their instruction data often carries the same values.
A field marked private in your Rust struct is private to other Rust code and nothing else. The compiler enforces that at build time, and the chain never sees it. Once the struct is serialized into the account, its fields sit in declared order, and anyone who has your program's source or IDL can decode them. Anyone without them can still scan the bytes for text.
That second reader is the one this scanner imitates. It needs no schema. It pulls accounts the program owns from its recent transactions, looks for runs of printable characters and checks them against a short list of things that should never be on chain: an email address, a link with a token in it, the word password, a base58 string long enough to be a secret key.
The result is a report you can read before launch. A team that stored a customer email in a profile PDA, or a webhook URL with a key in its query string in a config account, finds out from its own tool first.
Who uses it
- A program team before an audit or a mainnet deploy. It answers what a stranger could read out of the accounts the program already owns.
- A hackathon crew that stored user profile fields in PDAs and wants to know whether a name or contact detail is sitting in plain view.
- A reviewer looking at someone else's program. One run of the scanner on a busy program shows whether its accounts hold text and what kind.
What it flags
For each account the program owns, the scanner prints the size, the share of the data that is readable text, the first three text runs and a flag when a pattern matches.
| Check | Pattern | Why it matters |
|---|---|---|
| Readable text | Eight or more printable ASCII characters in a row | Shows names, labels and links stored as strings |
| [email protected] shape | Personal data that stays in the ledger after any later edit | |
| Link | http:// or https:// followed by non-space text | Webhook URLs and signed links often carry a key in the path |
| Secret word | password, passwd, secret, apikey, api_key, private_key, token=, in any case | Config values that were meant to stay on a server |
| Long base58 | 80 or more base58 characters | A base58 secret key is 87 or 88 characters |
Binary fields rarely match the text pattern, because bytes such as lamport amounts and public keys contain values outside the printable range often enough to break the runs. A mostly binary account shows a low text share and no runs, which is what you want to see for fields that hold numbers.
An Anchor account starts with an 8-byte discriminator, then the fields in order. The scanner ignores that layout. If you want fields named, decode with the IDL, as in Account data encodings, and run the scanner as the cheap first pass.
The build
One TypeScript file on @solana/kit and Node 24. It is read-only: no private key, nothing sent. The program id comes from the first argument and defaults to the Token Metadata program, whose accounts carry names and links as text.
- Call getSignaturesForAddress for the program with a limit of 8 and keep the signatures that did not fail.
- Fetch each transaction with getTransaction and maxSupportedTransactionVersion: 1. Collect its account keys, including the ones loaded through lookup tables. A failed fetch is printed and the others carry on.
- Send the collected keys, at most 100, in one getMultipleAccounts call with base64 encoding.
- Keep the accounts whose owner is the program id. A transaction also touches wallets and other programs, and their data is not the program's to answer for.
- Decode each account, find the text runs, test the patterns and print one line per account.
// BI0113 · Plaintext account data scanner// https://carbium.sh/library/blockchainideas/plaintext-account-data-scanner// Copyright (c) Carbium Corporation. MIT License (LICENSE). Keep this notice.// SPDX-License-Identifier: MITimport { address, createDefaultRpcTransport, createSolanaRpcFromTransport, type Address } from "@solana/kit";const key = process.env.CARBIUM_KEY;if (!key) { console.error("Set CARBIUM_KEY to your Carbium API key."); process.exit(1);}const rpc = createSolanaRpcFromTransport( createDefaultRpcTransport({ url: process.env.CARBIUM_RPC_URL ?? "https://services.carbium.sh", headers: { "x-api-key": key }, }),);// Token Metadata by default: its accounts hold names and links as text.const program = address(process.argv[2] ?? "metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s");const SUSPECT: [string, RegExp][] = [ ["email", /[\w.+-]+@[\w-]+\.[\w.-]+/], ["link", /https?:\/\/\S+/], ["secret word", /password|passwd|secret|api[_-]?key|private[_-]?key|token=/i], ["long base58", /[1-9A-HJ-NP-Za-km-z]{80,}/],];// 1. Newest signatures on the program, then the accounts those transactions touched.const sigs = await rpc.getSignaturesForAddress(program, { limit: 8 }).send();const txs = await Promise.allSettled( sigs .filter((s) => s.err === null) .map((s) => rpc.getTransaction(s.signature, { encoding: "json", maxSupportedTransactionVersion: 1 }).send()),);const found = new Set<Address>();for (const r of txs) { if (r.status === "rejected") { console.error("getTransaction failed:", r.reason instanceof Error ? r.reason.message : r.reason); continue; } const tx = r.value; if (!tx) continue; // older than the validator keeps const loaded = tx.meta?.loadedAddresses; for (const k of [...tx.transaction.message.accountKeys, ...(loaded?.writable ?? []), ...(loaded?.readonly ?? [])]) found.add(k);}// 2. One read of up to 100 accounts, then a text scan of each one the program owns.const keys = [...found].slice(0, 100);const { value } = await rpc.getMultipleAccounts(keys, { encoding: "base64" }).send();let owned = 0;let flagged = 0;value.forEach((acc, i) => { if (!acc || acc.owner !== program) return; owned++; const bytes = Buffer.from(acc.data[0], "base64"); const text = bytes.toString("latin1"); const runs = text.match(/[\x20-\x7e]{8,}/g) ?? []; const share = runs.reduce((n, r) => n + r.length, 0) / Math.max(bytes.length, 1); const hits = SUSPECT.filter(([, re]) => re.test(text)).map(([name]) => name); if (hits.length) flagged++; console.log(`${keys[i]} ${bytes.length} bytes, ${(share * 100).toFixed(0)}% readable text${hits.length ? ", FLAG " + hits.join("+") : ""}`); for (const r of runs.slice(0, 3)) console.log(` "${r.slice(0, 60)}"`);});console.log(`${keys.length} accounts seen, ${owned} owned by ${program}, ${flagged} flagged`);
run: CARBIUM_KEY=<YOUR_KEY> node main.ts metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s
Every call leaves commitment out, so @solana/kit sends confirmed. The scan looks at accounts from recent traffic, so it samples the program and does not enumerate it.
To scan more, raise the signature limit and loop over getMultipleAccounts in chunks of 100 keys. Pass the signature limit through an environment variable if you want a deeper pass in CI.
What it costs
One run makes one getSignaturesForAddress call at 50 cells, up to 8 getTransaction calls at 50 cells each and one getMultipleAccounts call. That last call charges 10 cells per pubkey, so 100 pubkeys cost 1000 cells, plus 1 because a 100-key request body runs past 4 KiB. A full run comes to at most 1,451 cells.
| Plan | Price per month | Credits | getSignaturesForAddress rate | Account read rate |
|---|---|---|---|---|
| Free | $0 | 500K once, at sign-up | 0.24 req/s | 0.5 req/s |
| Dev | $20 | 10M | 1.2 req/s | 15 req/s |
| Business | $250 | 50M | 100 req/s | 50 req/s |
| Pro | $500 | 200M | 500 req/s | 400 req/s |
getTransaction runs at 0.24, 1.2, 5 and 25 req/s on Free, Dev, Business and Pro, so the eight lookups go through on a class's 1,024-cell burst: they come to 400 cells, and the account read to at most 1,001. A second run straight after on Free finds the transaction bucket still refilling at 0.24 calls a second.
Below Pro, the 1,024-cell burst caps a getMultipleAccounts call at 100 pubkeys, so the code never sends more. A scan of a large program is a loop of such calls spaced to your plan's account-read rate. Limits are per account, so other tools on the same keys draw on the same budget.
What to do with a finding
A flag means the bytes are already public. Two things need handling: the data that is there and the data you have not stored yet.
- Stop writing the field. Change the instruction so it no longer takes or stores it, and ship that first.
- Move the value off chain and store a reference. A hash of the value with a salt you keep off chain, or an id into your own database, proves a match later. A plain hash of an email or a name can be guessed by hashing candidates.
- If a program must keep a secret on chain for a short time, such as a commit and reveal game, store a hash of the value and a random nonce first, and the value only at reveal.
- Rotate any secret the scan found, whatever you do to the account afterwards. Treat it as read by others from the moment it landed.
Closing the account returns its rent and zeroes the data going forward. The transactions that wrote the data stay in the ledger, and any archive of old state keeps it, so closing only stops new reads of the account.
Where it ends
- Text is found by pattern. Data that is encoded, compressed or encrypted by your program shows as binary and passes. A hit shows what is readable at a glance, and a miss proves nothing about hidden structure.
- Only accounts that recent transactions touched are read. A rarely used PDA can hold a secret the sample never reaches. Raise the signature limit or feed addresses from your own seeds.
- History is the 30-day address index at most, so the sample covers recent traffic. An empty page past that is the index's age limit and says nothing about older accounts.
- getTransaction can answer null for an older signature the index lists. The scanner skips those and works from the ones that return.
- Email and link patterns are loose and flag false positives, such as a metadata link that is meant to be public. Read each flag before you act on it.
- The scanner reads current state. It does not check what an account held before, which the transactions that wrote it and any archive of old state can still show.
When it goes wrong
| what goes wrong | what to do |
|---|---|
| The scan reports 0 accounts owned by the program. | The sample touched only wallets or other programs. Raise the signature limit in the code, or pass a program whose instructions create or change its own accounts. |
| getTransaction prints an error for some signatures. | Read the message. A -32015 means maxSupportedTransactionVersion was absent or 0; the code sets it to 1, so check that line if you changed it. A signature older than the validator keeps answers null, which the code skips without printing. |
| A call answers 429. | Wait the retry-after seconds and run again. On Free, space the calls to its rate, and remember that every key on the account shares one budget. |
| getMultipleAccounts is refused for a large key list. | Send at most 100 pubkeys per call below Pro and loop in chunks. Up to 300 pubkeys per call is a Pro limit. |
| Every account flags a link. | The program stores public links on purpose. Narrow the link pattern to the query strings you care about, such as [?&](key|token|sig)=. |
| The first run exits with a message about the key. | Set CARBIUM_KEY in the environment of the same shell that runs the command. |
Questions
Can anyone read the data of a PDA that only my program can sign for?
Yes. Signing authority decides who can change the account, and the account's data is open to every reader. The program owns the account and no one else can write to it, but anyone can fetch and decode it.
Does a private struct field hide the value?
No. Visibility rules apply to source code. Once serialized, the field is bytes at an offset in the account, and a reader with the layout or a text scan sees it.
If I encrypt the value before storing it, is that enough?
It keeps the plain value from readers who lack the key. Keep the key off chain, and plan for the ciphertext to stay public forever, so a weak key or a later break exposes it. Storing a salted hash or a reference avoids the question.
Will deleting or closing the account remove what was stored?
No. Closing frees the account's state going forward. The transactions that wrote it stay in the ledger and archives keep old state, so treat anything once written as published.
Can I scan every account of a program with this?
This version samples accounts from recent transactions at a small, predictable cost. For a full sweep, feed it addresses from your own seed list or from an index you build.