Kiosk Hardening
Everything that stands between a curious user and a shell. Each layer assumes the others may fail, which is why there are so many of them.
Layer 1 — Immutable storage
Keyboard and mouse
Three layers, because each one only catches what the layer below it let through.
- Openbox binds nothing.
rc.xmlhas an empty<keyboard>section and aRootmouse context with no menu, and it is installed to~/.config/openbox/rc.xmland/etc/xdg/openbox/rc.xml— the two pathsopenbox-sessionactually reads. Shipping it to/etc/openbox/rc.xmlalone left Alt+Tab, Alt+F4, Super+E and the right-click desktop menu working on every installed machine. - The keys are taken off the keyboard.
labkiosk-lock-keysrewrites the X keymap at session start so every F key, both Super keys, the menu key, Print Screen, Pause, Scroll Lock, Insert and theXF86media block carry no symbol at all. Nothing can bind a key that produces nothing — not even Chromium's built-in accelerators. Re-run it after any keyboard-layout change. - The extension refuses the rest. Every Ctrl/Alt/Meta combination, every non-printable key outside Backspace, Delete, Enter, Shift, Caps Lock, Tab, Escape and the cursor/page keys, and the context menu, are blocked in the capture phase, in every frame.
The single exception is the clipboard (Ctrl+A/C/V/X/Z/Y) on the setup wizard's own loopback origin, so an administrator can paste the enrolment key. No page a user can reach has that origin.
Ctrl+P stays blocked as well. While an organization allows printing, the extension prints the page itself when it sees one (Browser Extension); Chromium's own shortcut never runs.
/etc/overlayroot.conf:
overlayroot="tmpfs:recurse=0"
recurse=0 has to be part of the value. overlayroot reads only the overlayroot and overlayroot_cfgdisk variables from this file, so a separate overlayroot_options= line does nothing and leaves recurse at its default of 1 — which overlays every fstab entry with a RAM upper layer, LABKIOSK_DATA included, and quietly loses every enrolment at reboot.
The real root filesystem is mounted read-only, with a tmpfs overlay on top. Every write — browser cache, agent logs, downloads, user files, session state — lands in RAM and is gone at power-off.
This holds on live media and on installed disks. An installed disk boots the very same filesystem.squashfs the ISO carries, copied into its image store, through live-boot with the same overlay. Two consequences follow:
- Zero flash wear. Thin-client SSDs as small as 12 GB with limited write cycles are never written to during operation.
- Every boot is a clean boot. Nothing a user does survives a reboot, so there is no persistence for malware, no accumulated profile corruption, and no stale configuration.
The single exception on an installed disk is /etc/labkiosk, mounted from the LABKIOSK_DATA partition so that an enrolment survives. → Disk Installer
toram is opt-in
auto/config's --bootappend-live contains no toram. The default entry boots with overlayroot=tmpfs and reads the squashfs from the medium as it goes. The boot menu additionally offers Lab Kiosk OS (Load into RAM - toram), which copies the whole image into RAM first — pick that when the USB stick should be removable after boot, and expect it to need more RAM than the image size.
Layer 2 — No route to a shell
| Control | Where | Effect |
|---|---|---|
root locked | passwd -l root | No root login by any path |
getty@tty1..6 masked | systemctl mask | Ctrl+Alt+F1…F6 reaches nothing |
serial-getty@ masked | systemctl mask | No serial console login |
debug-shell.service masked | systemctl mask | No systemd emergency shell |
DontVTSwitch "true" | /etc/X11/xorg.conf.d/10-kiosk-lockdown.conf | X refuses VT switching |
DontZap "true" | same file | Ctrl+Alt+Backspace cannot kill X |
Empty rc.xml keybindings | /etc/openbox/rc.xml | Alt+Tab, Alt+F4, Ctrl+Alt+Del are inert |
| No SSH server | package list | Nothing listens for remote login |
kiosk not in the tty group | 01-lockdown.hook.chroot (gpasswd -d if present) | A browser escape cannot write to every terminal |
Why the kiosk account has an empty password, not a locked one
passwd -d "$KIOSK_USER" is deliberate and must stay. A locked kiosk account previously deadlocked the display manager's PAM stack (nodm's, before labkiosk-session) into a black screen on boot.
What makes an empty password safe here is that no login path exists to use it: labkiosk-session.service is pinned to User=kiosk and its PAM stack checks no password, every getty is masked, and no SSH server is installed. There is no prompt anywhere that would accept it.
kiosk holds two narrow sudo grants — NOPASSWD on /usr/local/bin/labkiosk-install (/etc/sudoers.d/50-labkiosk-install), which is what lets the setup wizard run the guided installer, and on /usr/local/sbin/labkiosk-localization (/etc/sudoers.d/51-labkiosk-localization) for language and region. There is no general sudo access: live-config's sudo and policykit components, which would otherwise grant the live user NOPASSWD: ALL and every polkit action at every boot, are pre-seeded away — on the ISO and on installed disks, which boot through live-boot too. labkiosk-boot-slots, which chooses the image an installed disk boots, has no sudo rule at all.
The session runs without root
There is no display manager. labkiosk-session.service (User=kiosk, Alias=display-manager.service, wanted by graphical.target, the default target) runs xinit /home/kiosk/.xsession -- /usr/bin/Xorg :0 vt7 -keeptty -novtswitch -nolisten tcp on tty7 and starts it again whenever it ends. Its PAM stack, /etc/pam.d/labkiosk-session, is pam_permit for auth and account, pam_deny for password, and pam_systemd.so class=user type=x11 for session: that registers a logind session, which is what hands the kiosk user the seat's graphics card and input devices.
/etc/X11/Xwrapper.config is allowed_users=console and needs_root_rights=auto, and Xorg.wrap stays setuid. So X runs **as kiosk** wherever the GPU has a kernel modesetting driver (Intel, AMD, nouveau, QEMU, Hyper-V's DRM driver), and as root only on graphics without one, such as plain VESA (and Hyper-V while hyperv_fb is the driver loaded). Only a process on a virtual console may start it at all.
Polkit: the kiosk user's rights, and nothing else
/etc/polkit-1/rules.d/50-labkiosk-power.rules grants kiosk reboot and power-off through logind. That grant is what makes the operator's remote shutdown command work: the agent runs as kiosk, so without it the command would be accepted and then silently do nothing. The other 50-* rules grant NetworkManager and the update units.
99-labkiosk-deny.rules answers no for kiosk on every other action. As the active logind session on its seat, the kiosk user would otherwise get polkit's desktop defaults — setting the time zone, the hostname, mounting disks. The one exception is org.freedesktop.login1.inhibit-* (left to the defaults), so a page can still keep the screen on during a video.
Never asleep
A workstation is on, or it powers off or restarts. It boots in well under a minute, and a sleeping kiosk is one nobody can reach from the console. logind.conf.d/labkiosk.conf makes the power button power off cleanly and ignores the sleep and hibernate keys, the lid (a laptop used as a kiosk keeps running with its lid shut) and idleness; sleep.conf.d/labkiosk.conf refuses every kind of sleep; and sleep.target, suspend.target, hibernate.target, hybrid-sleep.target and suspend-then-hibernate.target are masked.
Layer 3 — Kernel hardening
/etc/sysctl.d/99-kiosk-lockdown.conf:
kernel.sysrq = 0 # No magic SysRq key
kernel.dmesg_restrict = 1 # Unprivileged users cannot read the kernel ring buffer
kernel.kptr_restrict = 2 # Kernel pointers hidden from everyone
fs.protected_hardlinks = 1
fs.protected_symlinks = 1
fs.protected_fifos = 2
fs.protected_regular = 2
fs.suid_dumpable = 0
Core dumps are disabled outright in /etc/security/limits.conf (* hard core 0, * soft core 0).
Firewall
/etc/nftables.conf is table inet labkiosk_firewall, loaded by nftables.service (enabled by 01-lockdown.hook.chroot, which refuses to build if /etc/nftables.conf is not this file). Nothing on a workstation answers the network — the agent and x11vnc listen on 127.0.0.1, Remote Control is a connection the agent opens outward — and the firewall keeps it that way if a package or a bug ever starts a listener. Input and forward policy is drop; what is let in:
- loopback, and replies to connections the workstation opened (established/related);
- DHCP replies (UDP 67 → 68) and DHCPv6 replies from link-local addresses (547 → 546);
- ping, IPv4 and IPv6, limited to 5 per second;
- IPv6 neighbour discovery, router adverts, multicast listener queries and packet-too-big;
- TCP 8890 from private IPv4 ranges, for sharing a system update on the LAN —
labkiosk-share.nftstill adds its own table while a release is shared.
Outgoing traffic is not filtered; which sites a user may open is the browser policy's job. The file never says flush ruleset, so a reload keeps the sharing table.
AppArmor, in complain mode
labkiosk-apparmor.service loads two profiles (Debian's own apparmor.service skips live systems, and the kiosk always runs from live-boot's overlay; the profiles other packages ship stay unloaded): labkiosk-agent (attached to /opt/labkiosk/agent/agent.py) and labkiosk-x11vnc (attached to /usr/bin/x11vnc). Both are in complain mode: they block nothing, and what they would block is logged by the kernel to the journal (kept on LABKIOSK_DATA on an installed disk) and printed by the VM boot test. The session runs the agent as /opt/labkiosk/agent/agent.py itself, not python3 agent.py, because AppArmor attaches a profile to the path that was executed. sudo is unconfined from the agent's profile (Ux): root's helpers re-validate their arguments. Chromium has no profile; its own sandbox stays its main protection.
Layer 4 — Chromium managed policy
The browser runs --kiosk with a wiped profile on every launch, under an enterprise policy at /etc/chromium/policies/managed/policies.json.
Deny-all, then re-permit
"URLBlocklist": [
"chrome://*", "edge://*", "about:flags", "about:version",
"javascript://*", "view-source:*", "file://*",
"http://*", "https://*"
]
Everything is denied, and the organization's URLAllowlist re-permits exactly its own domains plus its portal apps. view-source: is listed explicitly because DeveloperToolsAvailability does not cover it and the http/https entries do not match it.
The rest of the static policy
| Key | Value | Why |
|---|---|---|
DeveloperToolsAvailability | 2 | DevTools disabled entirely |
IncognitoModeAvailability | 1 | Incognito disabled |
DownloadRestrictions | 3 | All downloads blocked |
AllowFileSelectionDialogs | false | Without this an upload control still opens a filesystem browser over the kiosk — a file manager a user otherwise has no route to |
PrintingEnabled | false | |
PasswordManagerEnabled, AutofillAddressEnabled, AutofillCreditCardEnabled | false | Nothing is retained between users |
BrowserSignin | 0 | No Google sign-in |
SyncDisabled | true | |
DefaultSearchProviderEnabled | false | An allowlisted kiosk has nowhere to search to |
DefaultGeolocationSetting, DefaultNotificationsSetting | 2 | Deny without prompting — a kiosk has nobody to answer a permission prompt, and a modal would sit above the lock curtain |
HardwareAccelerationModeEnabled | true | Thin clients need it |
Audio and video capture are deliberately *not* blocked. Language labs and video pages legitimately need the microphone and camera; taking them away breaks real room use.
Printing
PrintingEnabled: false is in the base, and the agent never writes it otherwise. When an organization turns printing on, the root helper labkiosk-printing adds zz-labkiosk-printing.json beside policies.json, with PrintingEnabled: true: Chromium merges the directory's files in name order, the last winning, and reloads them about five seconds after a change. Turning printing off removes the file. Whether printing is on or off, PrinterTypeDenyList: ["pdf", "extension"] keeps "Save as PDF" and extension printers out of the print preview, and /etc/xdg/gtk-3.0/settings.ini (and gtk-4.0) gives GTK's system dialog the CUPS backend only, so it has no "Print to File". → Client Agent
One home for the policy
The static policy is declared exactly once, in usr/share/labkiosk/chromium-policy-base.json. Two consumers generate from it — the build hook 01-lockdown.hook.chroot, and sync_chromium_policies() in agent.py — and neither may carry its own copy of those keys. When the keys were declared twice, anything added to one and not the other silently vanished the moment a workstation enrolled.
# CI asserts the committed generated file matches its base
python3 distro-builder/tools/generate-chromium-policy.py --check
Never hand-edit the generated etc/chromium/policies/managed/policies.json.
Never add a blanket extension block
ExtensionInstallBlocklist: ["*"] makes Chromium refuse --load-extension altogether — silently removing the kiosk's own navigation bar and lock curtain. → Browser Extension
Layer 5 — In-page controls
The MV3 extension traps F12, Ctrl+Shift+I/J/C, Ctrl+U, F11, and right-click, and while the lock curtain is up it swallows every mouse, keyboard, and touch event in the capture phase. Its UI lives in a closed Shadow DOM so page script cannot reach it.
Securing the boot chain
All of the above assumes an untampered kernel invocation. Someone with physical access who can edit the GRUB command line and append init=/bin/sh bypasses every layer at once.
The boot-menu password
A workstation always boots completely unattended. Every menu entry is marked --unrestricted — applied unconditionally by 02-security.hook.chroot, and written into every entry of the installed disk's boot menu (usr/share/labkiosk/boot/grub.cfg, a test checks it) — so powering on goes straight to the kiosk with no prompt. The password is asked for only when someone presses e to edit an entry, or c for the GRUB shell.
Do not commit a hash for an image you ship to more than one customer. A hash compiled into the ISO is one boot-menu password shared by every deployment that image produced: a leak at any single site compromises all of them, it cannot be rotated on machines already in the field, and
grub.pinis tracked in git, so the hash is permanent in history and open to offline cracking by anyone who can read the repository.
Route 1 — per installation (the default)
The setup wizard collects the password at install time and derives the PBKDF2 digest in the browser. Each site, or each workstation, gets its own password, and the shipped ISO carries no secret at all. → Disk Installer
Route 2 — per-customer ISO
Supply the hash in the build environment rather than committing it. This also locks the live USB menu:
docker run --rm -it ghcr.io/akbhoi/labkiosk-iso-builder grub-mkpasswd-pbkdf2 -c 200000
docker run --privileged --rm \
-e LABKIOSK_GRUB_PBKDF2="grub.pbkdf2.sha512.200000.YOUR.HASH" \
-v "$PWD/distro-builder/out:/build/out" \
ghcr.io/akbhoi/labkiosk-iso-builder
LABKIOSK_GRUB_PBKDF2 takes precedence over grub.pin, which remains as a fallback for a single organisation building an image for its own lab.
Where each mechanism applies
| Target | Mechanism | Set by |
|---|---|---|
| Installed disk | boot/grub/labkiosk-password.cfg on LABKIOSK_ROOT, outside every system image so updates keep it, sourced by the installed grub.cfg | The wizard, per installation (Route 1) |
| Live ISO, UEFI | config/bootloaders/grub-pc/labkiosk-password.cfg, sourced by config.cfg | auto/config from LABKIOSK_GRUB_PBKDF2 or grub.pin (Route 2) |
| Live ISO, legacy BIOS | ALLOWOPTIONS 0 + NOESCAPE 1 in config/bootloaders/*/stdmenu.cfg — no password needed, syslinux discards any kernel argument typed at the prompt | static config, always |
With no hash supplied the build prints a note and produces an editable live menu — the correct default for a shipped product, because installed workstations get their password from Route 1. If a hash is supplied but is not a grub.pbkdf2.sha512. value, the build fails rather than shipping an image whose menu is unprotected in a way nobody noticed.
Other boot-chain settings
GRUB_TIMEOUT=3
GRUB_CMDLINE_LINUX_DEFAULT="consoleblank=0"
GRUB_DISABLE_RECOVERY="true"
The installed disk's boot menu is the static usr/share/labkiosk/boot/grub.cfg rather than one generated from these settings, and it matches them: timeout=3, consoleblank=0 on every kernel line, and no recovery entry. Recovery mode is a root shell by design and has no place on a kiosk. consoleblank=0 — rather than quiet loglevel=3 — is what resolved the black-screen boot deadlock; suppressing boot logs made a PAM autologin failure invisible.
Secure Boot
The ISO and the installed disk boot through Microsoft's signed shim, Debian's signed GRUB and Debian's signed kernel, so they start with Secure Boot on, with the keys every PC ships with. With Secure Boot on, the firmware refuses a boot loader or kernel that is not signed, and the kernel runs in lockdown mode (no unsigned modules, no /dev/mem). Kernel modules outside Debian (the proprietary NVIDIA driver, for one) are deliberately not in the image: they would need a key enrolled by hand at the keyboard on every machine.
To turn it on and check it on a workstation:
- In the firmware setup (usually F2, F10, F12 or Del at power-on): set the boot mode to UEFI (not Legacy/CSM), set Secure Boot to Enabled, and if it offers key modes choose Standard or Factory/Microsoft keys (on some machines, "Install default Secure Boot keys"). Set a firmware password while you are there.
- Do this before installing. On a machine with a TPM the data partition's key is sealed to the Secure Boot state; turning it on afterwards resets the data partition and the workstation must be enrolled again (Disk Installer).
- Boot the ISO or the installed disk. If Secure Boot is on and the machine starts the kiosk, the signed chain was accepted; a machine that refuses it shows a firmware "Security violation" message instead.
- Open the setup wizard and Agent Log & Diagnostics: the line under the heading says
Secure Boot: On, with the workstation's hostname.Offmeans the firmware did not enforce it this boot;Off (started in legacy BIOS mode)means the machine did not start through UEFI. - The agent log on the same screen has the line
Hostname …; Secure Boot on.from the agent's start. - On a machine with any Linux shell (the simulator, or a Debian live USB on the same machine):
mokutil --sb-stateprintsSecureBoot enabled, andjournalctl -k | grep -i "secure boot"showsSecure boot enabled.
The VM boot test (distro-builder/tests/vm/boot-test.sh) boots every scenario under Secure Boot firmware with Microsoft's keys and fails unless the kernel reports Secure boot enabled.
BIOS / UEFI firmware
Software cannot defend against someone who can simply boot something else. After installing:
- Set a strong Supervisor/Administrator password in the workstation firmware.
- Set internal storage as the sole boot target.
- Disable the boot-device menu (F12) and USB booting.
Build pins fail closed
usr/share/labkiosk/grub.pin holds a value that cannot be verified from the repository — a password hash.
| Pin | Unset | Wrong |
|---|---|---|
grub.pin | Builds with a loud warning, live menu editable | Build fails |
Never invent a value to make a build go green.
What this does not defend against
Stated plainly, because a hardening page that claims completeness is worse than useless:
- Physical disassembly. On a machine with a TPM 2.0 chip the data partition is encrypted and opens only in that machine, so a drive taken out shows nothing but the system image, which is public. Without a TPM anyone who can remove the drive can read it. Either way, a whole stolen machine still boots and unlocks itself, and the enrolment token can be revoked from the dashboard in one click.
- A network-level attacker. The client trusts its control plane. HTTPS and the device token protect the channel; a compromised control plane can point the kiosk anywhere the allowlist permits.
- A stolen administrator session. Remote Control is protected by the console's sign-in as an administrator of the organization and a one-time session token, not by the 8-character RFB secret. Whoever holds an administrator's session can open a live desktop; other staff cannot. → Remote Control