Repository navigation
v0.3.0-alpha
Pre-releasePost-audit release. Nine PRs (h2ck.me v1 audit findings + one Snyk
base-image bump) landed on dev between 2026-09-04 and 2026-09-06
as one coordinated batch. Every finding was independently reviewed
by h2ck.me and closed with verdict ✅ pass.
Upgrading from 0.2.x
One breaking change. OIDC discovery is fail-closed on plain
HTTP by default (see ### Changed below). To find and fix
affected configs before upgrading:
# Any plain-http discovery_url in your tim.yaml:
grep -nE 'discovery_url:\s*http://' tim.yaml
# Anywhere in a mounted config directory:
grep -rnE 'discovery_url:\s*http://' /path/to/config/If a hit is intentional (dev against a non-TLS mock IdP), set
oauth2.providers.<id>.allow_http_discovery: true alongside the
plain-http URL. Otherwise, switch to https:// before upgrading.
The check also enforces HTTPS on endpoints inside the returned
discovery document — a provider that publishes HTTP endpoints in
its .well-known/openid-configuration will fail login regardless
of the URL you configured, and needs the same opt-in.
Two soft behaviour changes worth noting:
- Legacy
?session_id=<id>query-string transport now logs at
WARN (was DEBUG). Log-volume alerting keyed on WARN counts
may fire on deployments still using the query transport. Migrate
callers toAuthorization: Bearer sess_<id>orX-TIM-Session. - JWT validate
reasonfield values may differ for previously
mis-classified errors (see### Fixedonjwt/service.rs).
Dashboards keyed on the exactreasonstring may need updating.
No schema migration needed. The pkce_verifier column used by the
PKCE work was reserved in migrations/0001_init.sql since the
first alpha; existing databases already have it.
Added
- Boot-time diagnostic in
AppConfig::diagnosenow warns loudly on
two long-standing operator footguns:- CORS wildcard exposes cross-origin reads. When
security.cors_allowed_originscontains"*", TIM logs that
every unauthenticated read endpoint (/health,
/auth/providers, ...) is now reachable cross-origin. - HSTS + non-loopback bind without
preload. When bind is
not loopback andstrict_transport_securitylackspreload,
TIM names both facts in one line and points at
https://hstspreload.org. First-request MITM against
non-preloaded HSTS deployments leaks bearer tokens in the clear.
- CORS wildcard exposes cross-origin reads. When
src/oauth2/flow.rs— OAuth2 authorization requests now send a
per-requestcode_challenge(SHA-256 base64url-nopad) plus
code_challenge_method=S256per RFC 7636 (PKCE). The 32-byte
verifier is persisted alongsidestateinauth.oauth_state
and replayed on the token endpoint. Unblocks IdP registrations
that mandate PKCE (some TARA/Google/Microsoft clients) and
protects the authorization code against on-path interception on
registrations that permit non-PKCE.oauth2.providers.<id>.jwks_uri: Option<String>— pin the JWKS
URI expected in the discovery document. When set, TIM refuses
discovery whosejwks_uridiffers, closing the empty-JWKS DoS
path against a MITM'd discovery response. Default: unset (no
pin), preserving existing behaviour.POST /introspectnow supports optional Basic-auth client
authentication per RFC 7662 §2.1. Configured via a new
introspectionsection:introspection.required_client_auth: bool(default false for
backwards compatibility)introspection.clients: [{ client_id, client_secret_env }]
Secrets are compared constant-time (subtle::ConstantTimeEq).
When required, missing/wrong credentials → 401; the endpoint no
longer accepts every request against the denylist SELECT.
- New module
src/security/introspect_auth.rs+
IntrospectionGateboot resolver. Fails startup if any referenced
client_secret_envis unset when the gate is required.
Changed
src/oauth2/flow.rs,src/oauth2/state_sweeper.rs—auth.oauth_state
interval expressions rewritten as
now() - make_interval(secs => $N::int)instead of the string-concat-
then-cast form. Semantics identical (bind is still parameterised —
no injection path either way); the new form reads what it does.- OIDC discovery is now fail-closed on plain HTTP.
provider. discovery_urland endpoints inside the discovery document
(authorization_endpoint,token_endpoint,jwks_uri) must all
usehttps://or startup / login refuses. Operators intentionally
running against a non-TLS mock IdP for dev must set
oauth2.providers.<id>.allow_http_discovery: true. Closes MITM
substitution of the JWKS URI on the discovery fetch. src/security/session_auth.rs— the legacy?session_id=query
transport now emits WARN (was DEBUG). Operators grepping their
logs can identify remaining callers before removing the fallback.
Payload/behaviour otherwise unchanged.
Fixed
src/jwt/service.rs::validate— reason-code classification now
matches onjsonwebtoken::errors::ErrorKindvariants instead of
format!("{e}").contains("expired"). The prior pattern would have
silently reclassified every non-expiry error as
signature_mismatchon ajsonwebtokentext-format change,
hiding real bugs and breaking monitoring keyed on the reason
string. NewJwtSigner::verify_rawexposes the typed error so
classifier logic doesn't lose the kind through theTimError
wrapper.src/oauth2/session/postgres.rs—PostgresStore::getnow
filters expired rows in the SELECT (AND expires_at > now())
instead of doing a check-then-DELETE in Rust. Removes the
two-writer race where concurrent gets on an expiring session
both saw the row as expired and raced the DELETE (one won, the
other errored — visible as inconsistent 404/401 pairs). Expired
rows are now removed only bysweep_expired, which is already
scheduled by the state sweeper.
Testing
- New
tests/it_oauth_state_race.rspins the atomic single-use
contract onDELETE ... RETURNING: 32 concurrent callbacks with
the samestatevalue produce exactly one winner. Also asserts
that an aged-past-cap row cannot be consumed even before the
sweeper reaches it (closes the sweeper vs. consumer race).