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-artifacts
3description: Investigate supply chain attack artifacts including trojanized software
4 updates, compromised build pipelines, and sideloaded dependencies to identify intrusion
5 vectors and scope of compromise.
6domain: cybersecurity
7subdomain: malware-analysis
8tags:
9- supply-chain
10- malware-analysis
11- trojanized-software
12- solarwinds
13- 3cx
14- dependency-confusion
15- software-integrity
16version: '1.0'
17author: mahipal
18license: Apache-2.0
19atlas_techniques:
20- AML.T0010
21- AML.T0104
22nist_ai_rmf:
23- GOVERN-5.2
24- MAP-1.6
25- MANAGE-2.2
26d3fend_techniques:
27- Platform Hardening
28- Hardware Component Inventory
29- Restore Object
30- Electromagnetic Radiation Hardening
31- RF Shielding
32nist_csf:
33- DE.AE-02
34- RS.AN-03
35- ID.RA-01
36- DE.CM-01
37mitre_attack:
38- T1195.002
39- T1195.001
40- T1554
41- T1553.002
42- T1027
43source: https://github.com/mukul975/Anthropic-Cybersecurity-Skills
44source_commit: 04450304b12645cb2b974ab96d28c0664758a88d
45metadata:
46 source: https://skillmd.com/skills/yanacuti1121/analyzing-supply-chain-malware-artifacts
47---
48
49# Analyzing Supply Chain Malware Artifacts
50
51## Overview
52
53Supply 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.
54
55
56## When to Use
57
58- When investigating security incidents that require analyzing supply chain malware artifacts
59- When building detection rules or threat hunting queries for this domain
60- When SOC analysts need structured procedures for this analysis type
61- When validating security monitoring coverage for related attack techniques
62
63## Prerequisites
64
65- Python 3.9+ with `pefile`, `ssdeep`, `hashlib`
66- Binary diff tools (BinDiff, Diaphora)
67- Code signing verification tools (sigcheck, codesign)
68- Software composition analysis (SCA) tools
69- Access to legitimate software versions for comparison
70- Package repository monitoring (npm, PyPI, NuGet)
71
72## Workflow
73
74### Step 1: Binary Comparison Analysis
75
76```python
77#!/usr/bin/env python3
78"""Compare trojanized binary against legitimate version."""
79import hashlib
80import pefile
81import sys
82import json
83
84
85def compare_pe_files(legitimate_path, suspect_path):
86 """Compare PE file structures between legitimate and suspect versions."""
87 legit_pe = pefile.PE(legitimate_path)
88 suspect_pe = pefile.PE(suspect_path)
89
90 report = {"differences": [], "suspicious_sections": [], "import_changes": []}
91
92 # Compare sections
93 legit_sections = {s.Name.rstrip(b'\x00').decode(): {
94 "size": s.SizeOfRawData,
95 "entropy": s.get_entropy(),
96 "characteristics": s.Characteristics,
97 } for s in legit_pe.sections}
98
99 suspect_sections = {s.Name.rstrip(b'\x00').decode(): {
100 "size": s.SizeOfRawData,
101 "entropy": s.get_entropy(),
102 "characteristics": s.Characteristics,
103 } for s in suspect_pe.sections}
104
105 # Find new or modified sections
106 for name, props in suspect_sections.items():
107 if name not in legit_sections:
108 report["suspicious_sections"].append({
109 "name": name, "reason": "New section not in legitimate version",
110 "size": props["size"], "entropy": round(props["entropy"], 2),
111 })
112 elif abs(props["size"] - legit_sections[name]["size"]) > 1024:
113 report["suspicious_sections"].append({
114 "name": name, "reason": "Section size significantly changed",
115 "legit_size": legit_sections[name]["size"],
116 "suspect_size": props["size"],
117 })
118
119 # Compare imports
120 legit_imports = set()
121 if hasattr(legit_pe, 'DIRECTORY_ENTRY_IMPORT'):
122 for entry in legit_pe.DIRECTORY_ENTRY_IMPORT:
123 for imp in entry.imports:
124 if imp.name:
125 legit_imports.add(f"{entry.dll.decode()}!{imp.name.decode()}")
126
127 suspect_imports = set()
128 if hasattr(suspect_pe, 'DIRECTORY_ENTRY_IMPORT'):
129 for entry in suspect_pe.DIRECTORY_ENTRY_IMPORT:
130 for imp in entry.imports:
131 if imp.name:
132 suspect_imports.add(f"{entry.dll.decode()}!{imp.name.decode()}")
133
134 new_imports = suspect_imports - legit_imports
135 if new_imports:
136 report["import_changes"] = list(new_imports)
137
138 # Check code signing
139 report["legit_signed"] = bool(legit_pe.OPTIONAL_HEADER.DATA_DIRECTORY[4].Size)
140 report["suspect_signed"] = bool(suspect_pe.OPTIONAL_HEADER.DATA_DIRECTORY[4].Size)
141
142 return report
143
144
145def hash_file(filepath):
146 """Calculate multiple hashes for a file."""
147 hashes = {}
148 with open(filepath, 'rb') as f:
149 data = f.read()
150 for algo in ['md5', 'sha1', 'sha256']:
151 h = hashlib.new(algo)
152 h.update(data)
153 hashes[algo] = h.hexdigest()
154 return hashes
155
156
157if __name__ == "__main__":
158 if len(sys.argv) < 3:
159 print(f"Usage: {sys.argv[0]} <legitimate_binary> <suspect_binary>")
160 sys.exit(1)
161 report = compare_pe_files(sys.argv[1], sys.argv[2])
162 print(json.dumps(report, indent=2))
163```
164
165## Validation Criteria
166
167- Trojanized components identified through binary diffing
168- Injected code isolated and analyzed separately
169- Code signing anomalies documented
170- Infection timeline reconstructed from build artifacts
171- Downstream impact scope assessed across affected systems
172- IOCs extracted for detection and blocking
173
174## References
175
176- [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)
177- [Fortinet - SolarWinds Supply Chain Attack](https://www.fortinet.com/resources/cyberglossary/solarwinds-cyber-attack)
178- [Picus - 3CX SmoothOperator Analysis](https://www.picussecurity.com/resource/blog/smoothoperator-analysis-of-3cxdesktopapp-supply-chain-attack)
179- [MITRE ATT&CK T1195 - Supply Chain Compromise](https://attack.mitre.org/techniques/T1195/)