txnforge@1.0.4
Malicious code in txnforge (npm)
Analysis
txnforge@1.0.4 presents itself as a synthetic financial-transaction data generator, but ships a concealed code-execution loader alongside the data. The documented API (getTransactions, and the internal load_transaction_data) does two things: it returns plausible fake transaction records, and it silently executes a hidden second-stage payload. Mechanism: - database.js is a 43KB JavaScript-format array of 334 product/price records that each carry an extra "mark" field holding 8 base64 characters. It is read via fs.readFileSync in index.js/loadConfig and every mark is concatenated. - Each mark is base64-decoded to latin1 and then every character is rotated by subtracting (count % 256), where count is the caller's transaction count (default 20). This custom 8-bit rotation is applied by processData() in index.js. - The reassembled blob is base64-decoded again to UTF-8 and executed with the Function constructor, obtained indirectly as (()=>this)().constructor.constructor rather than a literal `new Function`. The resulting function is called with (Buffer, require, process), so the payload gets full Node capability. - Execution is deferred with setTimeout(callback, 100), and every trigger point is wrapped in try{}catch{} blocks with empty handlers plus a finally that clears the timer. Decoding or execution failures are swallowed completely and the API still returns normal-looking data, so the loader is invisible to the caller. - Identifiers used to build the executed code (Function, require, Buffer, process, setTimeout, clearTimeout) are stored split across a string array (_0x1a2b) and reassembled at runtime to avoid literal detection. Triggering: any call to the package's getTransactions(count) function (as documented in the README) invokes load_transaction_data, which fires the loader 100ms later in the calling Node process. Indicators: index.js (loader: loadConfig, processData, load_transaction_data, _0x1a2b string array), database.js (encoded payload chunks in the "mark" fields of 334 records). The package contains no plaintext URL, hostname or IP address; the executed stage-2 code only exists in the encoded marks and is reconstructed at runtime, so no C2 endpoint can be quoted from the shipped bytes.
- analyzed by
- Leitwacht
- first seen
- Nov 2, 2026, 04:35 AM
- analyzed
- Nov 2, 2026, 04:37 AM
- weekly installs
- 359
Related advisories
- txnforge@0.0.0-stage same package
- random-transactions-sdk@1.0.4
- random-transactions-sdk@1.0.1
- calkyippie@1.0.0
- calcurender@1.0.0
- t10-xor-spawn-testmetest@1.0.0
- event-bus-lite-testmetest@0.0.6
- retry-utils-testmetest@1.0.3
Independently detected by the Leitwacht supply-chain probe. IOCs are defanged. Published CC0. Think this is a mistake? See the dispute policy.