Skip to content

feat: Kerberos clock skew tolerance per instance - #14

Merged
ks98 merged 4 commits into
mainfrom
feat/krb5-clockskew
Nov 19, 2026
Merged

ks98 merged 4 commits into
mainfrom
feat/krb5-clockskew

Conversation

@ks98

@ks98 ks98 commented Nov 19, 2026

Copy link
Copy Markdown
Contributor

Why

At a school, Windows clients start after the weekly LINBO re-imaging with a clock exactly 1 h behind (the image's registry holds the summer-time bias). When W32Time steps the clock later, every Kerberos authenticator of the running logon session is about 1 h in the future, and squid's negotiate_kerberos_auth rejects it (gss_accept_sec_context() failed ... Clock skew too great, MIT default 300 s), so users get login popups until they log off. The root cause is being fixed on the clients (RealTimeIsUniversal); this option bridges the time until every room has been re-imaged.

What

  • New per-instance field krb5_clockskew_seconds (300–7200, default 300): CLI --krb5-clockskew-seconds on create/edit, REST POST/PATCH, hand-editable instance YAML (applied by reconcile / update <name>).
  • Passed to the container as KRB5_CLOCKSKEW_SECONDS only when it differs from 300, so existing instances keep their container spec on upgrade; the entrypoint validates it again and writes [libdefaults] clockskew = <n>.
  • lmnsquid edit / PATCH with an invalid value now answers 422 with field and reason instead of 500 (all fields).
  • Docs: operations (how/when, trade-off), ADR-017, threat model T17, references (MIT clockskew applies to the acceptor), test strategy, changelog block 7.3.9.

Takes effect only with an image that contains the new entrypoint: DEFAULT_IMAGE must be pinned to the image CI builds after this merge (follow-up pin PR) before tagging.

Tests

  • scripts/tests/run.sh quick: 7 passed, 0 failed, 0 skipped (pytest 223 passed).
  • LMNSQUID_ALLOW_REAL=1 scripts/tests/run.sh e2e (Samba AD DC + squid + client, client clock shifted with libfaketime after a ticket was obtained): 4 passed, 0 failed, 0 skipped. +0 min → 200 at 300 and 5400; +60 min → 407 at 300, 200 at 5400; +100 min → 407 at 5400; entrypoint refuses 299 / 7201 / abc.
  • Independent cold verification (fresh agent) confirmed all of the above, an unchanged spec fingerprint for instances without the setting, and make deb → linuxmuster-squid_7.3.9_amd64.deb.
  • Not tested: lab with a real Windows client, .deb upgrade from 7.3.8 on a real host. A client clock behind fails in the MIT client itself ("Ticket not yet valid"); Windows/SSPI behaviour for that case is not verified.

Kevin Stenzel added 4 commits November 19, 2026 10:21
PATCH /v1/instances/{name} re-validates the merged instance, but the
ValidationError of that step was not handled: an edit such as
"lmnsquid edit <name> --http-port 0" answered "500 Internal Server
Error" without a reason. It is now a 422 in FastAPI's validation format,
naming the field, like a bad POST body; nothing is changed, as before.
A school's Windows clients run 1 h ahead of the proxy after a LINBO sync
until W32Time corrects them; their authenticators are then refused with
"Clock skew too great" (MIT default 300 s) and users get login popups.
Until the clients are fixed, an instance can now tolerate more (ADR-017):

  lmnsquid edit <name> --krb5-clockskew-seconds 5400   (also on create)
  PATCH /v1/instances/{name} {"krb5_clockskew_seconds": 5400}
  krb5_clockskew_seconds: 5400 in the instance definition + reconcile

300-7200 s, default 300. The value is part of the instance definition,
so update, update-all, rollback and reconcile keep it. The control plane
passes it as KRB5_CLOCKSKEW_SECONDS, only when it differs from 300: the
env of an instance at the default stays that of 7.3.8, so its spec
fingerprint does not move and the upgrade replaces no container.

The entrypoint validates it again (plain decimal 300-7200, else FATAL
and exit 1 before anything is rendered; libkrb5 itself would silently
fall back to 300 on a value it cannot parse) and writes "clockskew = n"
into [libdefaults] of the krb5.conf it renders. MIT applies clockskew on
the acceptor side (krb5_check_clockskew on the authenticator time,
krb5int_validate_times on the ticket times); the replay cache keeps its
entries for the same skew (docs/references.md).

Per instance only: config.yml configures the control plane and has no
instance defaults to inherit from.

Docs: operations.md (how, when, trade-off), ADR-017, threat model T17,
architecture, references, the instance field table.
A new instance squid-skew (KRB5_CLOCKSKEW_SECONDS=5400) next to squid
(default 300). The test client gets libfaketime: it fetches the TGT and
the HTTP/<proxy> service ticket with the true time, as a Windows client
holds them when its clock jumps, then runs curl with its clock ahead, so
every authenticator carries that time:

  +0 min    -> 200 at 300 and at 5400
  +60 min   -> 407 at 300, 200 at 5400
  +100 min  -> 407 at 5400

Also: the rendered krb5.conf carries "clockskew = 300" resp. 5400, and
the image refuses 299, 7201 and abc (exit 1, FATAL), run without a
network so it does not take the fixed address of the running instance.
… image

A client clock behind the proxy is not helped by a larger clockskew: an MIT
client fails itself ("Ticket not yet valid" in gss_init_sec_context, nothing
reaches the proxy) and the KDC refuses its new ticket requests; Windows (SSPI)
behaviour for that case is not verified. The setting takes effect only with a
data-plane image containing the new entrypoint (DEFAULT_IMAGE pinned to the CI
image built after the merge); with an older image the value is accepted and
stored but has no effect. operations.md, ADR-017, changelog.
@ks98
ks98 merged commit 6694861 into main Nov 19, 2026
7 checks 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