Commit Graph
1 Commits
Author SHA1 Message Date
openwaf-agent ac672d9908 A write endpoint dropped a parameter it never implemented and changed state anyway
OPEN-33 put a guard on the read listings. The image that carried it then
answered the same request two different ways depending on the verb:

  GET    /admin-api/blocks?zzz=1                    -> 400, names 'zzz'
  POST   /admin-api/blocks?zzz=1                    -> 204, ban written
  PUT    /admin-api/policy?zzz=1                    -> 200, policy changed
  PUT    /admin-api/countries/DE?allowed=true&zzz=1 -> 204
  DELETE /admin-api/blocks?key=...&zzz=1            -> 200 {"deleted":1}
  GET    /admin-api/countries?limit=2               -> 200, every row

The silent half was the half that changes state. A misspelled scoping
parameter on a write acts with a wider scope than the caller meant, and
answers as if the scope had applied.

The guard now covers every endpoint under /admin-api, and it runs before
any state change, so a rejected write cannot half-happen. The last line
above changed the design: the guard used to assume limit/offset were
always legal, which is the same bug one level down -- /countries has no
paging to honour, so ?limit=2 was accepted, dropped, and answered with
the whole table. Each endpoint now declares its own parameter surface
and the base set is only `token`, the one parameter real for every
endpoint because the auth layer reads it (OPEN-16).

Teeth: WriteQueryGuardTests (29) asserts the 400 per endpoint, that the
refusal names the parameter that was actually sent, that a refused write
changes nothing (block, policy, country rule), that the same request
without the unknown parameter is still served, and that ?token= still
works on a write. The compose gate grew a scene (8 assertions) that runs
the same measurements against the shipped image.

Measured on this tree: unit 128/128, integration 170/170, smoke 28/0,
compose 94/0 (enforcement lag 11 ms on Linux), console 58/0, image 261
MB. Linux rehearsal: all three stages PASS. act: 5 jobs succeeded, 0
failed, console-evidence.zip 534721 bytes.
2026-10-02 12:08:02 +02:00