{
  "id": "CB-UBU-FS-004",
  "standard": "ubuntu",
  "version": "0.1.2",
  "url": "https://baselines.cirsec.org/b/ubuntu/v0.1.2/CB-UBU-FS-004",
  "json": "https://baselines.cirsec.org/b/ubuntu/v0.1.2/CB-UBU-FS-004.json",
  "yaml": "https://baselines.cirsec.org/b/ubuntu/v0.1.2/CB-UBU-FS-004.yml",
  "profiles_effective": [
    "core",
    "server",
    "server-hardened",
    "desktop",
    "desktop-hardened"
  ],
  "license": "Text CC BY 4.0, code Apache-2.0",
  "attribution": "CIRSEC Baselines, https://baselines.cirsec.org",
  "control": {
    "id": "CB-UBU-FS-004",
    "title": "Mount /dev/shm with nodev, nosuid and noexec",
    "finding": {
      "title": "Programs can be run from the shared memory filesystem",
      "description": "/dev/shm is writable by every user and lives only in memory, which makes it a convenient place to run attack tools without leaving files on disk."
    },
    "status": "active",
    "profiles": [
      "core"
    ],
    "risk": {
      "severity": "medium"
    },
    "assessment": "automated",
    "tags": [
      "mount",
      "shm",
      "tmpfs"
    ],
    "description": "`/dev/shm` is the tmpfs used for POSIX shared memory. systemd mounts it at boot with `nodev` and\n`nosuid`. This control also requires `noexec`, set through a `/dev/shm` line in `/etc/fstab`\nthat systemd applies at boot.\n",
    "rationale": "Every user can write to `/dev/shm`, and its content never reaches the disk. Attackers use it to\nstore and run tools while leaving few traces. `noexec` blocks direct execution, `nosuid` and\n`nodev` stop setuid files and device nodes placed there from being used.\n",
    "impact": "Programs that map executable code from files in `/dev/shm` fail. This is rare (some JIT engines\nand old database software); check vendor requirements before applying on such systems.\n",
    "setting": {
      "location": "/etc/fstab",
      "default_value": "nodev,nosuid (no noexec)",
      "recommended_value": "nodev,nosuid,noexec"
    },
    "audit": {
      "manual": "Run `findmnt -kn /dev/shm`. Its options must contain `nodev`, `nosuid` and `noexec`.\n",
      "checks": [
        {
          "id": "mount",
          "engine": "shell",
          "description": "/dev/shm is a mount point and its options include nodev, nosuid and noexec.",
          "spec": {
            "script": "o=$(findmnt -kn -o SOURCE,FSTYPE,OPTIONS --mountpoint /dev/shm | tail -n 1)\n[ -n \"$o\" ] || { echo \"/dev/shm is not mounted\"; exit 1; }\necho \"/dev/shm $o\"\nrc=0\nfor opt in nodev nosuid noexec; do\n  case ,${o##* }, in *,$opt,*) ;; *) echo \"missing $opt\"; rc=1 ;; esac\ndone\nexit $rc\n"
          }
        }
      ]
    },
    "remediation": {
      "manual": "1. If `/etc/fstab` has a `/dev/shm` line, add `nodev,nosuid,noexec` to its options. Otherwise\n   add the line:\n   ```\n   tmpfs /dev/shm tmpfs defaults,nodev,nosuid,noexec 0 0\n   ```\n2. Run `systemctl daemon-reload` and `mount -o remount,nodev,nosuid,noexec /dev/shm`.\n",
      "effects": {
        "restart": "none",
        "disruption": "low",
        "lockout_risk": false
      },
      "rollback": "Remove the `/dev/shm` line from `/etc/fstab` (or restore the copy saved in the backup\ndirectory), run `systemctl daemon-reload` and `mount -o remount,exec /dev/shm`.\n",
      "scripts": [
        {
          "id": "fstab",
          "engine": "shell",
          "file": "fix.sh"
        }
      ]
    },
    "references": [
      {
        "title": "fstab(5), Ubuntu manual pages",
        "url": "https://manpages.ubuntu.com/manpages/noble/man5/fstab.5.html",
        "publisher": "Canonical",
        "kind": "vendor-doc",
        "accessed": "2026-10-19"
      },
      {
        "title": "systemd-fstab-generator(8), Ubuntu manual pages",
        "url": "https://manpages.ubuntu.com/manpages/noble/man8/systemd-fstab-generator.8.html",
        "publisher": "Canonical",
        "kind": "vendor-doc",
        "accessed": "2026-10-19"
      },
      {
        "title": "mount(8), Ubuntu manual pages (filesystem-independent mount options)",
        "url": "https://manpages.ubuntu.com/manpages/noble/man8/mount.8.html",
        "publisher": "Canonical",
        "kind": "vendor-doc",
        "accessed": "2026-10-19"
      }
    ],
    "mappings": [
      {
        "framework": "nist-800-53r5",
        "framework_version": "5.1.1",
        "id": "CM-7",
        "relation": "related"
      }
    ],
    "threats": [
      {
        "framework": "mitre-attack",
        "id": "T1548.001"
      },
      {
        "framework": "cwe",
        "id": "CWE-732"
      }
    ],
    "related_controls": [
      {
        "id": "CB-UBU-FS-003",
        "type": "related"
      }
    ],
    "authors": [
      {
        "name": "Alice",
        "github": "Sn0wAlice"
      }
    ],
    "verified": [
      {
        "date": "2026-10-19",
        "by": "Sn0wAlice",
        "versions": [
          "20.04"
        ],
        "environment": "Proxmox VM 2520, Ubuntu 20.04 cloud image, kernel 5.4.0-216-generic",
        "notes": "Fails on fresh install (no noexec); fix adds an fstab line and remounts; options kept after reboot; second run leaves fstab unchanged."
      },
      {
        "date": "2026-10-19",
        "by": "Sn0wAlice",
        "versions": [
          "22.04"
        ],
        "environment": "Proxmox VM 2522, Ubuntu 22.04 cloud image, kernel 5.15.0-198-generic",
        "notes": "Fails on fresh install (no noexec); fix adds an fstab line and remounts; options kept after reboot; second run leaves fstab unchanged."
      },
      {
        "date": "2026-10-19",
        "by": "Sn0wAlice",
        "versions": [
          "24.04"
        ],
        "environment": "Proxmox VM 2524, Ubuntu 24.04 cloud image, kernel 6.8.0-147-generic",
        "notes": "Fails on fresh install (no noexec); fix adds an fstab line and remounts; options kept after reboot; second run leaves fstab unchanged."
      },
      {
        "date": "2026-10-19",
        "by": "Sn0wAlice",
        "versions": [
          "26.04"
        ],
        "environment": "Proxmox VM 2526, Ubuntu 26.04 cloud image, kernel 7.0.0-38-generic",
        "notes": "Fails on fresh install (no noexec); fix adds an fstab line and remounts; options kept after reboot; second run leaves fstab unchanged."
      }
    ],
    "introduced_in": "0.1.0",
    "created": "2026-10-19",
    "updated": "2026-10-19"
  }
}