Skip to content

DELETE /api/plugins/grants accepts whitespace ref/agentId and reports ok:true without deleting anything #495

Description

@Ayush7614

What

DELETE /api/plugins/grants in server/src/plugins/routes.ts:803-812 checks if (!kind || !ref || !agentId).

Query params are always strings, and " " is truthy, so DELETE /grants?kind=mcp&ref=%20%20&agentId=%20%20 skips the 400, calls store.revoke with whitespace, deletes zero rows (exact-match delete), still writes a plugin_revoked audit row naming whitespace, and answers 200 {ok:true}.

The twin POST /grants on the same file (lines 778-784) already does typeof === "string" && .trim() → 400 with "A kind, a ref and a Bot are required.".

Repro

  1. DELETE /api/plugins/grants?kind=mcp&ref=%20%20&agentId=bot-1 → 200 ok:true, zero rows deleted, junk audit row.
  2. Same with whitespace agentId.

Expected: 400 with the same message as POST, no DB delete, no audit row.

Where it runs

Stateless request validation in the server process. Same 400 on every replica; the existing revoke path (exact-match delete + audit row) is unchanged for valid input.

Fix sketch

Trim-check ref/agentId on DELETE like POST does, pass trimmed values to enablementRefusal/revoke. Add route tests: whitespace ref/agentId → 400 + store never called; valid still 200.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions