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
Trigger phrases:
"analyzing supply chain malware artifacts"
"Investigate supply chain attack artifacts including trojanized software updates,"
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
- Isolate the sample — ensure the malware is in a sandboxed environment with no network access
- Record file metadata — hash the sample and note file type, size, and compile timestamp
- Static analysis — examine strings, imports, and disassembled code without execution
- Dynamic analysis — execute in a monitored sandbox and record behavior (file, registry, network)
- Document IOCs — extract indicators of compromise and write the analysis report
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
When NOT to Use
- You need to perform the attack, not analyze it (use performing-* skills)
- Task is about detection, not analysis (use detecting-* skills)
- You need to implement controls (use implementing-* skills)
- Task is about threat hunting, not post-incident analysis (use hunting-* skills)
- You don't have access to the artifacts/logs to analyze
- Task requires real-time monitoring (use SOC tools)
Red Flags
- Performing actions without explicit written authorization from the asset owner
- Testing against production systems without a defined scope and rules of engagement
- Analyzing malware on a machine connected to the production network
- Failing to isolate the analysis environment from the internet
- Executing samples without proper containment (VM, sandbox)
Verification
- All steps executed successfully against a test environment before production use
- Output documented with screenshots or logs demonstrating expected behavior
- Sample hash recorded and verified (MD5, SHA-1, SHA-256)
- Analysis environment confirmed isolated from production network
- Indicators of compromise (IOCs) extracted and documented
References
Process
- Analyze the task requirements
- Apply domain expertise
- Verify output quality
Anti-Rationalization Table
| Rationalization |
Reality |
| "We are too small to be targeted" |
Automated attacks target everyone. Size does not matter. |
| "Security slows us down" |
A breach slows you down 100x more. Build security in from the start. |
| "We will fix it after launch" |
Vulnerabilities in production are exploited within hours. Fix before deploy. |
1---2name: analyzing-supply-chain-malware-artifacts3description: Use when investigate supply chain attack artifacts including trojanized4 software updates, compromised build pipelines, and sideloaded dependencies to identify5 intrusion vectors and scope of compromise. Use when working with analyzing supply6 chain malware artifacts.7domain: cybersecurity8subdomain: malware-analysis9tags:10- supply-chain11- malware-analysis12- trojanized-software13- solarwinds14- 3cx15- dependency-confusion16- software-integrity17version: '1.0'18author: oyi7719license: Apache-2.020atlas_techniques:21- AML.T001022- AML.T010423nist_ai_rmf:24- GOVERN-5.225- MAP-1.626- MANAGE-2.227d3fend_techniques:28- Platform Hardening29- Hardware Component Inventory30- Restore Object31- Electromagnetic Radiation Hardening32- RF Shielding33nist_csf:34- DE.AE-0235- RS.AN-0336- ID.RA-0137- DE.CM-0138category: cybersecurity39metadata:40 source: https://skillmd.com/skills/oyi77/analyzing-supply-chain-malware-artifacts41---4243# Analyzing Supply Chain Malware Artifacts4445## Overview4647Supply 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.484950## When to Use51**Trigger phrases:**52- "analyzing supply chain malware artifacts"53- "Investigate supply chain attack artifacts including trojanized software updates,"545556- When investigating security incidents that require analyzing supply chain malware artifacts57- When building detection rules or threat hunting queries for this domain58- When SOC analysts need structured procedures for this analysis type59- When validating security monitoring coverage for related attack techniques6061## Prerequisites6263- Python 3.9+ with `pefile`, `ssdeep`, `hashlib`64- Binary diff tools (BinDiff, Diaphora)65- Code signing verification tools (sigcheck, codesign)66- Software composition analysis (SCA) tools67- Access to legitimate software versions for comparison68- Package repository monitoring (npm, PyPI, NuGet)6970## Workflow71721. **Isolate the sample** — ensure the malware is in a sandboxed environment with no network access732. **Record file metadata** — hash the sample and note file type, size, and compile timestamp743. **Static analysis** — examine strings, imports, and disassembled code without execution754. **Dynamic analysis** — execute in a monitored sandbox and record behavior (file, registry, network)765. **Document IOCs** — extract indicators of compromise and write the analysis report77### Step 1: Binary Comparison Analysis7879```python80#!/usr/bin/env python381"""Compare trojanized binary against legitimate version."""82import hashlib83import pefile84import sys85import json868788def compare_pe_files(legitimate_path, suspect_path):89 """Compare PE file structures between legitimate and suspect versions."""90 legit_pe = pefile.PE(legitimate_path)91 suspect_pe = pefile.PE(suspect_path)9293 report = {"differences": [], "suspicious_sections": [], "import_changes": []}9495 # Compare sections96 legit_sections = {s.Name.rstrip(b'\x00').decode(): {97 "size": s.SizeOfRawData,98 "entropy": s.get_entropy(),99 "characteristics": s.Characteristics,100 } for s in legit_pe.sections}101102 suspect_sections = {s.Name.rstrip(b'\x00').decode(): {103 "size": s.SizeOfRawData,104 "entropy": s.get_entropy(),105 "characteristics": s.Characteristics,106 } for s in suspect_pe.sections}107108 # Find new or modified sections109 for name, props in suspect_sections.items():110 if name not in legit_sections:111 report["suspicious_sections"].append({112 "name": name, "reason": "New section not in legitimate version",113 "size": props["size"], "entropy": round(props["entropy"], 2),114 })115 elif abs(props["size"] - legit_sections[name]["size"]) > 1024:116 report["suspicious_sections"].append({117 "name": name, "reason": "Section size significantly changed",118 "legit_size": legit_sections[name]["size"],119 "suspect_size": props["size"],120 })121122 # Compare imports123 legit_imports = set()124 if hasattr(legit_pe, 'DIRECTORY_ENTRY_IMPORT'):125 for entry in legit_pe.DIRECTORY_ENTRY_IMPORT:126 for imp in entry.imports:127 if imp.name:128 legit_imports.add(f"{entry.dll.decode()}!{imp.name.decode()}")129130 suspect_imports = set()131 if hasattr(suspect_pe, 'DIRECTORY_ENTRY_IMPORT'):132 for entry in suspect_pe.DIRECTORY_ENTRY_IMPORT:133 for imp in entry.imports:134 if imp.name:135 suspect_imports.add(f"{entry.dll.decode()}!{imp.name.decode()}")136137 new_imports = suspect_imports - legit_imports138 if new_imports:139 report["import_changes"] = list(new_imports)140141 # Check code signing142 report["legit_signed"] = bool(legit_pe.OPTIONAL_HEADER.DATA_DIRECTORY[4].Size)143 report["suspect_signed"] = bool(suspect_pe.OPTIONAL_HEADER.DATA_DIRECTORY[4].Size)144145 return report146147148def hash_file(filepath):149 """Calculate multiple hashes for a file."""150 hashes = {}151 with open(filepath, 'rb') as f:152 data = f.read()153 for algo in ['md5', 'sha1', 'sha256']:154 h = hashlib.new(algo)155 h.update(data)156 hashes[algo] = h.hexdigest()157 return hashes158159160if __name__ == "__main__":161 if len(sys.argv) < 3:162 print(f"Usage: {sys.argv[0]} <legitimate_binary> <suspect_binary>")163 sys.exit(1)164 report = compare_pe_files(sys.argv[1], sys.argv[2])165 print(json.dumps(report, indent=2))166```167168## Validation Criteria169170- Trojanized components identified through binary diffing171- Injected code isolated and analyzed separately172- Code signing anomalies documented173- Infection timeline reconstructed from build artifacts174- Downstream impact scope assessed across affected systems175- IOCs extracted for detection and blocking176177## When NOT to Use178179- You need to perform the attack, not analyze it (use performing-* skills)180- Task is about detection, not analysis (use detecting-* skills)181- You need to implement controls (use implementing-* skills)182- Task is about threat hunting, not post-incident analysis (use hunting-* skills)183- You don't have access to the artifacts/logs to analyze184- Task requires real-time monitoring (use SOC tools)185186187## Red Flags188189- Performing actions without explicit written authorization from the asset owner190- Testing against production systems without a defined scope and rules of engagement191- Analyzing malware on a machine connected to the production network192- Failing to isolate the analysis environment from the internet193- Executing samples without proper containment (VM, sandbox)194195## Verification196197- All steps executed successfully against a test environment before production use198- Output documented with screenshots or logs demonstrating expected behavior199- Sample hash recorded and verified (MD5, SHA-1, SHA-256)200- Analysis environment confirmed isolated from production network201- Indicators of compromise (IOCs) extracted and documented202203## References204205- [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)206- [Fortinet - SolarWinds Supply Chain Attack](https://www.fortinet.com/resources/cyberglossary/solarwinds-cyber-attack)207- [Picus - 3CX SmoothOperator Analysis](https://www.picussecurity.com/resource/blog/smoothoperator-analysis-of-3cxdesktopapp-supply-chain-attack)208- [MITRE ATT&CK T1195 - Supply Chain Compromise](https://attack.mitre.org/techniques/T1195/)209210## Process2112121. Analyze the task requirements2132. Apply domain expertise2143. Verify output quality215216## Anti-Rationalization Table217218| Rationalization | Reality |219|---|---|220| "We are too small to be targeted" | Automated attacks target everyone. Size does not matter. |221| "Security slows us down" | A breach slows you down 100x more. Build security in from the start. |222| "We will fix it after launch" | Vulnerabilities in production are exploited within hours. Fix before deploy. |