id: dnsmasq-service

info:
  name: Ensure dnsmasq Service is Not Installed
  author: Th3l0newolf
  severity: info
  description: |
    The dnsmasq package provides lightweight DNS, DHCP, and TFTP services. If not explicitly required, its presence may expose unnecessary services and increase security risks.
  remediation: |
    - Ensure the `dnsmasq` package is not installed unless explicitly required.
    - To remove the package, run: sudo apt-get remove dnsmasq -y
  reference:
    - https://www.cisecurity.org/benchmark/ubuntu_linux
  metadata:
    verified: true
  tags: cis,local,cisecurity,audit,linux,ubuntu

self-contained: true

code:
  - engine:
      - bash
    args:
      - "-c"
      - |
        if dpkg-query -s dnsmasq &>/dev/null; then
          echo "[dnsmasq-service-check:Policy-Fail] [dnsmasq is installed] [CIS_FAIL]"
        else
          echo "[dnsmasq-service-check:Policy-Pass] [dnsmasq is not installed] [CIS_PASS]"
        fi

    matchers:
      - type: word
        name: policy-pass
        words:
          - "Policy-Pass"

      - type: word
        name: policy-fail
        words:
          - "Policy-Fail"
# digest: 4a0a0047304502210096d5ee4d88f2bcf276e1d30f7d440f27c00ed4a5afca848de514d11a3d2d7fc80220742d89f57a4da6922d14a351db1f31477f7fb513d0627d35d7b0fcdb28f69e5b:922c64590222798bb761d5b6d8e72950