Skip to content

feat: keylogger and root session detection#7

Merged
suisuss merged 9 commits intomainfrom
feat/keylogger-root-detection
Apr 6, 2026
Merged

feat: keylogger and root session detection#7
suisuss merged 9 commits intomainfrom
feat/keylogger-root-detection

Conversation

@suisuss
Copy link
Copy Markdown
Owner

@suisuss suisuss commented Apr 6, 2026

Summary

  • spyproc: Scan all process fds for /dev/uinput to detect virtual input injection (keystroke interception via clone-and-grab). Allowlists legitimate input remappers (keyd, kanata, kmonad, xremap, etc).
  • users: Three complementary checks for active root sessions -- utmp/who (TTY/SSH logins), loginctl (systemd sessions including graphical seats), and /proc scan for UID 0 processes with a controlling terminal (catches su/sudo -i shells that don't create utmp entries). Decodes TTY device numbers to human-readable pts/N or ttyN.
  • PATROL.md / C2.md: Root sessions and /dev/uinput access added as high-priority patrol signals and C2 correlation patterns. New "Root Compromise" correlation pattern (no watch signal required).
  • THREATS.md: Coverage matrix updated with new entries.
  • Threatlab: Root shell test artifact (script(1) pty allocation) -- 35/35 tests pass.

Test plan

  • docker compose --profile test run --rm secy-test -- 35 passed, 0 failed, 5 skipped
  • Manual: run sread spyproc on host with keyd/kanata running -- verify allowlist suppresses false positives
  • Manual: run sread users after sudo -i -- verify root shell is detected with correct pts/N
  • Manual: run sread users normally -- verify no false positives on a clean system

suisuss added 9 commits April 2, 2026 13:22
Debian 12 bookworm, x86_64, GNOME desktop, systemd, Docker Compose v2.
Clarify this is for developer workstations, not headless servers.
Processes holding /dev/uinput fds can create virtual input devices to
inject keystrokes or clone-and-grab real keyboards for interception.
Scans all process fds for /dev/uinput with an allowlist for legitimate
input remappers (keyd, kanata, kmonad, xremap, etc).
Three complementary checks for root activity that should not normally
exist on a developer workstation:

- utmp/who: catches root logged in via TTY or SSH
- loginctl: catches root sessions on systemd (including graphical seats)
- /proc scan: catches UID 0 processes with a controlling terminal (root
  shells spawned via su/sudo -i that don't create utmp entries)

Decodes TTY device numbers to human-readable pts/ttyN names.
- PATROL.md: update users module description to include active root
  session checks, add root sessions and /dev/uinput access to
  high-priority change list
- C2.md: add /dev/uinput to credential theft correlation pattern,
  add active root session to privilege escalation pattern, add new
  root compromise correlation pattern (no watch signal required)
Add /dev/uinput reader detection (2.3a) under process-level hiding.
Add new section 10a for active root session detection covering utmp/who,
loginctl, and /proc UID 0 + TTY scanning.
Seed a root process with a controlling terminal (via script(1) pty
allocation) so sread users can detect UID 0 + TTY. Skip /dev/uinput
test as it requires the kernel device node.

All 35 tests pass, 0 failures.
grep -v returns exit 1 when no lines match (e.g. sudoers.d/README is
all comments). Under set -eo pipefail this kills the entire script
before the new active root session checks can run.
@suisuss suisuss merged commit 6d828e3 into main Apr 6, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant