{
  "id": "CB-UBU-DESK-009",
  "standard": "ubuntu",
  "version": "main",
  "url": "https://baselines.cirsec.org/b/ubuntu/CB-UBU-DESK-009",
  "json": "https://baselines.cirsec.org/b/ubuntu/CB-UBU-DESK-009.json",
  "yaml": "https://baselines.cirsec.org/b/ubuntu/CB-UBU-DESK-009.yml",
  "profiles_effective": [
    "desktop",
    "desktop-hardened"
  ],
  "license": "Text CC BY 4.0, code Apache-2.0",
  "attribution": "CIRSEC Baselines, https://baselines.cirsec.org",
  "control": {
    "id": "CB-UBU-DESK-009",
    "title": "Lock the session when the screen saver starts and when the system suspends",
    "finding": {
      "title": "Users can turn off the screen lock, including on suspend and lid close",
      "description": "A laptop closed or suspended with an unlocked session resumes straight into that session for whoever opens it."
    },
    "status": "active",
    "profiles": [
      "desktop"
    ],
    "risk": {
      "severity": "medium"
    },
    "assessment": "automated",
    "tags": [
      "gnome",
      "kde",
      "dconf",
      "session-lock",
      "suspend"
    ],
    "description": "- GNOME locks the screen when it blanks and before the system suspends (lid close, suspend\n  key, idle suspend) when `org.gnome.desktop.screensaver lock-enabled` is `true`, and lets\n  users lock at all when `org.gnome.desktop.lockdown disable-lock-screen` is `false`. Both\n  keys are set in the system dconf database `local` and locked.\n- KDE Plasma locks on resume when `LockOnResume` is not false in the `[Daemon]` group of\n  `kscreenlockerrc`; the system file `/etc/xdg/kscreenlockerrc` must mark the group\n  immutable (`[Daemon][$i]`).\n",
    "rationale": "Mobile machines are mostly left suspended, not idle. If the session is not locked at suspend,\nanyone who gets the laptop resumes into the user's open session, without a password, and the\nidle lock never triggers.\n",
    "impact": "Users type their password after resume. They cannot disable the screen lock.\n",
    "notes": "These are Ubuntu's defaults on every version, but users can change them unless the keys are\nlocked. With Xfce, check by hand that `xfce4-power-manager` locks the screen on suspend (setting\n`lock-screen-suspend-hibernate`). The KDE check was written from the KDE documentation and\nnot tested in a lab; it has no automated fix.\n",
    "setting": {
      "location": "/etc/dconf/db/local.d/ (GNOME); /etc/xdg/kscreenlockerrc (KDE)",
      "default_value": "Lock enabled, not locked",
      "recommended_value": "lock-enabled=true and disable-lock-screen=false, locked; KDE [Daemon][$i] LockOnResume=true"
    },
    "audit": {
      "manual": "1. GNOME: `dconf read /org/gnome/desktop/screensaver/lock-enabled` must print `true` and\n   `dconf read /org/gnome/desktop/lockdown/disable-lock-screen` must print `false`; both keys\n   must be listed in `/etc/dconf/db/local.d/locks/`.\n2. KDE Plasma: `/etc/xdg/kscreenlockerrc` must have a `[Daemon][$i]` group that does not set\n   `LockOnResume=false`.\n",
      "checks": [
        {
          "id": "gnome-lock-enabled",
          "engine": "dconf",
          "description": "GNOME locks the screen when it blanks and before suspend.",
          "facts": [
            "desktop-gnome"
          ],
          "spec": {
            "key": "/org/gnome/desktop/screensaver/lock-enabled",
            "value": "true"
          }
        },
        {
          "id": "gnome-lock-allowed",
          "engine": "dconf",
          "description": "GNOME users cannot disable the lock screen.",
          "facts": [
            "desktop-gnome"
          ],
          "spec": {
            "key": "/org/gnome/desktop/lockdown/disable-lock-screen",
            "value": "false"
          }
        },
        {
          "id": "kde",
          "engine": "shell",
          "description": "The KDE screen locker locks on resume and users cannot change it.",
          "facts": [
            "desktop-kde"
          ],
          "spec": {
            "script": "f=/etc/xdg/kscreenlockerrc\n[ -f \"$f\" ] || { echo \"$f missing\"; exit 1; }\no=$(awk '/^[ \\t]*\\[/ { s = ($0 ~ /^[ \\t]*\\[Daemon\\]\\[\\$i\\][ \\t]*$/); if (s) imm = 1; next }\n  s && /^[ \\t]*LockOnResume[ \\t]*=/ { v = $0; sub(/^[^=]*=[ \\t]*/, \"\", v) }\n  END { printf \"immutable=%d LockOnResume=%s\\n\", imm, v }' \"$f\")\necho \"$o\"\ncase $o in *immutable=1*) ;; *) exit 1 ;; esac\ncase $o in *LockOnResume=false*) exit 1 ;; esac\n"
          }
        }
      ]
    },
    "remediation": {
      "manual": "1. GNOME: make sure `/etc/dconf/profile/user` contains `user-db:user` and `system-db:local`,\n   then create `/etc/dconf/db/local.d/00-lock-screen`:\n   ```\n   [org/gnome/desktop/screensaver]\n   lock-enabled=true\n\n   [org/gnome/desktop/lockdown]\n   disable-lock-screen=false\n   ```\n   list both keys in `/etc/dconf/db/local.d/locks/00-lock-screen` and run `dconf update`.\n2. KDE Plasma: add `LockOnResume=true` to the `[Daemon][$i]` group of\n   `/etc/xdg/kscreenlockerrc` (see CB-UBU-DESK-008).\n",
      "effects": {
        "restart": "session",
        "disruption": "low",
        "lockout_risk": false
      },
      "rollback": "Delete the files written in `/etc/dconf/db/local.d/` and its `locks/` directory, then run\n`dconf update`.\n",
      "scripts": [
        {
          "id": "gnome-lock-enabled",
          "from_check": "gnome-lock-enabled"
        },
        {
          "id": "gnome-lock-allowed",
          "from_check": "gnome-lock-allowed"
        }
      ]
    },
    "references": [
      {
        "title": "GNOME System Administration Guide - Lock the screen when the user is idle",
        "url": "https://help.gnome.org/admin/system-admin-guide/stable/desktop-lockscreen.html.en",
        "publisher": "The GNOME Project",
        "kind": "vendor-doc",
        "accessed": "2026-10-19"
      },
      {
        "title": "gsettings-desktop-schemas - org.gnome.desktop.screensaver schema",
        "url": "https://gitlab.gnome.org/GNOME/gsettings-desktop-schemas/-/blob/master/schemas/org.gnome.desktop.screensaver.gschema.xml.in",
        "publisher": "The GNOME Project",
        "kind": "vendor-doc",
        "accessed": "2026-10-19"
      },
      {
        "title": "kscreenlocker - kscreenlockerrc settings (kscreenlockersettings.kcfg)",
        "url": "https://invent.kde.org/plasma/kscreenlocker/-/blob/master/settings/kscreenlockersettings.kcfg",
        "publisher": "KDE",
        "kind": "vendor-doc",
        "accessed": "2026-10-19"
      },
      {
        "title": "ANSSI-BP-028 v2.0 - Recommandations de configuration d'un système GNU/Linux (R32)",
        "url": "https://messervices.cyber.gouv.fr/documents-guides/fr_np_linux_configuration-v2.0.pdf",
        "publisher": "ANSSI",
        "kind": "guide",
        "accessed": "2026-10-19"
      }
    ],
    "mappings": [
      {
        "framework": "anssi-linux",
        "framework_version": "2.0",
        "id": "R32",
        "relation": "partial",
        "note": "Covers locking at suspend; the idle delay is CB-UBU-DESK-003 and CB-UBU-DESK-008."
      },
      {
        "framework": "nist-800-53r5",
        "framework_version": "5.1.1",
        "id": "AC-11",
        "relation": "partial"
      }
    ],
    "threats": [
      {
        "framework": "cwe",
        "id": "CWE-613"
      }
    ],
    "related_controls": [
      {
        "id": "CB-UBU-DESK-003",
        "type": "related"
      },
      {
        "id": "CB-UBU-DESK-008",
        "type": "related"
      }
    ],
    "authors": [
      {
        "name": "Alice",
        "github": "Sn0wAlice"
      }
    ],
    "verified": [
      {
        "date": "2026-10-19",
        "by": "Sn0wAlice",
        "versions": [
          "20.04"
        ],
        "environment": "Proxmox VM with Ubuntu Desktop (GNOME 3.36, gdm3), Ubuntu 20.04.6, kernel 5.4.0-216-generic",
        "notes": "Generated dconf check and fix (desktop-hardened); value and lock confirmed with gsettings get/writable as a user under dbus-run-session (write refused); second remediation reported compliant; state kept after reboot. The KDE check was not tested (no KDE machine)."
      },
      {
        "date": "2026-10-19",
        "by": "Sn0wAlice",
        "versions": [
          "22.04"
        ],
        "environment": "Proxmox VM with Ubuntu Desktop (GNOME 42, gdm3), Ubuntu 22.04.5, kernel 5.15.0-198-generic",
        "notes": "Generated dconf check and fix (desktop-hardened); value and lock confirmed with gsettings get/writable as a user under dbus-run-session (write refused); second remediation reported compliant; state kept after reboot. The KDE check was not tested (no KDE machine)."
      },
      {
        "date": "2026-10-19",
        "by": "Sn0wAlice",
        "versions": [
          "24.04"
        ],
        "environment": "Proxmox VM with Ubuntu Desktop (GNOME 46, gdm3), Ubuntu 24.04.5, kernel 6.8.0-147-generic",
        "notes": "Generated dconf check and fix (desktop-hardened); value and lock confirmed with gsettings get/writable as a user under dbus-run-session (write refused); second remediation reported compliant; state kept after reboot. The KDE check was not tested (no KDE machine)."
      },
      {
        "date": "2026-10-19",
        "by": "Sn0wAlice",
        "versions": [
          "26.04"
        ],
        "environment": "Proxmox VM with Ubuntu Desktop (GNOME 50, gdm3), Ubuntu 26.04.1, kernel 7.0.0-38-generic",
        "notes": "Generated dconf check and fix (desktop-hardened); value and lock confirmed with gsettings get/writable as a user under dbus-run-session (write refused); second remediation reported compliant; state kept after reboot. The KDE check was not tested (no KDE machine)."
      }
    ],
    "introduced_in": "0.1.0",
    "created": "2026-10-19",
    "updated": "2026-10-19"
  }
}