{
  "id": "CB-UBU-AUTH-020",
  "standard": "ubuntu",
  "version": "0.1.0",
  "url": "https://baselines.cirsec.org/b/ubuntu/v0.1.0/CB-UBU-AUTH-020",
  "json": "https://baselines.cirsec.org/b/ubuntu/v0.1.0/CB-UBU-AUTH-020.json",
  "yaml": "https://baselines.cirsec.org/b/ubuntu/v0.1.0/CB-UBU-AUTH-020.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-AUTH-020",
    "title": "Close idle shell sessions automatically",
    "finding": {
      "title": "Idle shell sessions stay open forever",
      "description": "A forgotten terminal, often with a root shell, can be used by anyone who reaches it."
    },
    "status": "active",
    "profiles": [
      "core"
    ],
    "risk": {
      "severity": "low"
    },
    "assessment": "automated",
    "tags": [
      "accounts",
      "session",
      "timeout"
    ],
    "description": "When the read-only `TMOUT` variable is set, bash and dash close an interactive shell that\nwaited that many seconds for input. Setting it in `/etc/profile.d/` applies it to the login\nshells of every user, and `readonly` stops users from removing it.\n",
    "rationale": "Open terminals left on a console, in a jump host session or in a forgotten SSH connection are\nan easy way to reuse someone's access, sometimes with root privileges.\n",
    "impact": "Idle interactive shells exit after {{ tmout }} seconds. Long-running commands are not\naffected, but a shell waiting at the prompt is closed: use `tmux` or `screen` for sessions\nthat must stay open.\n",
    "setting": {
      "location": "/etc/profile.d/60-cirsec-tmout.sh",
      "default_value": "Not set",
      "recommended_value": "TMOUT={{ tmout }}, readonly"
    },
    "parameters": [
      {
        "name": "tmout",
        "type": "integer",
        "description": "Idle time before an interactive shell exits.",
        "unit": "seconds",
        "default": 900,
        "profile_defaults": {
          "server-hardened": 600,
          "desktop-hardened": 600
        },
        "minimum": 60,
        "maximum": 3600
      }
    ],
    "audit": {
      "manual": "Run `su -s /bin/sh -l nobody -c 'echo $TMOUT'`. It must print a value between 1 and {{ tmout }}.\n",
      "checks": [
        {
          "id": "login-shell",
          "engine": "shell",
          "description": "TMOUT in a login shell.",
          "spec": {
            "script": "t=$(su -s /bin/sh -l nobody -c 'printf %s \"${TMOUT:-}\"' 2>/dev/null) || exit 3\necho \"TMOUT=${t:-unset}\"\n[ -n \"$t\" ] && [ \"$t\" -ge 1 ] && [ \"$t\" -le \"$CB_TMOUT\" ]\n"
          }
        }
      ]
    },
    "remediation": {
      "manual": "Create `/etc/profile.d/60-cirsec-tmout.sh`:\n```\nTMOUT={{ tmout }}\nreadonly TMOUT\nexport TMOUT\n```\n",
      "effects": {
        "restart": "session",
        "disruption": "low",
        "lockout_risk": false
      },
      "rollback": "Delete `/etc/profile.d/60-cirsec-tmout.sh`.\n",
      "scripts": [
        {
          "id": "profile",
          "engine": "shell",
          "content": "f=/etc/profile.d/60-cirsec-tmout.sh\ncb_backup \"$f\"\nprintf '%s\\n' '# Written by CIRSEC Baselines CB-UBU-AUTH-020' \"TMOUT=$CB_TMOUT\" 'readonly TMOUT' 'export TMOUT' >\"$f\"\nchmod 644 \"$f\"\n"
        }
      ]
    },
    "references": [
      {
        "title": "bash(1), Ubuntu manual pages (TMOUT)",
        "url": "https://manpages.ubuntu.com/manpages/noble/man1/bash.1.html",
        "publisher": "Canonical",
        "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": "equivalent"
      },
      {
        "framework": "nist-800-53r5",
        "framework_version": "5.1.1",
        "id": "AC-12",
        "relation": "equivalent"
      }
    ],
    "threats": [
      {
        "framework": "mitre-attack",
        "id": "T1078"
      }
    ],
    "authors": [
      {
        "name": "Alice",
        "github": "Sn0wAlice"
      }
    ],
    "verified": [
      {
        "date": "2026-10-19",
        "by": "Sn0wAlice",
        "versions": [
          "20.04"
        ],
        "environment": "Proxmox VM, Ubuntu 20.04 cloud image, kernel 5.4.0-216-generic",
        "notes": "Fails on a fresh install; TMOUT 900 in core, 600 in server-hardened; kept after reboot."
      },
      {
        "date": "2026-10-19",
        "by": "Sn0wAlice",
        "versions": [
          "22.04"
        ],
        "environment": "Proxmox VM, Ubuntu 22.04 cloud image, kernel 5.15.0-198-generic",
        "notes": "Fails on a fresh install; TMOUT 900 in core, 600 in server-hardened; kept after reboot."
      },
      {
        "date": "2026-10-19",
        "by": "Sn0wAlice",
        "versions": [
          "24.04"
        ],
        "environment": "Proxmox VM, Ubuntu 24.04 cloud image, kernel 6.8.0-147-generic",
        "notes": "Fails on a fresh install; TMOUT 900 in core, 600 in server-hardened; kept after reboot."
      },
      {
        "date": "2026-10-19",
        "by": "Sn0wAlice",
        "versions": [
          "26.04"
        ],
        "environment": "Proxmox VM, Ubuntu 26.04 cloud image, kernel 7.0.0-38-generic",
        "notes": "Fails on a fresh install; TMOUT 900 in core, 600 in server-hardened; kept after reboot."
      }
    ],
    "introduced_in": "0.1.0",
    "created": "2026-10-19",
    "updated": "2026-10-19"
  }
}