Skip to content

Commit 8b856fa

Browse files
Gkrumbach07claude
andcommitted
fix(backend): use backend SA for runner secret validation
The CreateSession handler was using the caller's K8s client (reqK8s) to validate ambient-runner-secrets exists. Session ServiceAccounts created by the operator only have agenticsessions CRD permissions, not secret-read permission, causing 500 errors when sessions try to create other sessions via backend tools. Switch to the backend's own service account (K8sClient) for this validation check. This is safe because: - The check is a pre-flight validation, not a user-scoped operation - The operator also uses its own SA for the same check (line 661) - Session SA permissions are intentionally minimal (least-privilege) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent df0003d commit 8b856fa

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

components/backend/handlers/sessions.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -616,7 +616,9 @@ func CreateSession(c *gin.Context) {
616616

617617
// Always verify the runner secrets exist (even if registry is unavailable
618618
// and requiredKeys is nil — prevents sessions without any API keys).
619-
sec, err := reqK8s.CoreV1().Secrets(project).Get(c.Request.Context(), runnerSecretsName, v1.GetOptions{})
619+
// Use the backend's own service account (K8sClient) rather than the
620+
// caller's token — session ServiceAccounts lack secret-read permission.
621+
sec, err := K8sClient.CoreV1().Secrets(project).Get(c.Request.Context(), runnerSecretsName, v1.GetOptions{})
620622
if err != nil {
621623
if errors.IsNotFound(err) {
622624
log.Printf("Session creation blocked: %s secret missing in project %s", runnerSecretsName, project)

0 commit comments

Comments
 (0)