Custom checks: com.limdm.customchecks¶
IT defines its own checks as a library item. They are reported, counted, excepted
(exclude), marked advisory, exported as evidence and trigger grace period, webhook and
automatic lock exactly like the built in checks. They have no automatic remediation.
{"checks": [
{"id": "custom.no_telnet", "title": "Telnet client is not installed", "severity": "medium", "level": 1,
"refs": {"bsi": ["SYS.2.3.A1"], "cis": ["Ensure telnet client is not installed"], "iso": ["A.8.19"]},
"package": {"name": "telnet", "state": "absent"}},
{"id": "custom.shadow_mode", "title": "/etc/shadow is not readable by others", "severity": "high", "level": 1,
"file": {"path": "/etc/shadow", "state": "present", "max_mode": "0640", "owner": "root"}},
{"id": "custom.no_uid0", "title": "Only root has UID 0", "severity": "critical", "level": 1,
"query": {"sql": "SELECT username FROM users WHERE uid = 0 AND username <> 'root'", "expect": "no_rows"}}
]}
| Field | Meaning |
|---|---|
id |
custom. followed by up to 56 lower case letters, digits, ., _ or - (starting with a letter or digit); use it in exclude, advisory and risk exceptions |
title |
one line, up to 200 characters, shown on the device and compliance pages |
severity |
low, medium, high or critical; reported with the result and in the evidence |
level |
1 or 2; the check runs when the compliance level is at least this |
refs |
free text framework references: bsi, cis, iso lists (one line, up to 200 characters each) |
An item holds at most 200 checks; an ID may appear once. Each check has exactly one test:
| Test | Fields | Passes when |
|---|---|---|
query |
sql, expect (rows, no_rows, compare), for compare column, op, value |
the osquery result has rows, has none, or has rows and column of every row satisfies op value |
file |
path (absolute), state (present, absent), for present files optional max_mode (octal), owner, group, contains, not_contains (RE2, per line) |
the file exists or not, its permission bits stay within max_mode (no setuid, setgid or sticky bit), owner and group match, a line matches contains, no line matches not_contains |
sysctl |
key, op, value |
the kernel parameter compares as given; a parameter the kernel does not have is na |
package |
name, state (installed, absent) |
the package is installed or not |
service |
name, state (active, inactive), optional enabled |
the unit is active or not and, when set, enabled or not |
Operators: eq, ne, contains, matches (RE2) compare text; lt, le, gt, ge
compare numbers (a value that is no number fails the check).
Custom checks never run a shell. The only program a check starts is osqueryi with the
query, for at most 30 seconds, with extensions disabled. Server (on save) and agent (before
running) both accept only one read only statement of at most 4096 characters: it must start
with SELECT or WITH and may not contain a second statement (a trailing semicolon is
fine), comments, control characters, characters outside ASCII (except inside 'string'
literals), INSERT, UPDATE, DELETE, REPLACE (the string function replace() is
allowed), ATTACH, DETACH, PRAGMA, load_extension, writefile or readfile.
The validator tokenizes the query like SQLite (quoted names "x", [x] and `x`,
schema qualified main.x) and checks every table after FROM, JOIN, a comma in a
FROM clause and IN against an allowlist of local tables:
apparmor_profiles, apt_sources, authorized_keys, block_devices,
cpu_info, crontab, deb_packages, disk_encryption, dns_resolvers, etc_hosts,
etc_protocols, etc_services, file, groups, hash, interface_addresses,
interface_details, iptables, kernel_info, kernel_modules, last,
listening_ports, logged_in_users, md_devices, memory_info, mounts,
npm_packages, os_version, osquery_info, pci_devices, platform_info,
portage_packages, process_open_sockets, processes, python_packages, routes,
rpm_packages, secureboot, selinux_settings, shadow, ssh_configs,
startup_items, sudoers, suid_bin, system_controls, system_info,
systemd_units, time, tpm_info, uptime, usb_devices, user_groups,
user_ssh_keys, users, yum_sources, plus the common table expressions of a leading
WITH. Tables that reach the network (curl, curl_certificate, cloud metadata,
prometheus_metrics), carve files, read process environments or read any file (augeas, whose lenses parse /etc/shadow too) are refused. The agent
also starts osqueryi with --enable_tables set to the same allowlist and
--disable_tables for the network and carving tables, so osquery itself does not offer
them. The result sent to the server holds only the row count and, for compare, the
compared value of the first failing row (at most 64 characters); rows are never sent.
Without osquery on the device a query check fails. Items of several
blueprints are merged by id; the item evaluated last wins.