Skip to content

Commit 2f31554

Browse files
author
邝谧
committed
fix(push): add cross-tenant ownership check to DeleteAll + clean up owners map
DeleteAll previously had no ownership verification, allowing any caller to delete arbitrary task push configs — a cross-tenant isolation bypass. Changes: - DeleteAll now calls checkOwner (same pattern as Delete) and returns ErrTaskNotFound for cross-tenant access or nil for never-saved tasks. - DeleteAll now cleans up s.owners[taskID] to prevent stale owner entries after all configs are removed. - CrossTenantIsolation test extended to cover DeleteAll.
1 parent 6492d4f commit 2f31554

2 files changed

Lines changed: 13 additions & 1 deletion

File tree

a2asrv/push/store.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,10 +220,19 @@ func (s *InMemoryPushConfigStore) Delete(ctx context.Context, taskID a2a.TaskID,
220220
return nil
221221
}
222222

223-
// DeleteAll removes all stored configs for a task.
223+
// DeleteAll removes all stored configs for a task owned by the caller.
224224
func (s *InMemoryPushConfigStore) DeleteAll(ctx context.Context, taskID a2a.TaskID) error {
225225
s.mu.Lock()
226226
defer s.mu.Unlock()
227+
228+
if err := s.checkOwner(ctx, taskID); err != nil {
229+
if errors.Is(err, errNoOwner) {
230+
return nil // idempotent — task never existed
231+
}
232+
return err
233+
}
234+
227235
delete(s.configs, taskID)
236+
delete(s.owners, taskID)
228237
return nil
229238
}

a2asrv/push/store_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -479,6 +479,9 @@ func TestInMemoryPushConfigStore_CrossTenantIsolation(t *testing.T) {
479479
if err := store.Delete(bobCtx, taskID, cfg.ID); err == nil {
480480
t.Fatal("bob Delete should have failed with cross-tenant access")
481481
}
482+
if err := store.DeleteAll(bobCtx, taskID); err == nil {
483+
t.Fatal("bob DeleteAll should have failed with cross-tenant access")
484+
}
482485

483486
// Alice can still access her own configs.
484487
got, err := store.Get(aliceCtx, taskID, cfg.ID)

0 commit comments

Comments
 (0)