Defense in depth: every application UI/API is meant to be a distinct identity at three layers (SELinux, Casdoor, Kubernetes). The container runtime and the network are confined to those identities. §3 says which parts are enforced and which are still the target.
All ten stage4 builders (RPi 5, which makes the three role images
pki/backend/frontend, the x86_64 host, Frite, Jetson and the six Orange Pi
boards) build from the hardened/selinux profile (specs-*/portage/profile/parent)
with SELinux as the LSM. AppArmor is disabled (disable CONFIG_SECURITY_APPARMOR in
the x86 and RPi 5 fragments). The stack is per arch and is what the kernel actually runs
(tests/scripts/test-lsm-posture-honesty.sh fails the build if an image advertises
a name its kernel did not compile in):
| Boards | CONFIG_LSM / lsm= |
lockdown= |
|---|---|---|
| x86, rpi5 | lockdown,yama,selinux,bpf |
integrity |
| the 8 ARM boards (La Frite, Jetson, Orange Pi Zero 2 / Zero 2W / Zero 3 / 3 LTS / 4 LTS / 5) | lockdown,yama,selinux |
integrity |
bpf is registered only on x86 and rpi5. Both fragments now ask for the BTF a
BPF_PROG_TYPE_LSM program needs to attach. Only the x86 configuration has been resolved
against a real kernel tree (rpi5 is enforced by its builder guard at build time), and no
image has been built or booted with it, so that an attach really succeeds is not yet
proven (see the README roadmap). Lockdown selects
CONFIG_MODULE_SIG, so modules built with the kernel are signed and an unsigned
out-of-tree .ko is refused at runtime on every board.
The module-signing private key never ships (x86 live ISO, fixed 2026-11-11). That
signature is only worth something while certs/signing_key.pem stays private. The x86
build system keeps its kernel tree in /usr/src (the stage4 tar has always excluded
it), and the live ISO used to squash the whole build system, key included. Anyone with
that ISO could sign a module that every kernel of the same build accepts under
lockdown=integrity. The live pack now excludes usr/src (live_squash_excludes, both
arms), and live_root_gate refuses a squashfs whose listing still names
signing_key.pem or a usr/src/linux*/certs/ dir, in both its listing arms
(unsquashfs, and rdsquashfs, whose paths have no leading slash). The name match
takes any signing_key*.pem* (a .pem.bak copy is the same key) and the basename of a
non-default CONFIG_MODULE_SIG_KEY. With neither lister on the host the gate refuses
instead of passing unchecked. The --bundle-source generator tree moved out of
/usr/src to /usr/share/hugmesh/generator-src so the whole-directory exclude does not
take it along. Live ISOs built
before the fix, and images whose kernel came from the same cache entry, share a key that
has to be treated as public. Rotating it means invalidating the x86 kernel cache and
rebuilding.
The bundled generator source is tracked files only (fixed 2026-11-12). A generator
checkout in use holds gitignored secrets: keys-out/ (cluster CA key, vault token,
keystore passwords, OIDC client secrets), tests/stack/.tls-front/ca.key,
.e2e-credentials, .stack-src/, local tool state, and with -w pointed inside the checkout
the Secure Boot key. --bundle-source used to tar the whole checkout minus .git and
out/, so all of that rode into every artifact built with the bundle. That meant the
live ISO on older builds, and every artifact once the bundle left /usr/src. The Studio
always asks for the bundle. The builder now stages only what git ls-files lists (or, in
a bundled tree without .git, the .hugmesh-bundle-files manifest the previous bundle
wrote). With neither, the build goes on without the bundle and warns. It never falls
back to tarring the tree. A sysroot reused from an earlier run loses any bundle it holds
when this build does not bundle. Tracked files shaped like a key or
credential are left out, and bundle_source_gate re-checks the staged tree and fails the
build on any key- or credential-shaped name or PEM private-key header. Images built with
--bundle-source from a checkout holding such files before this fix carry them, and
those secrets have to be rotated.
The x86 kernel's post-olddefconfig hardening asserts and its compile/install/UKI recipe
are two plain scripts, scripts/_x86-kernel-asserts.sh and
scripts/_x86-kernel-install.sh. The builder runs them in the chroot, and the Studio's
kernel reconfiguration runs the same two files, so an edited kernel passes exactly the
asserts a fresh build passes.
- Pi (cross-built): SELinux policy packages'
pkg_postinstruns the targetsemodule, which can't execute under aarch64 cross-emerge — sokeys-provisionloads the base policy + relabels the filesystem natively at first boot (provision_selinux()), starting permissive. - x86 (native): the base policy is already built in the image. The hugmesh
node-policy modules (§3) are still loaded at first boot by
provision_selinux(). - Mode/type are set from the KEYS manifest:
selinux.mode(defaultpermissive),selinux.type(defaultmcs). Every image boots permissive. Theselinux-enforce-gateservice that could flip a node to enforcing ships inert unless the image was built withHUGMESH_SELINUX_ENFORCE_GATE=1(docs/selinux-module-loading.md).
containerd runs with enable_selinux = true and selinux_category_range = 1024
(specs/etc/containerd/config.toml). Every pod is labelled container_t with a
unique MCS category pair, so pods are mutually isolated by SELinux. Kubernetes
refines this per workload through securityContext.seLinuxOptions, which gives
each application its own role/level.
Each app UI/API is meant to be one identity across SELinux, Casdoor and Kubernetes,
with a Vault-issued mTLS certificate. The SELinux level and ServiceAccount columns
are enforced: tests/scripts/test-cluster-manifest-integrity.sh
([mcs-documented], [workload-sa]) compares them with the manifests. The other two
columns are the design target; see the status note under the table.
| Application | k8s ServiceAccount | SELinux seLinuxOptions (level) |
Casdoor user / role (target) | mTLS cert name (.cluster.local is appended) |
|---|---|---|---|---|
hugmesh-pki-gateway |
sa-pki-gateway |
s0:c11 |
svc-pki-gateway / ROLE_GATEWAY |
hugmesh-pki-gateway.hugmesh-pki.svc |
hugmesh-be-gateway |
sa-be-gateway |
s0:c12 |
svc-be-gateway / ROLE_GATEWAY |
hugmesh-be-gateway.hugmesh-backend.svc |
hugmesh-fe-gateway |
sa-fe-gateway |
s0:c13 |
svc-fe-gateway / ROLE_GATEWAY |
hugmesh-fe-gateway.hugmesh-frontend.svc |
hugmesh-gateway-superadmin |
sa-gateway-superadmin |
s0:c17 |
svc-gateway-superadmin / ROLE_GATEWAY |
hugmesh-superadmin-gateway.hugmesh-pki.svc |
hugmesh-api (actions) |
sa-api |
s0:c22 |
svc-api / ROLE_API |
hugmesh-api.hugmesh-backend.svc |
admin-bff (api) |
sa-admin-bff |
s0:c23 |
svc-admin-bff / ROLE_ADMIN_API |
hugmesh-admin-bff-api.hugmesh-backend.svc |
admin-bff-db |
sa-admin-bff-db |
s0:c26 |
(DB) | (non-Java: PEM, no JKS) |
federation-api |
sa-federation |
s0:c24 |
svc-federation / ROLE_FEDERATION |
hugmesh-federation-api.hugmesh-backend.svc |
federation-db |
sa-federation-db |
s0:c25 |
(DB) | (non-Java: PEM, no JKS) |
mod-bff-api |
sa-mod-bff |
s0:c27 |
svc-mod-bff / ROLE_MOD_API |
hugmesh-mod-bff-api.hugmesh-backend.svc |
mod-bff-db |
sa-mod-bff-db |
s0:c28 |
(DB) | (non-Java: PEM, no JKS) |
user-bff-api |
sa-user-bff |
s0:c29 |
svc-user-bff / ROLE_USER_API |
hugmesh-user-bff-api.hugmesh-backend.svc |
user-bff-db |
sa-user-bff-db |
s0:c38 |
(DB) | (non-Java: PEM, no JKS) |
forum-bff-api |
sa-forum-bff |
s0:c53 |
svc-forum-bff / ROLE_FORUM_API |
hugmesh-forum-bff-api.hugmesh-backend.svc |
forum-bff-db |
sa-forum-bff-db |
s0:c52 |
(DB) | (non-Java: PEM, no JKS) |
wiki-bff-api |
sa-wiki-bff |
s0:c69 |
svc-wiki-bff / ROLE_WIKI_API |
hugmesh-wiki-bff-api.hugmesh-backend.svc |
wiki-bff-db |
sa-wiki-bff-db |
s0:c68 |
(DB) | (non-Java: PEM, no JKS) |
service-catalog-ui (superadmin Service Catalog console; tailnet-only) |
sa-service-catalog-ui |
s0:c49 |
svc-service-catalog-ui / ROLE_SUPERADMIN_UI |
— (no <app>-mtls ExternalSecret) |
service-catalog-builder (Kaniko build pods) |
(per-build) | s0:c54 |
(build pod) | (non-Java: no JKS) |
route-access |
sa-route-access |
s0:c15 |
(DB) | — |
forgejo (GitOps) |
sa-forgejo |
s0:c16 |
per-app svc user | — |
clickhouse (analytics) |
per-app SA | s0:c19 |
(DB) | — |
kafka (analytics) |
per-app SA | s0:c20 |
per-app svc user | — |
lan-dns (coredns) |
per-app SA | s0:c57 |
— | — |
cloudflared |
per-app SA | s0:c56 |
— | — |
casdoor |
per-app SA | s0:c21 |
(IdP) | (non-Java: PEM, no JKS) |
casdoor-pg |
per-app SA | s0:c14 |
(DB) | — |
signup-gate |
per-app SA | s0:c36 |
per-app svc user | — |
media-poisoner |
per-app SA | s0:c18 |
— | (non-Java: PEM, no JKS) |
egress-proxy |
per-app SA | s0:c37 |
— | — |
binhost |
per-app SA | s0:c60 |
— | — |
vault |
per-app SA | s0:c70 |
— | — |
anubis (PoW gate) |
per-app SA | s0:c62 |
— | — |
frontend (host web) |
per-app SA | s0:c40 |
— | — |
social-ui (host-web / matrix / mastodon / login) |
per-app SA | s0:c41 / s0:c42 / s0:c43 / s0:c44 |
per-app svc user | — |
remote-fragment |
per-app SA | s0:c45 |
— | — |
mod-ui |
per-app SA | s0:c46 |
— | — |
user-ui |
per-app SA | s0:c47 |
— | — |
api-docs |
per-app SA | s0:c48 |
— | — |
forum-ui |
per-app SA | s0:c58 |
— | — |
wiki-ui |
per-app SA | s0:c71 |
— | — |
observability (postgres / uptrace) |
per-app SA | s0:c59 / s0:c61 |
— | — |
| akkoma (mastodon) | per-app SA | s0:c30 / s0:c31 |
per-app svc user | (non-Java: PEM, no JKS) |
| tuwunel (matrix) | per-app SA | s0:c32 |
per-app svc user | (non-Java: PEM, no JKS) |
| games | per-app SA | s0:c33 |
per-app svc user | (non-Java: PEM, no JKS) |
| casdoor-games | per-app SA | s0:c35 |
(IdP) | (non-Java: PEM, no JKS) |
| casdoor-games-pg | per-app SA | s0:c34 |
(DB) | — |
| owncast | per-app SA | s0:c39 |
per-app svc user | — |
| tube | per-app SA | s0:c55 |
per-app svc user | — |
| phpbb (forum) | per-app SA | s0:c51 |
per-app svc user | — |
| phpbb-db (forum) | per-app SA | s0:c50 |
(DB) | — |
cassandra (gateway revocation + URL registry) |
per-app SA | s0:c63 |
(DB) | (non-Java) |
velero (cloud-backup controller — server) |
velero |
s0:c64 |
— (no Casdoor user; cluster controller) | (non-Java: no JKS) |
velero-node-agent (Kopia filesystem/PV backups) |
velero |
s0:c65 |
— | (non-Java: no JKS) |
backups-status-sweep (cloud-backup CR-status sweep CronJob) |
backups-sweep |
s0:c66 |
— | (non-Java: no JKS) |
| coturn (TURN/STUN — optional, default-off) | sa-coturn |
s0:c67 |
per-app svc user | (non-Java: no JKS) |
edge-ai (ollama inference — GPU) |
per-app SA | s0:c73 |
— | (non-Java: no JKS) |
edge-ai-analysis (task-oriented analysis API in front of edge-ai — optional, default-off) |
per-app SA | s0:c87 |
— | (non-Java: no JKS) |
character-studio (ui) |
per-app SA | s0:c74 |
— | — |
games-ui (the games federation remote — optional, games slug) |
per-app SA | s0:c88 |
— | — |
games-bff-db (the games BFF's Postgres — optional, games slug) |
(pod default SA) | s0:c89 |
(DB) | (non-Java: PEM, no JKS) |
games-cassandra (the games BFF's session store — optional, games slug) |
(pod default SA) | s0:c90 |
(DB) | (non-Java: PEM, no JKS) |
games-portal (the standalone games site — optional, games slug) |
(pod default SA) | s0:c91 |
— | — |
games-cassandra-init (the keyspace Job for games-cassandra — optional, games slug) |
(pod default SA) | s0:c92 |
— | — |
image-builder (app-image Kaniko build pods) |
(per-build) | s0:c75 |
(build pod) | (non-Java: no JKS) |
edge-ai-tts (Piper TTS) |
per-app SA | s0:c72 |
— | (non-Java: no JKS) |
| meshbridge (Meshtastic ↔ Matrix bridge — optional, default-off) | sa-meshbridge |
s0:c76 |
(Casdoor machine client — manual, see meshbridge ESO) | (non-Java: no JKS) |
headwind-db (Headwind MDM Postgres — optional, default-off) |
sa-headwind-db |
s0:c77 |
(DB) | (non-Java: PEM, no JKS) |
headwind (Headwind MDM app — optional, default-off) |
sa-headwind |
s0:c78 |
— (LocalAuth admin, not Casdoor — see headwind-admin ESO) | (Java/Tomcat: no JKS — plain HTTP, TLS terminated at gateway) |
attestation-server (GrapheneOS AttestationServer — optional, default-off, single pod, no DB leg) |
sa-attestation-server |
s0:c79 |
— (SQLite-local accounts, not Casdoor — /attest/api/** gated ROLE_SUPERADMIN at the gateway) |
(Java: no JKS — plain HTTP, TLS terminated at gateway) |
mesh-bff-api (LoRa mesh BFF: node directory / bridge-sync) |
(pod default SA) | s0:c80 |
mesh-bff-casdoor-client (client-credentials → ROLE_SERVICE, manual — see secretstore ESO) |
hugmesh-mesh-bff-api.hugmesh-backend.svc |
mesh-bff-db (dedicated Postgres for mesh-bff-api) |
(pod default SA) | s0:c81 |
(DB) | (non-Java: PEM, no JKS) |
character-forge-bff-db (character-forge — optional, default-off) |
per-app SA | s0:c82 |
(DB) | (non-Java: PEM, no JKS) |
character-forge-bff-api (character-forge — optional, default-off) |
per-app SA | s0:c83 |
svc-character-forge-bff / ROLE_CHARACTER_FORGE_API |
hugmesh-character-forge-bff-api.hugmesh-backend.svc |
character-forge-ui (character-forge — optional, default-off) |
per-app SA | s0:c84 |
— | — |
The matrix is the contract for seLinuxOptions.level per Deployment and a
ServiceAccount per app. Each MCS category (s0:cNN) is unique — no two
workloads may share one, so a compromised pod cannot read another's
category-isolated volumes.
Status of the other two columns (checked 2026-10-07).
- Casdoor user / role.
manifests/casdoor/init-data-configmap.yamlseeds onlysvc-pki-gateway,svc-be-gateway,svc-fe-gateway(ROLE_GATEWAY),svc-api(ROLE_API),svc-admin-bff(ROLE_ADMIN_API) andsvc-signup-gate(ROLE_SERVICE) andsvc-test-ingest(ROLE_TEST_INGEST, the test-runner Job's ingest-only machine role). Thecasdoor-initjob also creates client-credentials machine apps foruser-bff(ROLE_API),matrix/mastodon/fragment-sync(ROLE_USER),test-ingest(ROLE_TEST_INGEST),harborandheadscale. The users and roles shown for the other rows (svc-gateway-superadmin,svc-federation,svc-mod-bff,svc-user-bff,svc-forum-bff,svc-wiki-bff,svc-service-catalog-ui,svc-character-forge-bff,ROLE_FEDERATION,ROLE_MOD_API,ROLE_USER_API,ROLE_FORUM_API,ROLE_WIKI_API,ROLE_SUPERADMIN_UI,ROLE_CHARACTER_FORGE_API) appear nowhere inspecs/,scripts/ortests/. They are the target, not the shipped state. - mTLS cert. Pods do not mount JKS files. Vault
pki_intissues a short-lived cert per app, External Secrets syncs it into a<app>-mtlsTLS Secret (tls.crt,tls.key,ca.crt), and abuild-keystoreinit container (in the gateway chart and inmanifests/admin-bff-api/deployment.yaml) turns it into a PKCS12 keystore and truststore in a tmpfs/storesvolume with a pod-local random password. The cert's CN is the name in the column with.cluster.localappended (common_nameinmanifests/external-secrets/pki-externalsecrets.yaml). The offlinegen-keystores.shfallback keystores cover only seven services:<brand>-pki-gateway,-be-gateway,-fe-gateway,-api,-admin-bff-api,-mod-bff-api,-user-bff-api. See §4.
service-catalog-ui note (reservation discharged 2026-08-26). This row used to read "no Deployment yet" and mark
s0:c49(reserved). The console shipped only a federation descriptor (manifests/federation-api/register-superadmin-service-catalog.descriptor.yaml), a gateway route and route-access rows, with nothing to serve them. The Deployment and Service now exist (manifests/superadmin-service-catalog-ui/) and carry exactly the reserved identity:serviceAccountName: sa-service-catalog-uiandsecurityContext.seLinuxOptions: { type: container_t, level: "s0:c49" }.What the reservation cost while it was only prose.
edge-ai-analysistooks0:c49as "next free". That was correct by the only evidence it had, because a reservation with no Deployment is invisible to a manifest scan and to the[mcs]uniqueness gate (which compares workloads). The clash surfaced when the Deployment was written, andedge-ai-analysismoved tos0:c87. The lasting fix is not the renumber.edge-ai-analysishad no row in this matrix at all, and an unlisted workload cannot be avoided. Anything that holds a category must appear above.
cassandraMCS note. Categorys0:c63is set through the bitnami cassandra 12.3.11 chart's supportedpodSecurityContext.seLinuxOptionsandcontainerSecurityContext.seLinuxOptionsvalues keys (specs/cluster/apps/00-cassandra.yaml). OnlyseLinuxOptions.levelis set; all other securityContext chart defaults are untouched. This is a clean values override (no chart fork, no template patch), so it is not an exemption.Cassandra auth (live) and TLS (dark, ADR-32). The per-app least-privilege roles
admin_bff_cass,pki_gw_cass,be_gw_cass,fe_gw_cass,sa_gw_cassandfederation_cassare Cassandra-internal login roles (CQLCREATE ROLE, deny-by-default underCassandraAuthorizer). They are not separate pods or ServiceAccounts, so they take no new MCS category. The livecassandra-bootstrapJob creates them (apps/00b-cassandra-init.yaml,manifests/cassandra-init/). The dark TLS helper Job (cassandra-tls-keystore-builder,manifests/cassandra-hardening/) is also a Cassandra-tier admin client. Both Jobs run under the sames0:c63, set in their podseLinuxOptions.level. They add no node service and need no newspecs/selinux/*.te/.fcmodule. No new listening port is opened: auth and TLS reuse the CQL port:9042, which thedb-ingress-cassandraNetworkPolicy already covers. The credentials come from ESO/Vault only (secret/<brand>/cassandra-admin,…/cassandra-app-creds) and are never in git. Seedocs/CLUSTER-HARDENING-PLAN.md§H.
velerocloud-backups MCS note. The opt-in, inert cloud-backups leg (specs/cluster/apps/55-velero.yaml,specs/cluster/manifests/velero/) runs THREE distinct pods in theveleronamespace, each with its own unique category:
- the Velero server
s0:c64and the node-agent DaemonSets0:c65, set through the upstream Velero 12.0.3 chart's supportedpodSecurityContext.seLinuxOptionsandcontainerSecurityContext.seLinuxOptionsvalues keys (andnodeAgent.podSecurityContext/nodeAgent.containerSecurityContext). OnlyseLinuxOptions.levelis set and every other chart securityContext default is untouched: the same clean values override as cassandra, with no fork;- the
backups-status-sweepCronJob, which carriess0:c66on its podsecurityContext(specs/cluster/manifests/velero/sweep-cronjob.yaml).The admin-bff
cloudbackupeffector identity (k8s SAbackups-effector, granted create/get/list/patch onvelero.ioBackup/Restore throughspecs/cluster/manifests/velero/rbac.yaml) runs INSIDE theadmin-bffpod. It inheritsadmin-bff'ss0:c23and does not take a category of its own. The whole leg ships dark (apps 55/56 manual-sync, and the admin-bff defaultapp.backups.effector.enabled=false). These categories are therefore reserved correct by construction and become live only on a deliberate superadmin opt-in.
coturnTURN-relay MCS note. The OPTIONAL, DEFAULT-OFF coturn relay (specs/cluster/manifests/coturn/) carries categorys0:c67on its podsecurityContext.seLinuxOptions.level(deployment.yaml). It runs as the dedicated SAsa-coturn(service-account.yaml,automountServiceAccountToken: false, because coturn needs no Kubernetes API). It shares thehugmesh-backendnamespace with tuwunel (s0:c32) so that both can use the ESO-synced TURN long-term-credential secret (coturn-shared-secret). The unique MCS category keeps the two pods category-isolated. coturn ships dark (RUNTIME-ONLY: no baked Application; gated by the apps/13a element and theinstalled-servicesConfigMap entrycoturn:"false"), so the category becomes live only on a deliberate per-domain opt-in. Seedocs/COTURN.md.
Node-service custom domains. The host-service SELinux domains in
specs/selinux/*.teare part of this contract for node processes (not pods). The full set:
Module ( .te/.fc)Domain(s) Confines Binary / labelled path localpath_provisionerlocalpath_provisioner_t,localpath_provisioner_helper_tlocal-path-provisioner controller + busybox helper (pod, runtime transition) /mnt/{data,usb}/local-pathotel_collectorotel_collector_totel-collector DaemonSet (pod, runtime transition) (no host exec; /var/log/pods)hugmesh_authkeyshugmesh_authkeys_t(+hugmesh_authkeys_cache_t)the AuthorizedKeysCommand (sshd_t domtrans, runs as nobody) — security-load-bearing. Its .fcalso carries the two label-only entries below (no.teof their own)/usr/sbin/hugmesh-authorized-keys-lookup;/etc/hugmesh/registryhugmesh_device_registry_synchugmesh_device_registry_sync_tLayer-B registry sync daemon (writes the export cache + the sshd_config.d drop-in, reloads sshd) /usr/sbin/hugmesh-device-registry-sync(in hugmesh_authkeys.fc) break-glass(label only — ssh_home_t)the loopback break-glass authorized_keys file so sshd reads it on enforcing /etc/ssh/break-glass.keyshugmesh_vpnhugmesh_vpn_runner_t,hugmesh_vpn_reconcile_t(+hugmesh_vpn_etc_t,hugmesh_vpn_runtime_t)egress-VPN runner (net_admin: wg/tun + ip-rule kill-switch) + the signed-export reconcile agent /usr/sbin/hugmesh-vpn-runner,/usr/sbin/hugmesh-vpn-reconcile;/etc/hugmesh/vpnhugmesh_node_storagehugmesh_node_storage_t(+hugmesh_node_storage_cache_t)node-storage reconcile agent (lsblk + FDE pool provision via provision.sh + kubectl nodePathMap patch) /usr/sbin/hugmesh-node-storage-reconcile;/var/lib/hugmesh/node-storagehugmesh_domain_reconcilehugmesh_domain_reconcile_t(+hugmesh_domain_reconcile_cache_t)domain-registry -> brand-repo bridge (#4): mTLS-fetch + verify the signed cross-domain export, then exec gen-keystores.sh + generate-brand-repos.sh to emit per-domain CA + brand GitOps repos into a node-local staging dir (NO block-device admin — emits files only) /usr/sbin/hugmesh-domain-reconcile;/var/lib/hugmesh/domain-registryhugmesh_policy_synchugmesh_policy_sync_tLayer-A headscale policy-sync agent (pki/control node only; renders + applies policy.hujson) /usr/sbin/gen-headscale-policy.sh(in hugmesh_authkeys.fc) oidc token(label only — user_runtime_t)the per-user SSO OIDC-token deposit dir read by the desktop bearer-forward GEN-SSO artifact /run/user/[^/]+/hugmeshhugmesh_torhugmesh_tor_reconcile_t(+hugmesh_tor_etc_t,hugmesh_tor_var_lib_t)the Tor onion-service reconcile agent (writes the managed /etc/tor/torrc, restarts the distrotor, exports the.onionhostname). The Tor daemon itself is confined by the upstreamtor_t/usr/sbin/hugmesh-tor-reconcile;/etc/hugmesh/tor;/var/lib/hugmesh/torThere are nine
.temodules. Each is a node module compiled by the build-host policy compile (the.ppis built on the x86 BUILD host, NOT first-boot — the Pi cannot run the refpolicy devel toolchain). The shared registry cache typehugmesh_authkeys_cache_t(declared inhugmesh_authkeys.te) is the on-disk handoff reused by the device-registry-sync, domain-reconcile, vpn-reconcile, node-storage, and policy-sync domains.scripts/_selinux-policy-lib.sh, called from all tenbuild-*-stage4.sh, compiles and installs the modules into every image, andprovision_selinux()loads them at first boot.localpath_provisioner,otel_collectorandhugmesh_torare installed only where the upstream policy modules they need are present. The images still boot permissive; the modules'# INFERRED-WIDErules have not been narrowed. Seedocs/selinux-module-loading.md.
The heading is a link target and keeps its old wording. Pods do not mount JKS
keystores from Vault. They use Vault-issued certs, which a build-keystore init
container turns into PKCS12 stores.
Every Java machine user (the Spring Cloud gateways and the Spring services) has its
own mTLS identity for cross-namespace calls. There are two cert paths, both rooted
in one cluster CA (the header of scripts/gen-keystores.sh
says the same):
- In-cluster (preferred, what pods use). Vault
pki_intimports the cluster CA (provisioned to thevaultnamespace as thecluster-caSecret from the pki USB) and issues a short-lived cert per app. External Secrets syncs each into a<app>-mtlsTLS Secret (tls.crt,tls.key,ca.crt) in the app's namespace (manifests/vault-pki,manifests/external-secrets/pki-externalsecrets.yaml). Abuild-keystoreinit container (gateway chartspecs/cluster/charts/hugmesh-gateway/templates/deployment.yaml; admin-bff inmanifests/admin-bff-api/deployment.yaml) builds a PKCS12 keystore and truststore in a tmpfs/storesvolume. It generates the store password in the init container, so the password is never in git, a Secret or Vault. The app loads it through a generatedapplication.properties(hugmesh.tls.key-store=/stores/keystore.p12,…trust-store=/stores/truststore.p12). The gateway chart sets the TLS protocol floor to TLS 1.3 (server.ssl.enabled-protocols,keystore.tlsProtocols;docs/CRYPTO-AUDIT.mdrow 6). - Offline / USB (the CA and fallback keystores).
scripts/gen-keystores.sh, run bygen-provision-keys.shon the pki node, generates the cluster CA (certs/cluster-ca.crtis the trust anchor on every KEYS stick), per-service fallback keystoreskeystores/<svc>.keystore.jks, a truststore andpasswords.json. Because the in-cluster certs chain to this same CA, the offline truststore validates them. No manifest underspecs/clustermounts the.keystore.jksfiles. Verified bytests/keystores/test-keystores.sh(26/26 on 2026-10-07). - Multi-tenancy (per-domain CA loop): by default the generator provisions a
single domain — byte-/functionally-identical to the pre-multi-tenancy output. A
build can list multiple brands/domains in
brands/domains.conf; the generator then loops, generating an independent-root CA (default) or importing a provided one (the same--ca-cert/--ca-keyseam, now per-domain) for each, and writing that domain's keystores underkeystores/<brand>/. Each domain gets a NARROW truststore (its own root only) so per-brand gateway/BFF/UI instances deny cross-domain mTLS at the trust anchor (defense in depth). The gateway chart selects the tier withkeystore.trustTier(NARROWby default,WIDEfor the architecture tier). One WIDE multi-anchor truststore (every domain's root) is built underkeystores/architecture/for the architecture tier ONLY (Vault / federation / superadmin), which must validate cross-domain mTLS. With one domain the wide store holds exactly the one root (== the narrow store). The single-domain byte-identical invariant + the N≥2 narrow/wide tiers + the per-domain import path are proven bytests/keystores/test-keystores-multidomain.sh(30/30 on 2026-10-07; it diffs the refactored output against a frozen pre-refactor golden). CA private keys never go in git — only public certs/truststores; an importedCA_KEYpath must point at the key-USB / a secret dir.
provision_truststore() builds a PKCS12 truststore (truststore.p12) from the
cluster CA / cert chain on the USB KEYS stick, copies any keystores/*.jks
from the stick next to it, and publishes kube-system/hugmesh-truststore. The
node-level truststore serves host-side Java processes: they must be started with
-Djavax.net.ssl.trustStore=<that file> -Djavax.net.ssl.trustStoreType=PKCS12 (the
comment above provision_truststore() says so). No specs/cluster manifest sets
those javax.net.ssl properties, and JAVA_TOOL_OPTIONS is not used for this.
In-cluster Java pods get their trust anchor from the build-keystore init
container in §4.
Casdoor is the OIDC IdP.
- Exposure. The superdomain Casdoor ships with no Ingress and is reached from
inside the cluster. A per-domain Casdoor (
idp: own) carries its own Ingress atid.<clusterDomain>(manifests/casdoor-domain/ingress.yaml). No front-door route (fe-gateway, be-gateway) exposes Casdoor. The pki-gateway is not internet-facing (the internal ingress on the pki node serves it, LAN/VPN only). It does route/api/auth/**,/login/**and/.well-known/**to Casdoor, and it sends/api/signupand/api/loginthrough the signup-gate first (docs/USERNAME-CONFUSABLE.md). - Human login is a native, first-party form. The browser's sign-in does not go to
Casdoor.
login-uiPOSTs username and password (plus any MFA passcode) to user-bffPOST /bff/login. user-bff runs PKCE, the internal Casdoor/api/loginand the code exchange server-side, and returns only an opaquebff_session cookie. No JWT,code_verifier,stateor Casdoor URL ever reaches the client. - Sign-up. Federated sign-up (Google/Discord) and registration stay admin-allowlist-gated (two-stage).
- Service users (the per-app identities in §3) are separate Casdoor accounts with
service roles. §3 says which are seeded. The gateways validate the Casdoor JWT and
the
External-*headers.
Calico is the CNI (specs/cluster/apps/01-calico.yaml, Tigera operator). Its
tunable config (pod CIDR, encapsulation, BGP, NAT, block size) comes from the KEYS
provision.json calico block, which provision_calico() renders into the
Installation CR. The app header says its secrets (typha mTLS, BGP passwords) are
Vault-managed via External Secrets, but no ExternalSecret for them exists in
manifests/external-secrets/ and BGP is disabled by default
(calico.bgp.enabled: false), so that part is not built. Default-deny ingress
NetworkPolicies per tier (docs/CLUSTER-HARDENING-PLAN.md §B) complement
the SELinux isolation. Egress default-deny ships dark.
The mesh is no longer flat for SSH or node-to-node traffic. Only pod and ClusterIP traffic is open between nodes, as below.
Every node joins one tailnet via headscale (control server on the pki/omnibus
node). The mesh is governed by a default-deny, tag-based ACL under
policy.mode: file (specs/etc/headscale/config.yaml), where headscale reads the
policy file at startup. provision_headscale (and later gen-headscale-policy.sh)
tries headscale policy set; when headscale refuses it in file mode, they restart
headscale so the rewritten file is the one in force.
- Membership tag. Nodes self-apply
tag:hugmesh(+ a per-roletag:pki/tag:be/tag:fe/tag:host) at join throughtailscale up --advertise-tags=..., which comes from.tailscale.up_argsinprovision.json(keys-template/provision.json,keys-template/examples/).tagOwnersrestricts those tags to thehugmeshheadscale user (the preauth-key owner), so only enrolled nodes can claim them. That user owns only these membership tags. With OIDC join, the Casdoorhugmesh/headscalegroup gates enrolment (allowed_groups, matching the group's real<owner>/<name>claim shape — seekeys-template/headscale/config.yaml) — two independent membership layers. - Pod/service data plane only. The one
acceptrule inaclsistag:hugmesh → {10.244.0.0/16, 10.96.0.0/12}:*(pods + ClusterIP services, all ports). The earlier any-to-any ruletag:hugmesh → tag:hugmesh:*was dropped ([FIX-DROPMESHRULE]) because it exposed every node's :22 to every other node. There is no internet-wide*grant and no exit-node access — the tailnet is fleet-scoped. - SSH is a separate, default-deny block.
tailscale up --sshis on by default (.tailscale.ssh). Thesshsection of the policy allows only the privileged user (@@TS_SSH_USER@@, rewritten by keys-provision; root and other accounts are denied), and only fromtag:superadmin: everysshrule's source in every shipped and rendered policy istag:superadminand nothing else. Tailscale SSH answers :22 itself, so the device's sshd key checks are not on that path and whoever a rule names as its source gets a privileged session;tag:hugmeshand the role tags are self-applied by every node holding a pre-auth key, so they are never a source. The one :22 rule inaclsistag:superadmin → tag:hugmesh:22; without it the superadmin's session could not reach the node. keys-provision refuses a KEYS-stick policy (and a stick-supplied bootstrap) whosesshrules name any other source, under every spelling headscale reads: it stages the clean bootstrap or removes those sources. The image bakespolicy.bootstrap.hujson, which first boot stages as/etc/headscale/policy.hujsonunless the KEYS stick carries its ownheadscale/policy.hujson(that wins). On the control node,gen-headscale-policy.sh(Layer A of the device-license registry) re-renders it frompolicy.hujson.tmplafter the first signature-verified registry export, with onesshedge per permitted operator and server-forced security tags (tag:dev_*,tag:dom_*,tag:mesh_*,tag:superadmin, set byhugmesh-headscale-forcetags). Every policy gives these tags an empty owner list, and that is what stops a node self-advertising them: headscale 0.23 grants a node its forced tags plus every advertised tag its own user owns, so a security tag owned byhugmeshcould be claimed by anyone holding a pre-auth key. keys-provision refuses to load a KEYS-stick policy that gives one an owner, and a key minted by the Studio may not carry one (headscale forces a key's tags at join). The check reads owners the way headscale does: under a case variant such asTagOwnersand in every repeat of atagOwnersmember (headscale's Go JSON decoder honours both; a plain.tagOwnersquery saw neither). A refused policy is replaced by the clean baked bootstrap policy, or, with no clean bootstrap, by the same policy with those owners emptied and checked again. Everything else fails closed: a policy that can be neither narrowed nor read, and no policy at all, get a static deny-all policy (no ACL, no SSH rule, no tag owner: nodes join but reach nothing and cannot claim a tag), first-boot health is marked UNPROTECTED in/run/hugmesh/firewall-health/headscale_policy.unprotected(with an ERROR line in/var/log/keys-provision.logand adaemon.critsyslog line), and when even the deny-all policy cannot be written headscale is not started. The first verified Layer-A sync, or re-provisioning with a clean policy, replaces the deny-all policy. Seedocs/DEVICE-REGISTRY-KEY-ROTATION.md. All of these checks are on/etc/headscale/policy.hujson, and headscale loads the file its own configuration names, which comes from the KEYS stick. So right before starting headscale, keys-provision asks headscale itself (headscale dumpConfig, the same config search and resolutionheadscale servedoes) what it will load, and starts it only onpolicy.mode: filewithpolicy.path: /etc/headscale/policy.hujson. A stick config that names another file (another stick file such asacl.hujsoncould owntag:superadmin), names none (headscale then runs allow-all), selects database mode, uses a relative path, or cannot be read is refused: headscale is not started, health is marked UNPROTECTED withstate=not-started, and the config is moved aside to/etc/headscale/config.*.refused, because OpenRC'srestartstarts a stopped service and later steps restart headscale (the CP DNS record, the Layer-A policy-sync apply leg).publish_cp_dns_record, which rewritesconfig.yamlafter that first check, runs the same check again before its restart. Measured on headscale 0.23.0, a line-by-line read ofconfig.yamlis not enough to know the answer (case-variant and dotted keys,<<:merges, CR/NEL/U+2028 line breaks, a quoted scalar that swallows a laterpolicy:block, a second YAML document, aconfig.jsonbeside the yaml). The boundary: the check runsheadscale dumpConfigwith everyHEADSCALE_*variable unset, so it reads the configuration FILES only. headscale also readsHEADSCALE_*variables from the daemon's own environment (for exampleHEADSCALE_POLICY_MODE,HEADSCALE_POLICY_PATH), and those override the file. What is known:specs/etc/init.d/headscalesets none, as of this writing. What is NOT checked, by this check or by any guard: that no variable reaches the daemon after the gate has passed (an/etc/conf.d/headscalethat exports one, a later init step, a host environment). Such a variable could point the daemon at a different policy file, or at database mode, after the check approved the config. This is a residual risk, not a closed one.specs/etc/headscale/policy.hujsonis a reference copy that the builders no longer bake; neither it norkeys-template/headscale/policy.hujsoncarries the any-to-any rule (their header comments say it was dropped). - Pods/services as one LAN. Each node advertises the cluster pod
(
10.244.0.0/16) and service (10.96.0.0/12) CIDRs (--advertise-routes=...) and accepts approved routes (--accept-routes).autoApprovers.routesmaps exactly those two CIDRs totag:hugmesh, so advertised subnet routes are auto-approved (no manualheadscale nodes approve-routes);provision_headscalealso backfills approval for any node that registered before the policy loaded.--snat-subnet-routes=falsepreserves real pod source IPs. IP forwarding for the subnet routers is already enabled cluster-wide (specs/etc/sysctl.d/99-kubernetes.conf:net.ipv4.ip_forward=1,net.ipv6.conf.all.forwarding=1).
The CIDRs in the headscale policies, the --advertise-routes flags, and
kubeadm-config.yaml (podSubnet/serviceSubnet) / provision.json
.calico.pod_cidr must stay in sync.
provision_headscale resolves the control server's server_url local-first at
first boot (resolve_endpoint), so a node provisioned before any public DNS exists
is still reachable by its LAN peers. Precedence, highest first:
provision.json .headscale.server_url;.mesh.endpoint;- the baked brand
HEADSCALE_URL(/etc/hugmesh/headscale-url, written at build time because env does not survive to first boot); - default
http://<the pki node's primary RFC1918 LAN IPv4>:8080.
The single server_url: line in /etc/headscale/config.yaml is rewritten in
place (idempotent) before headscale starts. The baked http://127.0.0.1:8080
is only an ultimate fallback.
The tailscale client mirrors this. An empty .tailscale.login_server defaults to
the same resolved endpoint on the control node. On a worker or additional control
plane it defaults to resolve_control_endpoint. A worker never points at its own LAN
IP. Precedence, highest first:
provision.json .headscale.server_url;.mesh.endpoint;- before go-live only: the pki node's confirmed LAN address,
http://<.mesh.pki_lan_ip>:8080. "Before go-live" means both of these hold:- this node is not past go-live itself, by the predicate
hugmesh-go-liveuses:/etc/hugmesh/release-stateis notpublicand the/etc/hugmesh/go-livemarker is absent (an absent release-state file is internal); - the baked
HEADSCALE_URLdoes not answer as a control server. The node's image cannot know that the mesh went live after the image was built, so keys-provision asks:GET <baked URL>/key?v=<the client's capability version>, the first requesttailscale upmakes, must return a Noise machine key (mkey:+ 64 hex). curl verifies https against the node's trust store, follows no redirect and is bounded (4 s; the LAN address 3 s). A captive portal, a parked name, an HTTP error or a certificate that does not verify is "does not answer";
- this node is not past go-live itself, by the predicate
- the baked brand
HEADSCALE_URL; - the pki row of
.nodes[](http://<ip>:8080).
Why step 3 exists: a worker's first boot happens before any public name answers, so
a baked public HEADSCALE_URL in step 4 left a LAN-first mesh (no public DNS, IP or
port-forward) with workers that never reached their control plane.
.mesh.pki_lan_ip is written only by gen-provision-keys.sh --pki-ip (the Studio
requires it for a mesh, with a static IP or a DHCP reservation behind it). The pki
row of .nodes[] is the template's example address (10.0.0.10) unless someone
edited it, so it stays below the baked URL. A malformed value in either is dropped,
never interpolated.
After go-live, step 3 is skipped and the baked URL wins again: on a node past
go-live itself without asking anything, and on every other node as soon as the
baked URL answers, whatever its image and whether or not it is on the pki's LAN.
The baked URL is asked first in every round and wins when both answer, so a worker
of a live mesh never contacts the pki LAN address at all (a worker on some other
LAN does not offer its pre-auth key to whatever holds that RFC1918 address there).
Before go-live it does: a worker on the pki's LAN offers its pre-auth key to
http://<pki_lan_ip>:8080 over plain HTTP, as a mesh with no baked URL always has
(headscale's Noise channel protects the exchange, but anything that holds that
address on that LAN receives the key). The static IP or DHCP reservation the Studio
requires is what keeps that address the pki's.
keys-provision runs once and tailscaled keeps the login server it is given, so the
two are asked in rounds (2 s apart) until one answers, for at most
.mesh.control_probe_wait seconds (0-600, default 45): a Wi-Fi profile the same run
installed, or a NIC still waiting for DHCP, does not pin the wrong answer. The usual
first boot pays one round. When neither answers within the wait the LAN address is
kept (before go-live is the default), with a WARNING saying that a node of a live
mesh off the pki's LAN will not join until it is provisioned again with a working
uplink (.provision-force) or its stick names .mesh.endpoint. Every platform's
base packages.list requests net-misc/curl (it is also in every stage3 seed), so
the question can be asked on every image; an image with no curl keeps the LAN
address and says so. A worker that joined over the LAN keeps that login server;
changing it later needs tailscale up --login-server=<new> --force-reauth.
The pki side. The pki node's own server_url still follows resolve_endpoint
above, so a pki baked with a public HEADSCALE_URL advertises that URL while its
workers dial its LAN address. Registration and the netmap do not depend on it; the
embedded DERP region's host and the OIDC callback do. Before go-live the LAN peers
connect directly, so relay through that host is what is lost.
The firewall. As built, nothing blocks the LAN dial: no shipped image enables
firewalld (x86 ships it but does not enable it; ARM leaves it out), and the nftables
tables (hugmesh-firewall-reconcile, hugmesh-coturn-firewall) do not drop
headscale's port. An operator who enables firewalld on an ENV=prod x86 image gets
its baked DefaultZone=drop with only tailscale0/lo trusted, which would drop
a worker that has not joined yet. For that case provision_headscale writes
headscale's listen port to /etc/hugmesh/headscale-lan-control, and
hugmesh-coturn-firewall (boot and a 60 s cron) admits that port over TCP from
the RFC1918 ranges only (one runtime rich rule each for 10.0.0.0/8,
172.16.0.0/12 and 192.168.0.0/16). It records the port it admitted in
/run/hugmesh/headscale-lan-control.fw and, when the marker goes or the port
changes, removes only rules of that exact shape for a recorded port: an operator's
rich rule for any other port is never touched.
A public facade (scale.<domain>) can be published later without re-imaging. The
MagicDNS control-plane name stays stable across the IP→domain transition, so clients
re-pin only if login_server itself changes. --snat-subnet-routes=false and the
fleet-scoped, default-deny ACL are unchanged, and the endpoint stays on the
tailnet/LAN by default (no internet-wide grant).
The Kubernetes control plane is N-node HA and uses a stable MagicDNS
endpoint, never a node IP, as controlPlaneEndpoint:
- Stable name.
provision.json .mesh.cp_dns_name(defaultkube-api.<base_domain>, i.e.kube-api.headnet.internal) is set ascontrolPlaneEndpointinkubeadm-config.yamland as every join target. After the control node is on the tailnet,publish_cp_dns_recordresolves its tailnet IP (tailscale ip -4, fallbackheadscale nodes list) and writes adns.extra_recordsA-record (cp_dns_name → tailnet IP) into the headscale config, then reloads headscale — so any mesh node resolves the API over the tailnet with no baked-in control-plane IP.provision_hostsalso writescp_dns_name → pki IPto/etc/hostsfor the first-boot window before MagicDNS converges. - First vs additional control-plane is data-driven and idempotent. The
first CP (
role=control-plane,bootstrap=true,firstdefaults true) runskubeadm init --upload-certsand persists fresh join material (/etc/hugmesh/kubeadm-join.cmd+kubeadm-certificate-key, mode 0600). An additional CP (first=false, full.kubernetes.joinincl.certificate_key) runskubeadm join … --control-plane --certificate-key. The robust default keys off a probe ofhttps://<cp_dns_name>:6443/healthz: if the cluster already answers, the node joins as additional regardless of the flag (so a re-imaged or mis-flagged node never re-inits a second cluster). Every branch guards on/etc/kubernetes/{admin,kubelet}.conffor idempotency. - Workers (
role=worker)kubeadm jointhe samecp_dns_name:6443. ThecertSANsinkubeadm-config.yamlcover the MagicDNS name, the control-node hostname, and loopback so additional CPs/clients validate the API cert. - N-per-role is not limited by the policy.
tag:hugmesh(+ per-role tags) are all owned by the singlehugmeshheadscale user, sotagOwnersgates which tags a node may claim, not how many nodes. N nodes per role join and mesh with no policy change. The limit is the preauth key: the template (keys-template/provision.json,.headscale.preauthkeys[]) mints one key with"reusable": false. Mint one key per node, or setreusabletotrue.
Checked against origin/main on 2026-10-07.
- Implemented: the LSM switch, container SELinux (
enable_selinux, per-workloadseLinuxOptions.levelandServiceAccount, both checked bytest-cluster-manifest-integrity.sh), truststore-from-USB, offline keystore and CA generation (test-keystores.sh26/26,test-keystores-multidomain.sh30/30), the Vault PKI → ESO →build-keystorepath for gateway and admin-bff pods, and the node-policy module build/install/load (§3). - Not enforcing: every image boots SELinux permissive. The nine node modules are loaded, and the enforce-gate ships inert. Whether a cross-built Pi image relabels cleanly still needs a hardware boot check.
- Not built as the matrix describes: most Casdoor service users and roles in §3
(see the status note under the matrix), and the Calico typha/BGP ExternalSecrets
named in
apps/01-calico.yaml.