61 lines
5.7 KiB
Markdown
61 lines
5.7 KiB
Markdown
# Spike — can a box refresh its security profiles by itself? — 2026-11-14 (release 2a, Part B)
|
|
|
|
**Answer: yes. The spike is clean, so the mode was built in the same run** (agent v0.174.0, `11-os-updates.md` §5.12).
|
|
Venue: demo-hp (Tier 0), host kernel 7.0.14-28-pve, guests 9201 (26 containers) and 9202 (6) running the whole time;
|
|
reads on Tester 1. Nothing on the N100 was touched. No package was changed. Documents read:
|
|
`audits/n100-clock-2026-11-11/README.md` (the diagnosis and its method), `architecture/11-os-updates.md` §5.4.1, §5.9,
|
|
§5.11, rows R-1388, R-1301.
|
|
|
|
## The six questions
|
|
|
|
| # | Question | Result | File |
|
|
|---|---|---|---|
|
|
| 1 | Does the detector (loaded hash against a fresh compile) work, and why does `lxc-containers` always "differ"? | It works for one-profile files. **`lxc-containers` compiles to a different binary every time** (two fresh compiles in a row differ; it includes a whole folder). So its hash can never judge it; the detector now compiles twice and says so. On demo-hp and Tester 1: 106 files, 0 stale, 1 not judgeable, 4.5 s | `evidence/01-detect-*.txt`, `tools/detect.sh` |
|
|
| 2 | Can one stale profile be made by the real mechanism, with no package change? | Yes. The old compiled chrony profile (of 4.6.1, sha `dbf67f16…`) was copied from the old kernel's cache folder into the running kernel's; its time (2026-08-21) is newer than the source's (2026-07-01). The system's own reload then **loaded the old one**, and a restart of chrony **failed exactly as on the N100** („Could not send notification to $NOTIFY_SOCKET", twice) | `evidence/02-make-stale.txt` |
|
|
| 3 | The smallest repair | `apparmor_parser --replace --skip-read-cache --write-cache -- /etc/apparmor.d` — **0.51 s**. After it: the same 119 profiles in the same modes; chrony's loaded profile and its cached copy are the fresh compile (`83417e83…`); both guests running, 26 and 6 containers, none restarted (newest start time unchanged), every guest init still confined by its own profile | `evidence/03-refresh.txt` |
|
|
| 3b | Why did 17 other profiles change their loaded hash? | Not staleness. For a file that defines several profiles the kernel's hash differs between a cache load and a fresh load of the **same** policy. **The only reliable sign of a stale copy is the cached FILE changing when it is rewritten** (here: only the planted one, and `lxc-containers`) | `evidence/03b-why-others-changed.txt` |
|
|
| 4 | What starts the failed program again? | The refresh does not (chrony stayed `failed`). The narrow rule, tried by hand: a **failed service** whose **ExecStart program is the path-name of a profile whose cached copy the refresh rewrote** → one `systemctl restart`. chrony came back, 0.0003 s off | `evidence/04-restart-rule.txt` |
|
|
| 5 | When should it run? | See the options below; the pick is „when the box runs another kernel than at the last refresh" | — |
|
|
| 6 | Can the guest have the same staleness? | Not today: in guest 9201 the AppArmor package is installed, its service is inactive, there is no profile cache, and the kernel's profile list is not visible | `evidence/06-guest-read.txt` |
|
|
|
|
**No new refusal by the kernel in 10 minutes** (`evidence/05-watch.txt`): 1 `DENIED` line, and it is the control.
|
|
**The control was needed** (`evidence/05a-denied-watch-control.txt`): the kernel rate-limits its audit lines, each
|
|
reload writes about 119 `STATUS` lines, and the `DENIED` line that the planted stale profile made at 10:58:07 UTC is
|
|
**not in the kernel log at all** („kauditd_printk_skb: 111 callbacks suppressed"). A count of 0 alone would have proved
|
|
nothing. The second channel is behaviour: no container restarted, no failed unit.
|
|
|
|
## Decision 4 — what restarts the program (two options)
|
|
|
|
| | Option A (picked) | Option B |
|
|
|---|---|---|
|
|
| Rule | a failed service whose own program's cached profile was stale | a fixed list: `chrony.service` |
|
|
| Covers | every program this fault can stop | the one case seen |
|
|
| Risk | a unit that failed for another reason, and whose profile was also stale, gets ONE start try | none beyond chrony |
|
|
| Cost | 3 `systemctl` reads per failed unit, only when a path-named profile was rewritten | a new release for each next program |
|
|
|
|
Never „restart whatever failed", never a unit named by the plan, at most 3 units a run.
|
|
|
|
## Decision 5 — when it runs (two options)
|
|
|
|
| | When the kernel differs from the last refresh's (picked) | After every agent start |
|
|
|---|---|---|
|
|
| Catches the fault | yes: a stale copy can only appear for a kernel that did NOT run when a profile changed, so the box always starts on „another kernel" before the kernel loads it. A box with no record yet counts as changed (this is what repairs the N100) | yes |
|
|
| Cost | one refresh per kernel change (about weekly) | one per agent start (about daily): 0.5 s, and each run floods the kernel log with ~119 lines and **hides other audit lines for a few seconds** (measured above) |
|
|
|
|
The record is the wrapper's own root-owned file; the agent asks at every start and after a bundle install, and the
|
|
wrapper answers „not needed".
|
|
|
|
## Put back
|
|
|
|
`evidence/07-put-back.txt`: the spike's files removed from `/root`; the planted copy is gone (the cache holds the fresh
|
|
compile, the old kernel's folder is untouched); one cache load (`systemctl reload apparmor`) put the loaded hashes
|
|
back as found; the detector reads 0 stale; chrony active; both guests running; no failed unit.
|
|
|
|
## Not measured
|
|
|
|
- A box that boots with `proxmox-boot-tool` or without AppArmor (none in the fleet).
|
|
- A profile in `complain` mode or in `/etc/apparmor.d/disable` (demo-hp has none; the parser is given the folder, as the
|
|
system's own loader is).
|
|
- The refresh while a backup or a restore-test runs (the agent takes the heavy-op gate so it never does).
|
|
- The real case: the N100. It is the proof of the built mode, in the release.
|