[BUG] selector selectByIdSet/deleteByIds omit namespace_id — cross-namespace selector delete (+ cascade)
- Dominant language
- Java
- Stars
- 8.8k
- Forks
- 3.1k
- Avg merge
- 7d 1h
- Merged PRs (30d)
- 85
Description
## Description
`SelectorServiceImpl.deleteByNamespaceId(List ids, String namespaceId)` calls `selectorMapper.selectByIdSet(new TreeSet<>(ids))` whose SQL is `WHERE id IN (...)` with no `namespace_id`, and the eventual `deleteByIds` is `DELETE FROM selector WHERE id IN (...)`. `namespaceId` is passed only to event publishing, never to SELECT or DELETE. Sibling `selectByQuery`/`updateSelective` enforce `namespace_id`, confirming bug.
Controller-exposed at `SelectorController:155`. The fetched selectors (unfiltered by namespace) also drive `unbindDiscovery` and the downstream `BatchSelectorDeletedEvent` rule cleanup, amplifying blast radius.
## Location
- `shenyu-admin/src/main/java/org/apache/shenyu/admin/service/impl/SelectorServiceImpl.java:297-303,633-636`
- `shenyu-admin/src/main/resources/mappers/selector-sqlmap.xml:80-88` (`selectByIdSet`), `465-471` (`deleteByIds`)
- `shenyu-admin/src/main/java/org/apache/shenyu/admin/controller/SelectorController.java:152-156`
## Impact
Cross-namespace selector deletion (and cascade unbindDiscovery/deleteSelector) — a user can tear down selectors in another namespace, removing routing configuration and bound discovery bindings. Requires authenticated admin with `system:plugin:delete`.
## Suggested fix
Add `AND namespace_id = #{namespaceId}` to `selectByIdSet` and `deleteByIds`, or filter ids via a namespace-scoped select first.
## Related existing
Distinct from H-2 (rule) and N2 (#6615) — different mapper file and operation.
Contributor guide
No contributing guide indexed for this repository
Research direction
Start at SelectorController.java:152-156 and trace SelectorServiceImpl.java:297-303 and 633-636 into selector-sqlmap.xml entries 80-88 and 465-471. Verify that selector lookup and deletion remain namespace-scoped, including the unbindDiscovery and BatchSelectorDeletedEvent cleanup paths. Done means an authenticated deletion cannot affect selectors or bindings outside the requested namespace.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, sql
- Domain
- api, backend, database, security
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Active
- Clarity
- Clearly specified
- Newbie friendliness
- 72/100