For AI agents: A markdown version of this page is available at https://docs.datadoghq.com/security/default_rules/def-000-pqk.md. A documentation index is available at /llms.txt.

Uninstall ypserv Package

Description

The ypserv package can be removed with the following command:

$ apt-get remove ypserv

Rationale

The NIS service provides an unencrypted authentication service which does not provide for the confidentiality and integrity of user passwords or the remote session. Removing the ypserv package decreases the risk of the accidental (or intentional) activation of NIS or NIS+ services.

Remediation

Shell script

The following script can be run on the host to remediate the issue.

#!/bin/bash

# CAUTION: This remediation script will remove ypserv
# from the system, and may remove any packages
# that depend on ypserv. Execute this
# remediation AFTER testing on a non-production
# system!


# check wether the package is virtual: if not, remove it.
# if the package is virtual, iterate on providers
#  if a provider is installed, remove it
is_virtual=`apt-cache showpkg "ypserv" | grep -Pzc 'Versions: \n\n'`
if [ $is_virtual = 1 ]; then
    rprovides_line=`apt-cache showpkg "ypserv" | grep -n 'Reverse Provides:' | cut -f1 -d:`
    pkglist=`apt-cache showpkg "ypserv" | tail -n +$(($rprovides_line + 1)) | cut -f1 -d' '`
    for package in $pkglist; do
        not_installed=`apt-cache policy $package | grep -c 'Installed: (none)'`
	if [ $not_installed = 0 ]; then
	    DEBIAN_FRONTEND=noninteractive apt-get -o DPkg::Lock::Timeout=60 remove -y $package
	fi
    done
else
    DEBIAN_FRONTEND=noninteractive apt-get -o DPkg::Lock::Timeout=60 remove -y "ypserv"
fi

Ansible playbook

The following playbook can be run with Ansible to remediate the issue.

- name: 'Uninstall ypserv Package: Ensure ypserv is removed'
  ansible.builtin.package:
    name: ypserv
    state: absent
  tags:
  - NIST-800-53-CM-6(a)
  - NIST-800-53-CM-7(a)
  - NIST-800-53-CM-7(b)
  - NIST-800-53-IA-5(1)(c)
  - PCI-DSS-Req-2.2.2
  - PCI-DSSv4-2.2
  - PCI-DSSv4-2.2.4
  - disable_strategy
  - high_severity
  - low_complexity
  - low_disruption
  - no_reboot_needed
  - package_ypserv_removed