Analyzing Supply Chain Malware Artifacts
Overview
Supply chain attacks compromise legitimate software distribution channels to deliver malware through trusted update mechanisms. Notable examples include SolarWinds SUNBURST (2020, affecting 18,000+ customers), 3CX SmoothOperator (2023, a cascading supply chain attack originating from Trading Technologies), and numerous npm/PyPI package poisoning campaigns. Analysis involves comparing trojanized binaries against legitimate versions, identifying injected code in build artifacts, examining code signing anomalies, and tracing the infection chain from initial compromise through payload delivery. As of 2025, supply chain attacks account for 30% of all breaches, a 100% increase from prior years.
When to Use
- When investigating security incidents that require analyzing supply chain malware artifacts
- When building detection rules or threat hunting queries for this domain
- When SOC analysts need structured procedures for this analysis type
- When validating security monitoring coverage for related attack techniques
Prerequisites
- Python 3.9+ with
pefile, ssdeep, hashlib
- Binary diff tools (BinDiff, Diaphora)
- Code signing verification tools (sigcheck, codesign)
- Software composition analysis (SCA) tools
- Access to legitimate software versions for comparison
- Package repository monitoring (npm, PyPI, NuGet)
Workflow
Step 1: Binary Comparison Analysis
#!/usr/bin/env python3
"""Compare trojanized binary against legitimate version."""
import hashlib
import pefile
import sys
import json
def compare_pe_files(legitimate_path, suspect_path):
"""Compare PE file structures between legitimate and suspect versions."""
legit_pe = pefile.PE(legitimate_path)
suspect_pe = pefile.PE(suspect_path)
report = {"differences": [], "suspicious_sections": [], "import_changes": []}
# Compare sections
legit_sections = {s.Name.rstrip(b'\x00').decode(): {
"size": s.SizeOfRawData,
"entropy": s.get_entropy(),
"characteristics": s.Characteristics,
} for s in legit_pe.sections}
suspect_sections = {s.Name.rstrip(b'\x00').decode(): {
"size": s.SizeOfRawData,
"entropy": s.get_entropy(),
"characteristics": s.Characteristics,
} for s in suspect_pe.sections}
# Find new or modified sections
for name, props in suspect_sections.items():
if name not in legit_sections:
report["suspicious_sections"].append({
"name": name, "reason": "New section not in legitimate version",
"size": props["size"], "entropy": round(props["entropy"], 2),
})
elif abs(props["size"] - legit_sections[name]["size"]) > 1024:
report["suspicious_sections"].append({
"name": name, "reason": "Section size significantly changed",
"legit_size": legit_sections[name]["size"],
"suspect_size": props["size"],
})
# Compare imports
legit_imports = set()
if hasattr(legit_pe, 'DIRECTORY_ENTRY_IMPORT'):
for entry in legit_pe.DIRECTORY_ENTRY_IMPORT:
for imp in entry.imports:
if imp.name:
legit_imports.add(f"{entry.dll.decode()}!{imp.name.decode()}")
suspect_imports = set()
if hasattr(suspect_pe, 'DIRECTORY_ENTRY_IMPORT'):
for entry in suspect_pe.DIRECTORY_ENTRY_IMPORT:
for imp in entry.imports:
if imp.name:
suspect_imports.add(f"{entry.dll.decode()}!{imp.name.decode()}")
new_imports = suspect_imports - legit_imports
if new_imports:
report["import_changes"] = list(new_imports)
# Check code signing
report["legit_signed"] = bool(legit_pe.OPTIONAL_HEADER.DATA_DIRECTORY[4].Size)
report["suspect_signed"] = bool(suspect_pe.OPTIONAL_HEADER.DATA_DIRECTORY[4].Size)
return report
def hash_file(filepath):
"""Calculate multiple hashes for a file."""
hashes = {}
with open(filepath, 'rb') as f:
data = f.read()
for algo in ['md5', 'sha1', 'sha256']:
h = hashlib.new(algo)
h.update(data)
hashes[algo] = h.hexdigest()
return hashes
if __name__ == "__main__":
if len(sys.argv) < 3:
print(f"Usage: {sys.argv[0]} <legitimate_binary> <suspect_binary>")
sys.exit(1)
report = compare_pe_files(sys.argv[1], sys.argv[2])
print(json.dumps(report, indent=2))
Validation Criteria
- Trojanized components identified through binary diffing
- Injected code isolated and analyzed separately
- Code signing anomalies documented
- Infection timeline reconstructed from build artifacts
- Downstream impact scope assessed across affected systems
- IOCs extracted for detection and blocking
References
1---2name: analyzing-supply-chain-malware-artifacts3description: Investigate supply chain attack artifacts including4version: '1.0'5author: mahipal (vendored by SOCIS)6license: Apache-2.07platforms:8- linux9- macos10- windows11category: security12metadata:13 source: https://skillmd.com/skills/socisio/analyzing-supply-chain-malware-artifacts14 socis:15 tags:16 - supply-chain17 - malware-analysis18 - trojanized-software19 - solarwinds20 - 3cx21 - dependency-confusion22 - software-integrity23 subdomain: malware-analysis24 upstream: mukul975/Anthropic-Cybersecurity-Skills25 nist_csf:26 - DE.AE-0227 - RS.AN-0328 - ID.RA-0129 - DE.CM-0130 atlas_techniques:31 - AML.T001032 d3fend_techniques:33 - Platform Hardening34 - Hardware Component Inventory35 - Restore Object36 - Electromagnetic Radiation Hardening37 - RF Shielding38 nist_ai_rmf:39 - GOVERN-5.240 - MAP-1.641 - MANAGE-2.242 mitre_attack:43 - T1195.00244 - T1195.00145 - T155446 - T1553.00247 - T102748---4950# Analyzing Supply Chain Malware Artifacts5152## Overview5354Supply chain attacks compromise legitimate software distribution channels to deliver malware through trusted update mechanisms. Notable examples include SolarWinds SUNBURST (2020, affecting 18,000+ customers), 3CX SmoothOperator (2023, a cascading supply chain attack originating from Trading Technologies), and numerous npm/PyPI package poisoning campaigns. Analysis involves comparing trojanized binaries against legitimate versions, identifying injected code in build artifacts, examining code signing anomalies, and tracing the infection chain from initial compromise through payload delivery. As of 2025, supply chain attacks account for 30% of all breaches, a 100% increase from prior years.555657## When to Use5859- When investigating security incidents that require analyzing supply chain malware artifacts60- When building detection rules or threat hunting queries for this domain61- When SOC analysts need structured procedures for this analysis type62- When validating security monitoring coverage for related attack techniques6364## Prerequisites6566- Python 3.9+ with `pefile`, `ssdeep`, `hashlib`67- Binary diff tools (BinDiff, Diaphora)68- Code signing verification tools (sigcheck, codesign)69- Software composition analysis (SCA) tools70- Access to legitimate software versions for comparison71- Package repository monitoring (npm, PyPI, NuGet)7273## Workflow7475### Step 1: Binary Comparison Analysis7677```python78#!/usr/bin/env python379"""Compare trojanized binary against legitimate version."""80import hashlib81import pefile82import sys83import json848586def compare_pe_files(legitimate_path, suspect_path):87 """Compare PE file structures between legitimate and suspect versions."""88 legit_pe = pefile.PE(legitimate_path)89 suspect_pe = pefile.PE(suspect_path)9091 report = {"differences": [], "suspicious_sections": [], "import_changes": []}9293 # Compare sections94 legit_sections = {s.Name.rstrip(b'\x00').decode(): {95 "size": s.SizeOfRawData,96 "entropy": s.get_entropy(),97 "characteristics": s.Characteristics,98 } for s in legit_pe.sections}99100 suspect_sections = {s.Name.rstrip(b'\x00').decode(): {101 "size": s.SizeOfRawData,102 "entropy": s.get_entropy(),103 "characteristics": s.Characteristics,104 } for s in suspect_pe.sections}105106 # Find new or modified sections107 for name, props in suspect_sections.items():108 if name not in legit_sections:109 report["suspicious_sections"].append({110 "name": name, "reason": "New section not in legitimate version",111 "size": props["size"], "entropy": round(props["entropy"], 2),112 })113 elif abs(props["size"] - legit_sections[name]["size"]) > 1024:114 report["suspicious_sections"].append({115 "name": name, "reason": "Section size significantly changed",116 "legit_size": legit_sections[name]["size"],117 "suspect_size": props["size"],118 })119120 # Compare imports121 legit_imports = set()122 if hasattr(legit_pe, 'DIRECTORY_ENTRY_IMPORT'):123 for entry in legit_pe.DIRECTORY_ENTRY_IMPORT:124 for imp in entry.imports:125 if imp.name:126 legit_imports.add(f"{entry.dll.decode()}!{imp.name.decode()}")127128 suspect_imports = set()129 if hasattr(suspect_pe, 'DIRECTORY_ENTRY_IMPORT'):130 for entry in suspect_pe.DIRECTORY_ENTRY_IMPORT:131 for imp in entry.imports:132 if imp.name:133 suspect_imports.add(f"{entry.dll.decode()}!{imp.name.decode()}")134135 new_imports = suspect_imports - legit_imports136 if new_imports:137 report["import_changes"] = list(new_imports)138139 # Check code signing140 report["legit_signed"] = bool(legit_pe.OPTIONAL_HEADER.DATA_DIRECTORY[4].Size)141 report["suspect_signed"] = bool(suspect_pe.OPTIONAL_HEADER.DATA_DIRECTORY[4].Size)142143 return report144145146def hash_file(filepath):147 """Calculate multiple hashes for a file."""148 hashes = {}149 with open(filepath, 'rb') as f:150 data = f.read()151 for algo in ['md5', 'sha1', 'sha256']:152 h = hashlib.new(algo)153 h.update(data)154 hashes[algo] = h.hexdigest()155 return hashes156157158if __name__ == "__main__":159 if len(sys.argv) < 3:160 print(f"Usage: {sys.argv[0]} <legitimate_binary> <suspect_binary>")161 sys.exit(1)162 report = compare_pe_files(sys.argv[1], sys.argv[2])163 print(json.dumps(report, indent=2))164```165166## Validation Criteria167168- Trojanized components identified through binary diffing169- Injected code isolated and analyzed separately170- Code signing anomalies documented171- Infection timeline reconstructed from build artifacts172- Downstream impact scope assessed across affected systems173- IOCs extracted for detection and blocking174175## References176177- [ReversingLabs - 3CX Supply Chain Analysis](https://www.reversinglabs.com/blog/what-went-wrong-with-the-3cx-software-supply-chain-attack-and-how-it-could-have-been-prevented)178- [Fortinet - SolarWinds Supply Chain Attack](https://www.fortinet.com/resources/cyberglossary/solarwinds-cyber-attack)179- [Picus - 3CX SmoothOperator Analysis](https://www.picussecurity.com/resource/blog/smoothoperator-analysis-of-3cxdesktopapp-supply-chain-attack)180- [MITRE ATT&CK T1195 - Supply Chain Compromise](https://attack.mitre.org/techniques/T1195/)