id: nfs-daemon-service

info:
  name: NFS Service Daemon Should Be Disabled
  author: songyaeji
  severity: high
  description: |
     Assessed the status of the NFS service daemon. A running NFS service may expose the system to unauthorized access, modification, or deletion of files; it is recommended to disable the daemon when not explicitly required.
  reference:
    - https://isms.kisa.or.kr
  tags: linux,local,audit,kisa,compliance

self-contained: true

code:
  - engine:
      - sh
      - bash
    source: |
      if command -v systemctl >/dev/null 2>&1; then
        if systemctl is-active --quiet nfs-server; then
          echo "[VULNERABLE] NFS service is active (systemd nfs-server is running)"
        else
          echo "[SAFE] NFS service is not running"
        fi
      else
        if ps -ef | grep -v grep | grep -q nfsd; then
          echo "[VULNERABLE] NFS service is active (nfsd is running)"
        else
          echo "[SAFE] NFS service is not running"
        fi
      fi

    matchers:
      - type: word
        part: response
        words:
          - "[VULNERABLE]"
# digest: 490a0046304402202e365f52032e4d73bd77139c21b39a53cde40c7ccfcadc601d7838be496b568702205752a5bedecd1cdfe538de1f56707780e86398de4153e89ba87a4a2d5ca82f11:922c64590222798bb761d5b6d8e72950