Linux Python Spawning Pseudo-Terminal via pty Module

Flags Linux executions where Python imports the pty module and calls spawn to create a pseudo-TTY session.

FreeReviewedSigma · Medium · v2
Product
linux
Category
process_creation
Author
Nextron Systems (SigmaHQ), DRL 1.1
Published
2022-06-03
Updated
2026-07-31
title: Linux Python Spawning Pseudo-Terminal via pty Module
id: dd86af87-6fc8-407a-9f90-256d618c5a9c
related:
  - id: 32e62bc7-3de0-4bb1-90af-532978fe42c0
    type: similar
  - id: c4042d54-110d-45dd-a0e1-05c47822c937
    type: derived
status: test
description: This rule identifies Linux process creation where a Python interpreter imports the pty module and issues a spawn operation, consistent with creating a pseudo-terminal ("pretty tty") for interactive command execution. Attackers can use PTYs to improve shell usability, maintain interactive sessions, and support reverse shell workflows. Telemetry relies on process creation events including the executable image path and full command-line content showing the pty import and spawn usage.
references:
  - https://www.volexity.com/blog/2022/06/02/zero-day-exploitation-of-atlassian-confluence/
  - https://github.com/SigmaHQ/sigma/blob/master/rules/linux/process_creation/proc_creation_lnx_python_pty_spawn.yml
author: Nextron Systems, Huntrule Team
date: 2022-06-03
modified: 2024-11-04
tags:
  - attack.execution
  - attack.t1059
logsource:
  category: process_creation
  product: linux
detection:
  selection_img:
    - Image|endswith:
        - /python
        - /python2
        - /python3
    - Image|contains:
        - /python2.
        - /python3.
  selection_cli_import:
    CommandLine|contains:
      - import pty
      - "from pty "
  selection_cli_spawn:
    CommandLine|contains: spawn
  condition: all of selection_*
falsepositives:
  - Unknown
level: medium
license: DRL-1.1