Skip to content

Commit 90ded74

Browse files
Ambient Code Botclaude
andcommitted
fix(api-server): deny empty-username callers in WatchSessionMessages
Non-service callers with an empty username previously skipped ownership checks, allowing unauthenticated access to arbitrary session streams. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 764077b commit 90ded74

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

components/ambient-api-server/plugins/sessions/grpc_handler.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,10 @@ func (h *sessionGRPCHandler) WatchSessionMessages(req *pb.WatchSessionMessagesRe
288288

289289
if !middleware.IsServiceCaller(ctx) {
290290
username := auth.GetUsernameFromContext(ctx)
291-
if username != "" && (h.grpcServiceAccount == "" || username != h.grpcServiceAccount) {
291+
if username == "" {
292+
return status.Error(codes.PermissionDenied, "not authorized to watch this session")
293+
}
294+
if h.grpcServiceAccount == "" || username != h.grpcServiceAccount {
292295
session, svcErr := h.service.Get(ctx, req.GetSessionId())
293296
if svcErr != nil {
294297
return grpcutil.ServiceErrorToGRPC(svcErr)

0 commit comments

Comments
 (0)