Skip to content

bug: deleting one A2A endpoint can remove two, destroying a stored credential #2174

Closed

Description

@vybe

Summary

remove_endpoint(ref) in src/backend/services/a2a_outbound.py filters out every record whose id or name matches the reference:

keep = [
    r for r in records
    if str(r.get("id") or "") != wanted
    and str(r.get("name") or "").lower() != lowered
]

Nothing enforces uniqueness across those two namespaces, and endpoint ids are visible in the admin GET /api/settings/a2a-endpoints response. So an operator who has named one endpoint after another endpoint's id can issue a single-target DELETE /api/settings/a2a-endpoints/{ref} and silently destroy two endpoints — along with their AES-256-GCM-encrypted credentials — while the route's own docstring says "Remove one registered outbound A2A endpoint by id or name" and the function returns a single True.

Context

Found by an /edge-cases sweep of the #736 A2A outbound path. This is the cross-namespace-collision class the tracker has hit before (#1631 operator-queue ids: uniqueness assumed globally but enforced per-agent).

The blast radius is what makes it worth fixing rather than documenting: the destroyed record's credential is a partner secret the operator may not still have a copy of, and the deletion is reported as success, so there is no signal to re-check. The next call against the collaterally-deleted endpoint fails with endpoint_not_found, which reads as a registration problem rather than a deletion.

upsert_endpoint enforces case-insensitive uniqueness on name only; it never checks a proposed name against existing ids, so creating the collision is a normal, permitted operation.

Reproduction

alpha = upsert_endpoint("alpha", url, "alpha-secret")     # -> id a2aep_<hex12>
        upsert_endpoint("beta",  url, "beta-secret")
        upsert_endpoint(alpha["id"], url, "gamma-secret") # legal: name == alpha's id

list_oss_endpoints()          -> ['alpha', 'beta', 'a2aep_<hex12>']   (3)
remove_endpoint(alpha["id"])  -> True
list_oss_endpoints()          -> ['beta']                             (1)   <-- two gone

Acceptance Criteria

  • remove_endpoint(ref) removes at most one record per call
  • With an id/name collision present, removing by id removes the id-matched record and leaves the name-matched one intact (resolution order is documented and the delete agrees with resolve_endpoint, which returns the first match)
  • remove_endpoint still returns False on a genuine miss and for an empty/whitespace ref
  • Removing by name still works for the ordinary no-collision case
  • The strict-xfail on tests/unit/test_736_a2a_outbound_edges.py::test_G7_removing_one_endpoint_removes_exactly_one_endpoint is removed and the test passes plainly

Technical Notes

Two candidate shapes, and they are not equivalent — pick deliberately:

  1. Remove the first match only, mirroring resolve_endpoint's first-match-wins semantics. This keeps delete and resolve consistent: whatever a ref resolves to is what it deletes. Preferred.
  2. Refuse an ambiguous ref (400/409, naming both candidates). Safer, but introduces a state the operator can reach and cannot exit without renaming, so it needs a rename path to be usable.

Worth considering alongside: upsert_endpoint could reject a name that collides with an existing id, which removes the ambiguity at the source. That is a separate, additive guard — it does not fix already-stored collisions, so it is not a substitute for fixing the delete.

Related: the same sweep found upsert_endpoint treats a whitespace-only credential as "clear" while None and "" mean "leave unchanged" — filed separately with the other low-severity findings.

Activity

  1. added
    priority-p2
    type-bug
    theme-security
    status-ready
    on Aug 14, 2026
  2. added
    status-in-progress
    and removed
    status-ready
    on Aug 14, 2026
  3. self-assigned this
    on Aug 14, 2026
  4. dolho commented on Aug 14, 2026

    @dolho
    Contributor

    /claim — picking this up. Branch: fix/2174-a2a-delete-one-endpoint.

  5. github-actions commented on Aug 14, 2026

    @github-actions

    @dolho This issue is already assigned to dolho. Use /unclaim first if you want to take over.

  6. dolho commented on Aug 14, 2026

    @dolho
    Contributor

    PR: #2177 (targets dev).

    Took Technical Notes option 1 (first-match-wins, shared predicate with resolve_endpoint) plus the additive create-time guard — a new endpoint may not be named after an existing id (422), create path only so an already-stored collision stays editable and removable.

    One deviation from the AC worth flagging: tests/unit/test_736_a2a_outbound_edges.py does not exist on dev — git log -S finds it in no branch or commit, so the /edge-cases sweep's file never landed. There was no strict-xfail to remove; the file is created in this PR with test_G7_removing_one_endpoint_removes_exactly_one_endpoint passing plainly, plus 16 sibling cases.

    Verified live: through the real admin API, 3 endpoints + one DELETE left 1 (gamma-secret destroyed, {"success": true}); the same store on the branch resolves the ref to alpha, removes alpha only (3 → 2), and the collided record survives with its credential.

  7. added
    status-in-dev
    and removed
    status-in-progress
    on Aug 14, 2026
  8. removed
    status-in-dev
    on Aug 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

priority-p2theme-securitytype-bug

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions