---
title: Ensure overlayfs kernel module is not available
description: Datadog, the leading service for cloud-scale monitoring.
breadcrumbs: >-
  Docs > Datadog Security > OOTB Rules > Ensure overlayfs kernel module is not
  available
---

> For the complete documentation index, see [llms.txt](https://docs.datadoghq.com/llms.txt).

# Ensure overlayfs kernel module is not available
 
## Description{% #description %}

To configure the system to prevent the `overlay` kernel module from being loaded, add the following line to the file `/etc/modprobe.d/overlay.conf`:

```
install overlay /bin/false
```

This entry will cause a non-zero return value during a `overlay` module installation and additionally convey the meaning of the entry to the user in form of an error message. If you would like to omit a non-zero return value and an error message, you may want to add a different line instead (both `/bin/true` and `/bin/false` are allowed by OVAL and will be accepted by the scan):

```
install overlay /bin/true
```

To configure the system to prevent the `overlay` from being used, add the following line to file `/etc/modprobe.d/overlay.conf`:

```
blacklist overlay
```

overlayfs is a Linux filesystem that layers multiple filesystems to create a single unified view which allows a user to "merge" several mount points into a unified filesystem.

## Rationale{% #rationale %}

The overlayfs has known CVE's. Disabling the overlayfs reduces the local attack surface by removing support for unnecessary filesystem types and mitigates potential risks associated with unauthorized execution of setuid files, enhancing the overall system security.

## Remediation{% #remediation %}

### Shell script{% #shell-script %}

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

```bash
#!/bin/bash

# Remediation is applicable only in certain platforms
if rpm --quiet -q kernel; then

if LC_ALL=C grep -q -m 1 "^install overlay" /etc/modprobe.d/overlay.conf ; then
	
	sed -i 's#^install overlay.*#install overlay /bin/false#g' /etc/modprobe.d/overlay.conf
else
	echo -e "\n# Disable per security requirements" >> /etc/modprobe.d/overlay.conf
	echo "install overlay /bin/false" >> /etc/modprobe.d/overlay.conf
fi

if ! LC_ALL=C grep -q -m 1 "^blacklist overlay$" /etc/modprobe.d/overlay.conf ; then
	echo "blacklist overlay" >> /etc/modprobe.d/overlay.conf
fi

else
    >&2 echo 'Remediation is not applicable, nothing was done'
fi
```

### Ansible playbook{% #ansible-playbook %}

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

```go
- name: Gather the package facts
  package_facts:
    manager: auto
  tags:
  - disable_strategy
  - kernel_module_overlayfs_disabled
  - low_complexity
  - low_severity
  - medium_disruption
  - reboot_required

- name: Ensure kernel module 'overlay' is disabled
  ansible.builtin.lineinfile:
    create: true
    dest: /etc/modprobe.d/overlay.conf
    regexp: install\s+overlay
    line: install overlay /bin/false
    mode: 420
  when: '"kernel" in ansible_facts.packages'
  tags:
  - disable_strategy
  - kernel_module_overlayfs_disabled
  - low_complexity
  - low_severity
  - medium_disruption
  - reboot_required

- name: Ensure kernel module 'overlay' is blacklisted
  ansible.builtin.lineinfile:
    create: true
    dest: /etc/modprobe.d/overlay.conf
    regexp: ^blacklist overlay$
    line: blacklist overlay
    mode: 420
  when: '"kernel" in ansible_facts.packages'
  tags:
  - disable_strategy
  - kernel_module_overlayfs_disabled
  - low_complexity
  - low_severity
  - medium_disruption
  - reboot_required
```
