Appendix B: Error catalog
What this appendix is for: You have an error message and are looking for a place to start. Each entry tells you how the problem shows up, where the actual reason is written, what the cause was and how it was fixed. All entries come from the diagnosis tasks, challenges and drills of this course. The messages are the ones from the lab. The days in parentheses lead to the full solution path.
One rule applies to almost every entry: The door says little,
the issuer says more. A service deliberately answers tersely
(401, invalid_client); the issuer writes the
reason into its own log – the API server into the journal of
k3s, Keycloak into the journal of keycloak,
the SPIRE agent into its pod log.
Overview
| No. | Message (excerpt) | Cause | Day |
|---|---|---|---|
| B1 | open /etc/rancher/k3s/k3s.yaml: permission denied |
own kubeconfig missing | 0 |
| B2 | Burglar keeps logging in after the “rotation” | only the Secret changed, not the password in the database | 1 |
| B3 | 401 Unauthorized at the API server with a fresh
token |
token for a different audience | 2 |
| B4 | validation failed: invalid issuer claim (iss) |
token issued before the issuer was changed | 3 |
| B5 | invalid_client after reworking
keycloak.conf |
Keycloak no longer trusts the API server’s CA | 4 |
| B6 | agent.sock: connect: no such file or directory |
SPIRE agent not registered: wrong audience | 5 |
| B7 | PermissionDenied desc = no identity issued |
selector misspelled | 6 |
| B8 | invalid principal, or principal not allowed |
wrong SPIFFE ID in --verify-uri |
7 |
| B9 | certificate signed by unknown authority after agent
restart |
outdated bootstrap bundle | 8 |
| B10 | Token verification failed after five minutes |
access token expired | 9 |
| B11 | 401 … Audience doesn't match at the warehouse |
audience mapper missing | 10 |
| B12 | Client is not within the token audience during
exchange |
token issued for a different client | 11 |
| B13 | 403 … Bereich lager:lesen fehlt after the switch |
scopes optional, old client requests none | 12 |
| B14 | 401 … Signature has expired after the confirmation
prompt |
token fetched before the confirmation | 12 |
| B15 | 401 … Audience doesn't match at the MCP server despite
resource |
Keycloak ignores resource |
13 |
| B16 | 400 … nur Protokollversion 2026-07-28 |
MCP header or _meta missing |
13 |
| B17 | ServiceAccount deleted, Keycloak keeps issuing tokens | Keycloak checks Kubernetes badges offline | 14 |
| B18 | curl reports 000 at the tool desk |
failed exchange not caught | 14 |
| B19 | Login missing from the journal | success events only in the database | 15 |
| B20 | Leak continues after a new secret | issued token with a long lifetime | 16 |
The entries
B1 – kubectl may not read the kubeconfig
- Message:
error loading config file "/etc/rancher/k3s/k3s.yaml": open /etc/rancher/k3s/k3s.yaml: permission denied, together with the advice to start k3s with--write-kubeconfig-mode. - Narrowing it down:
sudo ls -l /etc/rancher/k3s/k3s.yamlshows-rw------- root root. - Cause: You are working as
ubuntu; your own copy andKUBECONFIGare missing. - Fix: copy with
sudo install -m 600 -o ubuntu -g ubuntuto~/.kube/config,KUBECONFIGin~/.bashrc. Do not follow the advice: mode644turns every account on the machine into a cluster administrator. (Day 0)
B2 – Rotation without effect
- Message: After
kubectl applywith a new password the burglar keeps logging in, while the till gets login errors. - Narrowing it down: test the old password with a
test pod (
psql … select 1); in the running container,crictl inspect– the environment contains the old password. - Cause: The PostgreSQL image sets
POSTGRES_PASSWORDonly on the first initialization. After that the Secret is just a copy; environment variables apply from the moment a container starts. - Fix: first
ALTER USER … PASSWORDin the database, then the Secret, then restart all users. Better: replace static passwords with identities (Day 2 onwards). (Day 1)
B3 – 401 at the API server with a fresh token
- Message:
"message": "Unauthorized", "code": 401. - Narrowing it down:
sudo journalctl -u k3s --grep "Unable to authenticate"→token audiences ["lager"] is invalid for the target audiences [...]. - Cause: The projected token has
audience: lager; the API server only accepts its own audiences. - Fix: a second projected token without
audiencefor the API server – or none at all if the application does not need the API server. (Day 2)
B4 – invalid issuer claim
- Message:
validation failed: invalid issuer claim (iss)during the offline check withstep. - Narrowing it down:
step crypto jwt inspect --insecureshows the old issuerhttps://kubernetes.default.svc.cluster.local. - Cause: The token dates from before the switch to the new issuer name. The API server accepts both, the service only the new one.
- Fix: wait one token lifetime (the kubelet renews
projected tokens), then remove the old name from
config.yaml. As a transition, a service may accept both, never permanently. (Day 3)
B5 – invalid_client after tidying up the Keycloak configuration
- Message:
{"error":"invalid_client","error_description":"Invalid client or Invalid client credentials"}. - Narrowing it down:
sudo journalctl -u keycloak --grep "Failed to load"→Failed to load public keys for Kubernetes IdP 'cluster' … PKIX path building failed. - Cause: The
truststore-pathsline is missing fromkeycloak.conf; Java does not know the API server’s CA and cannot fetch the JWKS. - Fix: add the line back, restart Keycloak. (Day 4)
B6 – The SPIRE agent’s socket is missing
- Message:
dial unix /run/spire/sockets/agent.sock: connect: no such file or directory, even though the agent pod is1/1 Running. - Narrowing it down:
kubectl logs -n spire daemonset/spire-agent→token audiences ["spire"] is invalid for the target audiences ["spire-server"]. - Cause: The audience of the agent’s badge was
changed in the DaemonSet; the server expects
spire-server. Without its own badge the agent does not create a socket. - Fix: set
audience: spire-serverback,kubectl apply. A probe on the health endpoint would have shown the error immediately. (Day 5)
B7 – no identity issued
- Message:
rpc error: code = PermissionDenied desc = no identity issued. - Narrowing it down: log of the agent on the pod’s
node →
PID attested to have selectorswithsa:inventur; the entry requiresserviceaccount:inventur. - Cause: The selector
k8s:serviceaccount:does not exist. SPIRE creates the entry anyway, without a warning. - Fix:
spire-server entry updatewith all settings and-selector k8s:sa:inventur. Copy selectors from the agent log, not from memory. (Day 6)
B8 – principal not allowed
- Message:
curl: (56) Recv failure: Connection reset by peer; in the client’s tunnelerror on dial: unauthorized: invalid principal, or principal not allowed. - Narrowing it down: The server only reports
remote error: tls: bad certificate– it rejected nothing.grep verify-uriin the pod file shows the wrong SPIFFE ID. - Cause: The client expects
…/laden/lager, but the server is called…/laden/lager-api. - Fix: correct
--verify-uri, recreate the pod.error on dialmeans: the client rejected the server. (Day 7)
B9 – Agent does not start after CA rotation
- Message: Agent
1/1 Running, but not registered; the log showsx509: certificate signed by unknown authorityandTrust Bundle and Server don't agree. - Cause: A newly starting agent
reads the bootstrap bundle from the ConfigMap
spire-bundle, and that dates from before the rotation. Running agents received the new bundle over their connection. - Fix: recreate the ConfigMap with the current bundle
(
kubectl delete configmap+kubectl create configmap --from-file). Update it after every rotation. (Day 8)
B10 – Token verification failed after five minutes
- Message:
401withWWW-Authenticate: Bearer … error="invalid_token", error_description="Token verification failed". - Narrowing it down:
sudo journalctl -u keycloak --grep "error="→USER_INFO_REQUEST_ERROR … reason="Token is not active";expin the token lies in the past. - Cause: The access token is valid for five minutes – that is intended.
- Fix: The program renews the token with the refresh
token (
grant_type=refresh_token) instead of making the human log in again. (Day 9)
B11 – Audience doesn’t match at the warehouse
- Message:
[Lager] 401 {"fehler": "Schein ungültig: Audience doesn't match"}, followed by a summary from the model that talks about the “delivery note”. - Narrowing it down: never read the model’s summary,
read the
[Lager]line. A fresh token withstep crypto jwt inspect→"aud": "account", nolager. - Cause: The mapper
tuer-lageron the client is missing. - Fix: create the mapper again
(
oidc-audience-mapper,included.custom.audience=lager). (Day 10)
B12 – Client is not within the token audience
- Message:
[Empfang] 403 {'error': 'access_denied', 'error_description': 'Client is not within the token audience'}. - Narrowing it down:
sudo journalctl -u keycloak --grep TOKEN_EXCHANGE_ERROR→subject_token_client_id="ladenkasse-cli"; in the token"aud": "account". - Cause: The token was issued for the shop till, not
for the assistant. Keycloak only exchanges tokens whose
audcontains the requesting client. - Fix: Anna logs in to the assistant
(
assistent-cli). Do not give every client a mapper for the assistant. (Day 11)
B13 – Scope missing after the switch to optional scopes
- Message:
[Lager] 403 {"fehler": "Bereich lager:lesen fehlt"}with an assistant that still worked yesterday. - Cause: The warehouse scopes are now only optional
on the client; the old assistant sends no
scopeduring the exchange and getsprofile email. - Fix: use the assistant that requests the scope per tool – do not push the scopes back into the default list. (Day 12)
B14 – Signature has expired after the confirmation prompt
- Message:
[Lager] 401 {"fehler": "Schein ungültig: Signature has expired"}when the human confirms the prompt only after 100 seconds. - Cause: The pass with a 60-second lifetime was exchanged before the confirmation prompt.
- Fix: ask first, then exchange (assistant v5). (Day 12)
B15 – Audience doesn’t match at the MCP server despite resource
- Message:
401witherror="invalid_token", error_description="Audience doesn't match", even thoughresource=http://172.16.0.126:8091/mcpwas sent along. - Narrowing it down: In the token
"aud": ["assistent", "account"],"azp": "assistent-cli". - Cause: Keycloak ignores the
resourceparameter (RFC 8707); the audience comes solely from the mappers of the client you log in to. - Fix: log in to
mcp-cli, whose mapper writes the MCP server intoaud. (Day 13)
B16 – MCP server rejects the request with 400
- Message:
400with JSON-RPC error-32602“nur Protokollversion 2026-07-28”. - Cause: The stateless MCP version 2026-07-28
requires, in every request, the header
MCP-Protocol-Versionand, inparams._meta, the keyio.modelcontextprotocol/protocolVersion. - Fix: send both. (Day 13)
B17 – ServiceAccount deleted, Keycloak keeps issuing tokens
- Message: none. The attacker with the stolen badge keeps getting tokens.
- Narrowing it down: TokenReview reports
not foundafter about 13 seconds, but Keycloak still accepts the badge. - Cause: Keycloak checks the Kubernetes badge offline against the cluster’s JWKS, not via TokenReview.
- Fix: disable the client
(
enabled=false). When rebuilding, use a new identity (new ServiceAccount, adjustjwt.credential.sub); a new ServiceAccount with the same name makes the old badge valid at Keycloak again. (Day 14)
B18 – curl reports 000 at the tool desk
- Message:
curlprints status000, no response. - Narrowing it down:
journalctl -u lager-mcp→ traceback withurllib.error.HTTPError: HTTP Error 400inlagerschein; Keycloak:TOKEN_EXCHANGE_ERROR … reason="subject_token validation failure". - Cause: Anna’s session was ended, the exchange fails, and nobody catches the exception.
- Fix: catch the failed exchange and answer with
401 invalid_token(mcp_lager v2). (Day 14)
B19 – The login is not in the journal
- Message:
journalctl -u keycloak --grep 'type="LOGIN"'finds nothing. - Cause: The
jboss-logginglistener writes success events only at leveldebug. The stored events are in the database. - Fix: use
kcadm.sh get events; if you need successes in the journal, set--spi-events-listener--jboss-logging--success-level=infoat startup. (Day 15)
B20 – The leak stays open after the new secret
- Message: After a new client secret and reduced rights, the same client keeps checking out goods.
- Narrowing it down: In the warehouse’s visitor log
the same
jtifor every checkout; in the Keycloak events only oneCLIENT_LOGINwith exactly thistoken_id; the client’saccess.token.lifespanis 900. - Cause: The issued token carries its rights and expiry time, signed, inside itself; the warehouse checks offline. Secret, scopes and roles only affect new tokens.
- Fix: wait out the remaining lifetime or have the service block it specifically; in future, short lifetimes, rights only as needed, badge instead of secret. (Day 16)