MITRE ATT&CK T1546.018: Python Startup Hooks
When to use this skill
Use this skill when the task involves T1546.018, Python Startup Hooks, enterprise ATT&CK, TTP mapping, detection engineering, hunting, incident-response enrichment, control validation, or authorized adversary-emulation planning. Treat it as a defensive analysis aid: keep outputs focused on understanding, detecting, mitigating, and safely validating this ATT&CK sub-technique.
Technique context
- ATT&CK domain: enterprise
- ATT&CK ID: T1546.018
- Technique name: Python Startup Hooks
- Type: sub-technique
- ATT&CK URL: https://attack.mitre.org/techniques/T1546/018
- Tactics: persistence, privilege-escalation
- Platforms: Linux, macOS, Windows
- Required permissions: Not specified
- Effective permissions: Not specified
- Defenses bypassed: Not specified
ATT&CK description
Adversaries may achieve persistence by leveraging Python’s startup mechanisms, including path configuration (.pth) files and the sitecustomize.py or usercustomize.py modules. These files are automatically processed during the initialization of the Python interpreter, allowing for the execution of arbitrary code whenever Python is invoked.(Citation: Volexity GlobalProtect CVE 2024)
Path configuration files are designed to extend Python’s module search paths through the use of import statements. If a .pth file is placed in Python's site-packages or dist-packages directories, any lines beginning with import will be executed automatically on Python invocation.(Citation: DFIR Python Persistence 2025) Similarly, if sitecustomize.py or usercustomize.py is present in the Python path, these files will be imported during interpreter startup, and any code they contain will be executed.(Citation: Python Site Configuration Hook)
Adversaries may abuse these mechanisms to establish persistence on systems where Python is widely used (e.g., for automation or scripting in production environments).
Agent workflow
- Clarify scope: identify the system, asset class, log sources, cloud or endpoint platform, and whether the user wants triage, detection, coverage assessment, or safe emulation planning.
- Load bundled resources as needed: use
references/technique-profile.json for structured metadata, references/detection-and-mitigation.md for triage and telemetry guidance, references/known-threat-context.md for ATT&CK relationship context, and templates/ for repeatable outputs.
- Map observations to ATT&CK: compare the user's evidence to the ATT&CK description, tactics, platforms, and known procedure patterns before asserting a match.
- Produce defensive outputs: prioritize hypotheses, telemetry requirements, detection logic ideas, validation steps, containment guidance, and mitigations.
- Preserve uncertainty: distinguish confirmed evidence, plausible indicators, assumptions, and gaps. Recommend what to collect next.
- Stay safe: do not provide malware, credential theft, persistence, evasion, destructive automation, or unauthorized exploitation instructions. For adversary emulation, keep steps bounded to approved lab or control-validation contexts and omit operational abuse details.
Bundled resources
references/technique-profile.json: machine-readable ATT&CK metadata for this technique.
references/detection-and-mitigation.md: detection notes, telemetry checklist, triage questions, mitigation candidates, and false-positive considerations.
references/known-threat-context.md: ATT&CK relationship context with attribution cautions.
templates/detection-brief.md: detection engineering brief template.
templates/hunt-plan.md: threat hunt plan template.
templates/incident-response-note.md: incident response note template.
templates/coverage-assessment.md: ATT&CK coverage assessment template.
scripts/render_brief.py: local helper that renders a Markdown defensive brief from technique-profile.json.
assets/output-schema.json: JSON schema for structured technique analysis outputs.
To generate a quick brief, run python scripts/render_brief.py --output brief.md from inside this skill directory, or adapt the templates directly.
Detection guidance
No ATT&CK detection guidance was present in the source STIX object.
Useful telemetry and data sources
- Not specified in the STIX object.
Mitigations to consider
- No ATT&CK mitigation relationships were present in the source STIX bundle.
Known threat context
Use these examples only as contextual leads, not as proof that an observed event is this technique:
- No group or software uses relationships were included for this technique in the source STIX bundle.
Recommended output pattern
When responding with this skill, structure the answer as:
- Assessment: whether the evidence supports this ATT&CK mapping and why.
- Evidence: specific indicators, logs, behaviors, and assumptions.
- Detection: telemetry sources, analytic logic, and tuning considerations.
- Response: containment, eradication, recovery, and validation actions.
- Coverage gaps: missing logs, sensors, controls, or environmental details.
- References: include the ATT&CK URL and any user-provided evidence references.
ATT&CK contributors
- Ruben Groenewoud (@RFGroenewoud)
- Pyae Heinn Kyaw, CSIRT @ Salesforce
1---2name: attack-ent-t1546-018-python-startup-hooks3description: "Analyze MITRE ATT&CK T1546.018 Python Startup Hooks in the enterprise matrix. Use for TTP triage, detection engineering, hunting, defensive emulation planning, mitigations, incident response mapping, ATT&CK coverage, or questions mentioning T1546.018, Python Startup Hooks, or enterprise ATT&CK. Adversaries may achieve persistence by leveraging Python’s startup mechanisms, including path configuration (`.pth`) files and the `sitecustomize.py` or `usercustomize.py` modules."4license: MITRE ATT&CK Terms of Use apply to ATT&CK-derived content. See https://attack.mitre.org/resources/terms-of-use/5metadata:6 source: https://skillmd.com/skills/santosomar/attack-ent-t1546-018-python-startup-hooks7 upstream: mitre-attack/attack-stix-data8 domain: enterprise9 attack_id: T1546.01810 attack_stix_id: attack-pattern--c5087385-9b7c-4488-9923-d9e370bf08df11 attack_version: "1.0"12 attack_modified: "2025-10-21T02:35:20.850Z"13---1415# MITRE ATT&CK T1546.018: Python Startup Hooks1617## When to use this skill1819Use this skill when the task involves T1546.018, Python Startup Hooks, enterprise ATT&CK, TTP mapping, detection engineering, hunting, incident-response enrichment, control validation, or authorized adversary-emulation planning. Treat it as a defensive analysis aid: keep outputs focused on understanding, detecting, mitigating, and safely validating this ATT&CK sub-technique.2021## Technique context2223- ATT&CK domain: enterprise24- ATT&CK ID: T1546.01825- Technique name: Python Startup Hooks26- Type: sub-technique27- ATT&CK URL: https://attack.mitre.org/techniques/T1546/01828- Tactics: persistence, privilege-escalation29- Platforms: Linux, macOS, Windows30- Required permissions: Not specified31- Effective permissions: Not specified32- Defenses bypassed: Not specified3334## ATT&CK description3536Adversaries may achieve persistence by leveraging Python’s startup mechanisms, including path configuration (`.pth`) files and the `sitecustomize.py` or `usercustomize.py` modules. These files are automatically processed during the initialization of the Python interpreter, allowing for the execution of arbitrary code whenever Python is invoked.(Citation: Volexity GlobalProtect CVE 2024)3738Path configuration files are designed to extend Python’s module search paths through the use of import statements. If a `.pth` file is placed in Python's `site-packages` or `dist-packages` directories, any lines beginning with `import` will be executed automatically on Python invocation.(Citation: DFIR Python Persistence 2025) Similarly, if `sitecustomize.py` or `usercustomize.py` is present in the Python path, these files will be imported during interpreter startup, and any code they contain will be executed.(Citation: Python Site Configuration Hook)3940Adversaries may abuse these mechanisms to establish persistence on systems where Python is widely used (e.g., for automation or scripting in production environments).4142## Agent workflow43441. Clarify scope: identify the system, asset class, log sources, cloud or endpoint platform, and whether the user wants triage, detection, coverage assessment, or safe emulation planning.452. Load bundled resources as needed: use `references/technique-profile.json` for structured metadata, `references/detection-and-mitigation.md` for triage and telemetry guidance, `references/known-threat-context.md` for ATT&CK relationship context, and `templates/` for repeatable outputs.463. Map observations to ATT&CK: compare the user's evidence to the ATT&CK description, tactics, platforms, and known procedure patterns before asserting a match.474. Produce defensive outputs: prioritize hypotheses, telemetry requirements, detection logic ideas, validation steps, containment guidance, and mitigations.485. Preserve uncertainty: distinguish confirmed evidence, plausible indicators, assumptions, and gaps. Recommend what to collect next.496. Stay safe: do not provide malware, credential theft, persistence, evasion, destructive automation, or unauthorized exploitation instructions. For adversary emulation, keep steps bounded to approved lab or control-validation contexts and omit operational abuse details.5051## Bundled resources5253- `references/technique-profile.json`: machine-readable ATT&CK metadata for this technique.54- `references/detection-and-mitigation.md`: detection notes, telemetry checklist, triage questions, mitigation candidates, and false-positive considerations.55- `references/known-threat-context.md`: ATT&CK relationship context with attribution cautions.56- `templates/detection-brief.md`: detection engineering brief template.57- `templates/hunt-plan.md`: threat hunt plan template.58- `templates/incident-response-note.md`: incident response note template.59- `templates/coverage-assessment.md`: ATT&CK coverage assessment template.60- `scripts/render_brief.py`: local helper that renders a Markdown defensive brief from `technique-profile.json`.61- `assets/output-schema.json`: JSON schema for structured technique analysis outputs.6263To generate a quick brief, run `python scripts/render_brief.py --output brief.md` from inside this skill directory, or adapt the templates directly.6465## Detection guidance6667No ATT&CK detection guidance was present in the source STIX object.6869## Useful telemetry and data sources7071- Not specified in the STIX object.7273## Mitigations to consider7475- No ATT&CK mitigation relationships were present in the source STIX bundle.7677## Known threat context7879Use these examples only as contextual leads, not as proof that an observed event is this technique:8081- No group or software uses relationships were included for this technique in the source STIX bundle.8283## Recommended output pattern8485When responding with this skill, structure the answer as:8687- Assessment: whether the evidence supports this ATT&CK mapping and why.88- Evidence: specific indicators, logs, behaviors, and assumptions.89- Detection: telemetry sources, analytic logic, and tuning considerations.90- Response: containment, eradication, recovery, and validation actions.91- Coverage gaps: missing logs, sensors, controls, or environmental details.92- References: include the ATT&CK URL and any user-provided evidence references.9394## ATT&CK contributors9596- Ruben Groenewoud (@RFGroenewoud)97- Pyae Heinn Kyaw, CSIRT @ Salesforce