The vulnerability in debug@4.4.2 is not a code flaw in the traditional sense, but rather a supply chain attack where a malicious version of the package was published to the npm registry after an account takeover. The malware was injected into the published package, specifically in the src/index.js file, but it does not exist in the source code repository on GitHub. Therefore, there are no security patch commits to analyze.
The analysis is based on the deobfuscated malware code provided in the referenced blog post from socket.dev.
The malware targets browser environments and aims to steal cryptocurrency by intercepting network traffic. It achieves this by monkey-patching fundamental browser APIs for making network requests: fetch and XMLHttpRequest.
When an application using the compromised debug package runs in a browser, the malware's code executes and overrides these functions. Any subsequent network request made through fetch or XMLHttpRequest is then routed through the malicious code. The malware inspects the response data, and if it finds any strings that match patterns of cryptocurrency wallets, it replaces them with addresses from a hardcoded list belonging to the attacker.
The key functions that would appear in a runtime profile during exploitation are the overridden fetch and XMLHttpRequest.prototype.send functions, as well as the internal malware functions replaceCryptoHashes and findNearestAddressLevenshtein which contain the core malicious logic. The XMLHttpRequest.prototype.open function is also hooked to capture request details.
The root cause is the compromised npm account, which allowed the attacker to publish a malicious package. The remediation was to remove the compromised version from the npm registry and publish a new, clean version (4.4.3). Users are advised to upgrade, clear caches, and rebuild their applications to ensure the malicious code is purged from their systems.