character-ai-sdk@1.0.1
Malicious code in character-ai-sdk (npm)
Analysis
character-ai-sdk@1.0.1 is a trojanized AI character/persona SDK: its advertised memory runtime ships four heavily obfuscated bundles (cache-sweep.mjs, cache-warm.mjs, build-cache.mjs, workspaces.js) that are not part of the documented API and harvest the installer's cloud and deployment credentials. Obfuscation: each bundle embeds a base64 string array decoded with atob() and XORed with 0x8e, thousands of _0x-style identifiers, and dead arithmetic code; further strings are built at runtime from String.fromCharCode() over hex arithmetic, so C2 details never appear in plaintext. Credential and secret collection (cache-sweep.mjs): reads $HOME/.aws/credentials and $HOME/.aws/config in full, enumerates $HOME/.aws/sso/cache and returns each entry (capped at 2048 bytes), copies every environment variable whose name begins with the AWS prefix, walks up to five parent directories from the working directory plus git repository roots collecting .env files (capped at 4096 bytes), and scans git remotes and repository content for secret-shaped strings. Execution and concealment: cache-warm.mjs hooks the package's public personas API (exported cssVarMap) so the payload runs on first normal SDK use rather than at install, then builds a randomized script path under the OS temp directory, injects extra variables into a copy of process.env and spawns the helper with detached:true, unref()'ing it so it outlives the parent. build-cache.mjs probes writable directories, writes a platform-specific shell script, sets its mode to 0755 on Unix, launches it detached, and deletes staged files afterwards. Sandbox evasion: six bundled native addons (native/{linux,darwin,win32}/{x64,arm64}/cache-probe.node) check for QEMU firmware config, systemd-detect-virt, DMI chassis type, /.dockerenv, /.dockerinit, dmidecode and dmesg hypervisor strings before the payload acts. No plaintext C2 hostname or IP is recoverable from the package — the HTTPS request target is assembled at runtime from the encoded string tables, so no network indicator can be published; detection should key on the file paths, the exported cssVarMap entry point, and the AWS/SSH/.env collection behaviour above.
- analyzed by
- Leitwacht
- first seen
- Oct 31, 2026, 03:41 PM
- analyzed
- Nov 2, 2026, 07:37 AM
Related advisories
- character-ai-sdk@1.0.0 same package
- litecore-lib-ltc@1.9.3
- orderly-plugin-liquidity-heatmap@1.0.6
- orderly-plugin-liquidity-heatmap@1.0.4
- @galicia-toolkit/spa-build-config@999.0.5
- css-reading-display-polyfill@1.0.0
- css-jptvix-polyfill@1.0.0
- @worrisome/aaaa@1.0.0
Independently detected by the Leitwacht supply-chain probe. IOCs are defanged. Published CC0. Think this is a mistake? See the dispute policy.