Skip to content

fix(auth): RevokeAuthorityOverrideAsync ignores action parameter and may revoke wrong override #399

@github-actions

Description

@github-actions

Summary

IAuthorityPort.RevokeAuthorityOverrideAsync in AuthorityService queries AuthorityOverrides by AgentId/TenantId/IsActive but ignores the action parameter and calls FirstOrDefaultAsync(). When multiple active override rows exist for the same agent/tenant, this can revoke an unrelated or already-expired override, leaving the requested elevated permission in place.

Affected file

src/BusinessApplications/AgentRegistry/Services/AuthorityService.cs — lines 745-760

Required fix

Add action to the LINQ filter and choose deterministically:

var activeOverride = (await _dbContext.AuthorityOverrides
    .Where(o => o.AgentId == agentId
             && o.TenantId == tenantId
             && o.IsActive
             && o.ExpiresAt > DateTimeOffset.UtcNow)
    .OrderByDescending(o => o.CreatedAt)
    .ToListAsync())
    .FirstOrDefault(o => o.OverrideScope?.AllowedApiEndpoints?.Contains(action) == true);

References

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions