# OverlayFs Exploits

## Theory

The [overlay file system](https://docs.kernel.org/filesystems/overlayfs.html) (often abbreviated as OverlayFS) allows a user to "merge" several mount points into a unified file system resulting in single directory structure that contains underlying files and sub-directories from all sources. Common applications overlay a read/write partition over a read-only partition, such as with LiveCDs and IoT devices with limited flash memory write cycles.

An overlay filesystem combines two filesystems - an 'upper' filesystem and a 'lower' filesystem. When a name exists in both filesystems, the object in the 'upper' filesystem is visible while the object in the 'lower' filesystem is either hidden or, in the case of directories, merged with the 'upper' object.

It would be more correct to refer to an upper and lower 'directory tree' rather than 'filesystem' as it is quite possible for both directory trees to be in the same filesystem and there is no requirement that the root of a filesystem be given for either upper or lower.

## Practice

{% content-ref url="/pages/Gm4Eb0nVkaRDHnXCrecq" %}
[GameOverlayFs](/redteam/privilege-escalation/linux/kernel-exploits/overlayfs-exploits/gameoverlayfs.md)
{% endcontent-ref %}

{% content-ref url="/pages/HiT0NYP2sCeBn54CCbug" %}
[CVE-2023-0386](/redteam/privilege-escalation/linux/kernel-exploits/overlayfs-exploits/cve-2023-0386-overlayfs.md)
{% endcontent-ref %}

{% content-ref url="/pages/aVWe6uu5ooiTK7aQQJFC" %}
[CVE-2021-3493](/redteam/privilege-escalation/linux/kernel-exploits/overlayfs-exploits/cve-2021-3493.md)
{% endcontent-ref %}

## Resources

{% embed url="<https://en.wikipedia.org/wiki/OverlayFS>" %}

{% embed url="<https://docs.kernel.org/filesystems/overlayfs.html>" %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://red.infiltr8.io/redteam/privilege-escalation/linux/kernel-exploits/overlayfs-exploits.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
