Vetting a Prediction Market Arbitrage Bot Before Connecting
PMA Research · · 7 min read · Updated

The appeal of automated trading is undeniable, but the infrastructure required to execute it safely is unforgiving. Handing over your credentials to an unverified script is the fastest way to drain your trading capital. Before you connect a wallet to any automated system, you must rigorously audit its code, scope its permissions, and verify its performance claims.
Key takeaways
- Malicious repositories often hide credential-stealing payloads inside obfuscated npm dependencies rather than the main source code.
- Legitimate trading automation requires scoped API keys with withdrawal permissions explicitly disabled, never raw private keys.
- Backtested performance claims are frequently inflated by ignoring taker fees, which can consume a significant portion of your edge.
- Running unverified code in an isolated virtual machine helps mitigate risks, but security VM and burner mitigations are not absolute safety guarantees.
How do malicious prediction market bots steal private keys?
Threat actors have developed sophisticated supply chain attacks targeting cryptocurrency developers and algorithmic traders. Instead of writing obvious malware, attackers hijack legitimate, dormant open-source projects to distribute their payloads.
In March 2026, security researchers discovered that a verified GitHub organization belonging to a legitimate Japanese decentralized finance project had been compromised. The attackers used this trusted account to host over twenty malicious repositories disguised as automated trading software StepSecurity: Malicious Polymarket Bot Hides in Hijacked dev-protocol GitHub Org and Steals Wallet Keys. Because the organization had a verified badge and a history dating back to 2019, the repositories appeared credible to unsuspecting users GitHub: Security Alert: This GitHub organization appears to have been compromised.
The malicious code was not located in the primary trading logic. The bots actually functioned as advertised, connecting to real market data endpoints and authenticating correctly. However, the repositories included typosquatted npm packages. When a user installed the dependencies, a postinstall hook automatically executed an obfuscated script. This script scanned the local machine for environment files, exfiltrated wallet keys to an external command server, and opened a secure shell backdoor.
This is part of a broader trend. Threat intelligence firms have mapped extensive delivery networks operated by state-sponsored actors, identifying dozens of malicious packages embedded across hundreds of repositories targeting various decentralized ecosystems Panther: Tracking the Contagious Trader Distribution Network. Relying on star counts or verified badges is insufficient for security.
Why should you audit npm dependencies and postinstall scripts?
The modern software supply chain is deeply interconnected. A single trading script might rely on hundreds of third-party libraries. Attackers exploit this by publishing packages with names that are one letter off from popular libraries.
When you run an installation command, you are granting execution privileges to the authors of every package in that dependency tree. Postinstall scripts are particularly dangerous because they run automatically during the installation phase, before you even execute the main application.
To protect yourself, you must inspect the full dependency tree. Look for packages with unusually low download counts or names that mimic established libraries. Review the lockfile to ensure the versions you are installing match the versions that were previously audited. If a repository lacks a lockfile, the dependencies are floating, meaning a benign package could be swapped for a malicious one at any time.
What is the difference between API keys and private keys?
Understanding the distinction between API keys and private keys is critical for securing your funds. A private key is the cryptographic root of your wallet. Anyone who possesses it has total control over your assets and can transfer them to any address. You should never paste a raw private key or seed phrase into a command-line interface or configuration file provided by an unverified third party.
API keys, conversely, are generated by the exchange or platform and can be strictly scoped. When generating an API key for an automated strategy, you must enforce the principle of least privilege. Enable trading permissions but explicitly disable withdrawal permissions. While a properly scoped trade-only API key restricts direct withdrawals to an attacker's wallet, if compromised, the attacker might still execute unprofitable trades to drain your balance into their own positions.
Always store API keys in secure environment variables or a dedicated secrets manager. Never hardcode them into your source files or commit them to version control.
How can you safely test a bot in an isolated environment?
Even after auditing the code, you should never run unverified software on your primary workstation. Use an isolated virtual machine or a containerized environment to execute the initial setup and testing phases.
This isolation helps mitigate the risk of malicious scripts accessing your personal files, browser extensions, or global environment variables. However, remember that security VM and burner wallet mitigations are not absolute safety guarantees.
Pre-deployment security checklist
| Verification Step | Action Required | Rationale | | :--- | :--- | :--- | | Dependency Audit | Inspect the full package tree for typosquatted names. | Prevents execution of hidden malware during installation. | | Network Monitoring | Log all outbound connections during a dry run. | Identifies unauthorized data exfiltration to command servers. | | Permission Scoping | Restrict API keys to trade-only access. | Prevents unauthorized withdrawals if credentials are leaked. | | Environment Isolation | Execute the software in a dedicated virtual machine. | Mitigates risks to your primary workstation from secure shell backdoors. | | Burner Wallet | Fund a separate address with minimal capital. | Caps your maximum potential loss in the event of a compromise. |
Run the software without providing any real credentials first. Monitor its network activity to ensure it only communicates with expected endpoints, such as official exchange APIs or public remote procedure call nodes. Any connection to an unrecognized domain warrants immediate investigation.
Execution Realities: Order Types and Market Data
Vendors often market their software using highly optimized backtests that ignore the friction of real-world trading. A strategy that appears profitable on paper will quickly collapse if it fails to account for taker fees, slippage, and execution latency.
When evaluating market data for backtests, remember that outcome prices, last trade prices, or midpoints are NOT executable asks. Missing asks mean the contract is unavailable, never zero. Selling YES uses actual bids and collateral/venue permission.
Furthermore, a limit order can be a taker if it is marketable; only resting, non-marketable orders provide liquidity. When attempting arbitrage across multiple platforms, remember that Fill-or-Kill (FOK) controls fills on ONE venue, never atomic cross-venue. FOK and Immediate-or-Cancel (IOC) semantics differ significantly, and misunderstanding them can leave you with an unhedged, directional position.
Verifying Fee Calculations
Consider the fee structures of major platforms. Polymarket charges taker fees on most categories, while makers pay no fee and can earn rebates, though rebate eligibility is not guaranteed revenue Fees - Polymarket Documentation.
On Kalshi, the general taker fee formula is round up(M * 0.07 * C * P * (1 - P)), where M is the multiplier (defaulting to 1 for standard contracts) Fee Schedule for July 2026 - 7.7.26 Update.
Let us examine a worked numeric example. Suppose you are evaluating an arbitrage opportunity on Kalshi where a YES contract pays $1.00 at resolution. You want to purchase 1,000 contracts at a price of 50 cents ($0.50).
- Base cost: 1,000 contracts x $0.50 = $500.00
- Fee calculation: 1 x 0.07 x 1,000 x 0.50 x (1 - 0.50)
- Fee calculation: 0.07 x 1,000 x 0.25 = $17.50
The fee is approximately 1.75 cents per contract at 50 cents. Your total cost to enter the position is $517.50. You must explicitly acknowledge that current precision must be read from live fee parameters; do not assume a per-contract 1.75-cent hard cap after rounding or across multipliers. If your backtest ignores this friction, your projected returns will be entirely fictitious. Hypothetical tables are not observed trades; return calculations must include both legs' capital and costs.
Furthermore, venues can resolve the "same" event differently based on their specific rulebooks. A strategy that assumes identical resolution criteria across platforms without reading the fine print is fundamentally flawed. Always verify the exact settlement conditions before deploying capital.
This is not financial advice. Always conduct your own rigorous due diligence. There is no guaranteed profitability in prediction market arbitrage.
Frequently asked questions
Should I trust a repository with a high star count?
No. Star counts and forks are easily manipulated using automated accounts. You must evaluate the actual commit history and audit the dependency tree rather than relying on superficial metrics.
Can a trade-only API key be used to steal my funds?
While a properly scoped trade-only API key cannot be used to withdraw funds directly to an attacker's wallet, an attacker could potentially use it to execute trades that benefit their own positions at your expense.
Why do backtests often overstate profitability?
Backtests frequently suffer from look-ahead bias and fail to account for real-world friction. They often ignore taker fees, slippage, the fact that marketable limit orders act as takers, and the reality that you cannot always execute your entire order at the best available historical price.
Sources
Information only, not financial advice. Trading prediction markets involves risk of loss.