fix: fail closed on an unwritable audit log, bound the rate limiter and harden startup
The audit logger is opened at startup (exit 2 on failure) and obtained before every call, which is refused with audit_unavailable otherwise. Audit records only take validated path and sudo values and use the request id as correlation id. The rate limiter evicts idle keys, caps tracked keys, audits the first excess per key and window and uses the settings passed to the app. FORWARDED_ALLOW_IPS is now a setting, and startup warns about a missing host allow-list and unavailable OAuth.
This commit is contained in:
1 parent
a3222d5ebe
commit
cf3d2e17d3
16 files changed
+532
-115
No files matched your search
+10
-3
@@ -34,6 +34,7 @@ client fails to parse the stream. Logs go to stderr; look at the client's MCP se
|
||||
| `redirect` | Gitea answered with a redirect, which is never followed. Use the final URL (for example https) as `GITEA_URL`. |
|
||||
| `payload_too_large` | The response is above `MAX_BINARY_BYTES`. Raise it or fetch a smaller object. |
|
||||
| `secret_blocked` | `SECRET_DETECTION_MODE=block` withheld a result containing secret-like content. Use `mask` if that is acceptable. |
|
||||
| `audit_unavailable` | The audit log could not be opened, so the call was refused before it reached Gitea. Fix the permissions of `AUDIT_LOG_PATH` (or `DATA_DIR`) and restart. |
|
||||
| `rate_limited` (429) | Gitea or this server's `RATE_LIMIT_PER_MINUTE` limit. |
|
||||
|
||||
A result with a `truncated` object was cut to `MAX_TOOL_RESPONSE_ITEMS` or
|
||||
@@ -48,9 +49,15 @@ A tool the client cannot see is probably filtered by `TOOLSETS`, `READ_ONLY` or
|
||||
10 seconds). Fix connectivity from the server's host.
|
||||
- 401 on `/mcp`: no or wrong bearer token, and no valid OAuth token. The response has a
|
||||
`WWW-Authenticate` header that points clients to the OAuth metadata.
|
||||
- Request rejected with an invalid Host: the name you used is not allowed. Add it to
|
||||
`ALLOWED_HOSTS` or set `PUBLIC_BASE_URL`.
|
||||
- 429: the client exceeded `RATE_LIMIT_PER_MINUTE`.
|
||||
- Request rejected with an invalid Host (421): the name you used is not allowed. Add it to
|
||||
`ALLOWED_HOSTS` or set `PUBLIC_BASE_URL`. With a non-loopback `MCP_HOST` and neither variable
|
||||
the server prints a warning at startup that says so.
|
||||
- 429: the client exceeded `RATE_LIMIT_PER_MINUTE`. If every client seems to share one limit,
|
||||
the proxy address is not in `FORWARDED_ALLOW_IPS`, so all requests look like they come from
|
||||
the proxy.
|
||||
- The server exits with code 2 and "cannot open the audit log": the audit file or its directory
|
||||
is not writable. Fix the permissions, or point `AUDIT_LOG_PATH` or `DATA_DIR` at a writable
|
||||
location (in Docker, check the volume ownership). The server never runs without an audit log.
|
||||
- Responses arrive in one chunk or time out behind nginx: set `proxy_buffering off;`.
|
||||
|
||||
## OAuth sign-in
|
||||
|
||||
Reference in new issue
Block a user