fix(agent): fail closed when user role cannot be resolved

A userId that is not a team member previously resolved to isOwner=true
(role === undefined || role === 'owner'), bypassing bash restrictions.
Treat only flows without a user context (autofill etc.) and explicit
owner memberships as unrestricted; unknown users are now restricted.
This commit is contained in:
yiling
2026-08-04 16:26:16 +08:00
parent c938e84ccc
commit dd2f8e68d9
2 changed files with 21 additions and 4 deletions
+4 -2
View File
@@ -234,9 +234,11 @@ export async function createAgentSession(params: CreateAgentSessionParams) {
Object.assign(skillEnvs, envs)
}
// Resolve the requesting user's team role to enforce owner-only bash privileges
// Resolve the requesting user's team role to enforce owner-only bash privileges.
// A user who is not a member of the team is treated as restricted (fail-closed),
// while flows without a user context (e.g. autofill) remain unrestricted.
const role = await resolveTeamMemberRole(teamId, userId)
const isOwner = role === undefined || role === 'owner'
const isOwner = !userId || role === 'owner'
const restricted = !isOwner
// Restore env variables from previously loaded skills in this session