Refuse a query string on every route
Breaking: every route now answers a request with a query string with 400 invalid_query, where all but the module routes used to ignore it. A caller must drop the query string and send any input in the JSON body. No route takes an input from the query any more, now that the module routes take copies and printer in the JSON body. The other routes ignored a query, so a caller that sent one had it dropped without a word: an old module caller's ?copies=2 on another route, or a typo. The refusal's message is "query parameters are not accepted". The check runs after routing and, under /api/v1, after the token, the rate limit and the token's scope, so an unknown route still answers 404 and a token sent only in the query still 401. A bare question mark is no query. The OpenAPI document lists invalid_query on every route, and a route's parameters can no longer be in the query. Nothing that ships with the daemon sends it a query: the install, the Docker image and the ntfy recipes post bodies or read /healthz plainly. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
9e829bfce7
commit
6bfaee0bc8
8 files changed
+212
-33
No files matched your search
+6
-3
@@ -29,6 +29,11 @@ tokens with `uberbringer token`. Tokens created by the old install script keep
|
||||
working as long as the secret is unchanged. Tokens in query strings are not
|
||||
accepted, because they leak into proxy logs.
|
||||
|
||||
No route takes a query string: every input goes in the JSON body, and the
|
||||
path holds only a resource's ID or a fixed word. A request with a query
|
||||
string gets `400` `invalid_query`. Under `/api/v1` the token and its scope
|
||||
are checked first, so a token sent only in the query still gets `401`.
|
||||
|
||||
Keep a token off command lines too, where other users of the machine can
|
||||
read it. The examples here send the header from a file only you can read,
|
||||
which curl 7.55 and later take as `-H @file`;
|
||||
@@ -302,7 +307,7 @@ Errors are JSON:
|
||||
|--------|--------|---------|
|
||||
| 400 | `invalid_job` | Malformed JSON, an unknown field, trailing data after the job, or invalid elements. When elements are invalid, `details` lists every problem. A `{"data": [...]}` body gets a message pointing to the [element format](#elements) |
|
||||
| 400 | `invalid_payload` | A [module](#modules) route's body or payload that is not a JSON object, has an unknown field or a field of the wrong type, or is invalid, e.g. `invalid payload for module "note"`, or a body whose `copies` is outside 1–5. `details` lists every problem |
|
||||
| 400 | `invalid_query` | On a module route: the request has a query string. Every input goes in the JSON body |
|
||||
| 400 | `invalid_query` | The request has a query string, on any route. Every input goes in the JSON body |
|
||||
| 400 | `unknown_printer` | On a module route: `printer` names a printer other than `default` |
|
||||
| 400 | `bad_request` | A malformed HTTP request, refused by the server itself |
|
||||
| 401 | `unauthorized` | `missing bearer token`, or `invalid or expired token`. Sent with `WWW-Authenticate` |
|
||||
@@ -658,8 +663,6 @@ job and a `Location` header, or `503` when the queue is full or closing.
|
||||
ntfy's messages as they are and ignores the fields it does not know.
|
||||
- `400` `unknown_printer` means `printer` names a printer other than
|
||||
`default`.
|
||||
- `400` `invalid_query` means the request has a query string: every input
|
||||
goes in the body.
|
||||
- `404` `module_not_found` names an unknown module.
|
||||
- `422` `module_failed` means the module built a receipt that fails
|
||||
validation. That is a bug in the module, and it is logged.
|
||||
|
||||
Reference in new issue
Block a user