id: privesc-cdist

info:
  name: Cdist - Privilege Escalation
  author: daffainfo
  severity: high
  description: |
    cdist is a free software configuration management tool for Unix-like systems. It manages nodes over SSH using the Bourne Shell, and does not require any additional software to be installed on target nodes.
  reference:
    - https://gtfobins.github.io/gtfobins/cdist/
  metadata:
    verified: true
    max-request: 3
  tags: code,linux,cdist,privesc,local

self-contained: true
code:
  - engine:
      - sh
      - bash
    source: |
      whoami

  - engine:
      - sh
      - bash
    source: |
      cdist shell -s whoami

  - engine:
      - sh
      - bash
    source: |
      sudo cdist shell -s whoami

    matchers-condition: and
    matchers:
      - type: word
        part: code_1_response
        words:
          - "root"
        negative: true

      - type: dsl
        dsl:
          - 'contains(code_2_response, "root")'
          - 'contains(code_3_response, "root")'
        condition: or
# digest: 4a0a00473045022100cfa29fa9d6ec8feab0ec2f0699290904b413f9d3c4df22f8005c5b864dea8a980220563a6a9dba54919b894ff069d2c82b84193c21def957c29f4905b97fc18e9a52:922c64590222798bb761d5b6d8e72950