浏览代码

docs: /fn is unauthenticated AND unthrottled, and the policy field that looks like it covers that does not

fszontagh 1 月之前
父节点
当前提交
356fee0450
共有 1 个文件被更改,包括 2 次插入 和 0 次删除
  1. 2 0
      CLAUDE.md

+ 2 - 0
CLAUDE.md

@@ -82,6 +82,8 @@ docker run -d --name svapi-dev -p 8080:8080 -e SMARTBOTIC_VECTORAPI_KEY=dev svap
 - `builtinDefaultFunctionPolicy()` grants **nothing**: unreviewed code reaches no collection until an admin says so. Widening it is a security-posture change, and a test asserts the current floor.
 - **Descriptor parsing never throws** (`functions/descriptor.hpp`, pure): a script author's typo is data. Unknown keys are ignored so a script written for a later server still loads. 404 and 405 stay distinct, so a 405 can carry its `Allow:` union.
 - **Routes:** functions are managed at `/api/v1/projects/{p}/functions*` (project-manage; **policy is admin-only**) and served to the world at **`/fn/{project}/*`**, which is **unauthenticated** - the project segment is therefore hostile input: charset-restricted (no `:`, the `qualify()` separator), confirmed against `listProjects()` before anything qualifies a collection, and a `..` segment is refused anywhere (httplib percent-decodes before the handler sees the path, and `..` can be captured by a `:name` param). Disabled and invalid functions are absent from the descriptor list, so they 404 rather than 403, and function error text never reaches the caller - it goes to the run log, with the `run_id` in the response.
+- **`/fn` IS UNAUTHENTICATED *AND* UNTHROTTLED, AND THE SECOND HALF SURPRISES PEOPLE WHO READ THE FIRST.** Verified in code 2026-10-13, prompted by a consumer asking how to send a verification e-mail: `function_dispatch.cpp` never touches `rateLimiter()`, and the policy's `rate_limit_per_min` is enforced only inside `requireCapabilityCore` - that is, on the function's DATA access through `ctx.collections`. **`ctx.mail` and `ctx.fetch` are outside the policy entirely** (a function with `rules: []` can still send mail, which is recorded above as a deliberate decision). So a published function that sends mail or makes an outbound call is reachable by anyone who learns the URL, with no per-function ceiling: an e-mail bomb aimed at any address, on the tenant's SMTP quota and sender reputation, or a paid API burned.
+  The unauthenticated part is a design decision and still right - a published HTTP function is published. **The unthrottled part is not a decision, it is a gap**, and the field that looks like it covers it does not. I believed it did when I started answering. See task #77; the lean is to honour `rate_limit_per_min` on `/fn`, because a consumer reading the policy vocabulary will assume it already applies and will not test that assumption. Until then the only protection is the tenant's own: a secret header the function checks itself, or no HTTP trigger at all - a `db`-triggered function behind an `insert` grant has no public endpoint to abuse.
 - **A write is validated on a runner before storage**, so the engine that validates is the engine that executes; with no healthy runner the write is refused **503** rather than stored unchecked.
 - **`RunnerPool` retry is three-way, not two.** Never connected → retry (nothing ran). Answered, whatever the answer → never retry (the runner did its job). **Delivered then unanswered** (read timeout, non-200, unparseable body) → **do not retry**, mark unhealthy: the handler may be running right now, and a retry would run a side-effecting function twice. `validate()` retries everything, because compiling has no side effects. Also: `RunnerPool::Options::readTimeoutSec` **must exceed** the runner's `max_wall_time_ms`, or our read times out before the runner can report its own timeout and the caller gets a misleading 503 instead of a 504.
 - **`ctx.collections(...)` is a direct gateway call, never loopback HTTP**, and `ctx.fetch` pins the connection to the single address the guard approved (`set_hostname_addr_map`) rather than re-resolving - re-resolving IS the rebinding window. One resolution, one classification.