Wednesday, December 18, 2024
Homecyber securityHackers Deploy Malicious npm Packages on GitHub to Steal SSH Keys

Hackers Deploy Malicious npm Packages on GitHub to Steal SSH Keys

Published on

SIEM as a Service

Two malicious npm packages were discovered on the npm open source package manager, which leverages GitHub to store stolen Base64-encrypted SSH keys obtained from developer systems that installed the malicious npm packages.

In recent weeks, two suspicious npm packages, namely warbeast2000 and kodiak2k, were discovered in multiple versions. As of writing, both the packages were removed from npm in January.

ReversingLabs stated that between 2020 and the end of 2023, the overall number of malicious packages discovered on open-source package managers increased by 1,300%.

- Advertisement - SIEM as a Service

A rising part of this trend is the hosting of malicious command and control infrastructure on the GitHub version control platform.

Document
Free Trial

Streaming Malware Service

Open Suspicious Files & Links in the ANY RUN Sandbox Safely; Try All Features for Free. Understand malware behavior, collect IOCs, and easily map malicious actions to TTPs — all in our interactive sandbox.

Malicious Packages Target Developer SSH keys

The warbeast2000 package, according to researchers, was made up of only a few components and was not particularly complex. Warbeast2000’s corresponding npm page was simple and did not openly imitate any other package.

“There were eight versions (1.0.0 – 1.0.8), with new elements being added to the package with each new version. The package author was in the process of building out the malware and adding layers of deception. Fortunately, the package was detected and removed from npm before that could happen”, ReversingLabs Shared with Cyber Security News.

After the victim’s machine was installed with the final version of the package, a postinstall script would be activated, retrieving and running a JavaScript file.

The malicious script, in its second stage, read the private SSH key that was kept in the id_rsa file, which was found in the <homedir>/.ssh directory.

The Base64-encoded key was then uploaded to a GitHub repository under the attacker’s control. The package did not exhibit any other actions other than obtaining and copying the id_rsa SSH key.

Malicious second stage from warbeast2000 private SSH key
Malicious second stage from warbeast2000 private SSH key

Once the package is installed, kodiak2k executes a postinstall script. That script launches another JavaScript file that it has downloaded. Except for the first few, kodiak2k had over 30 versions, all of which were harmful, in contrast to warbeast2000.

Similar to warbeast2000, that script searches for a key called meow while reading everything in the <homedir>/.ssh directory.

It’s unclear if meow was just a placeholder name for the package throughout development or if the developer had a specific key in mind.

“When and if the meow file was located, the key contained in it would be encoded in Base64 and uploaded to a GitHub repository, as with the warbeast2000 package”, researchers said.

It was discovered that later iterations of kodiak2k ran a script in a GitHub repository that had been archived and contained the Empire post-exploitation framework. The script can dump credentials from process memory by launching the Mimikatz hacking tool.

In September 2023, Sonatype researchers tracked the npm registry campaign, extracting Kubernetes configurations and SSH keys via npm packages. Their automated system found about 14 malicious packages.

Hence, developers and development organizations should evaluate the security of software or libraries discovered on package managers such as npm or PyPI before incorporating them to make sure they are safe to use.

Gurubaran
Gurubaran
Gurubaran is a co-founder of Cyber Security News and GBHackers On Security. He has 10+ years of experience as a Security Consultant, Editor, and Analyst in cybersecurity, technology, and communications.

Latest articles

New I2PRAT Malware Using encrypted peer-to-peer communication to Evade Detections

Cybersecurity experts are sounding the alarm over a new strain of malware dubbed "I2PRAT,"...

Earth Koshchei Employs RDP Relay, Rogue RDP server in Server Attacks

 A new cyber campaign by the advanced persistent threat (APT) group Earth Koshchei has...

Careto – A legendary Threat Group Targets Windows By Deploy Microphone Recorder And Steal Files

Recent research has linked a series of cyberattacks to The Mask group, as one...

RiseLoader Attack Windows By Employed A VMProtect To Drop Multiple Malware Families

RiseLoader, a new malware family discovered in October 2024, leverages a custom TCP-based binary...

API Security Webinar

72 Hours to Audit-Ready API Security

APIs present a unique challenge in this landscape, as risk assessment and mitigation are often hindered by incomplete API inventories and insufficient documentation.

Join Vivek Gopalan, VP of Products at Indusface, in this insightful webinar as he unveils a practical framework for discovering, assessing, and addressing open API vulnerabilities within just 72 hours.

Discussion points

API Discovery: Techniques to identify and map your public APIs comprehensively.
Vulnerability Scanning: Best practices for API vulnerability analysis and penetration testing.
Clean Reporting: Steps to generate a clean, audit-ready vulnerability report within 72 hours.

More like this

New I2PRAT Malware Using encrypted peer-to-peer communication to Evade Detections

Cybersecurity experts are sounding the alarm over a new strain of malware dubbed "I2PRAT,"...

Earth Koshchei Employs RDP Relay, Rogue RDP server in Server Attacks

 A new cyber campaign by the advanced persistent threat (APT) group Earth Koshchei has...

Careto – A legendary Threat Group Targets Windows By Deploy Microphone Recorder And Steal Files

Recent research has linked a series of cyberattacks to The Mask group, as one...