mirror of
https://github.com/Ark0N/Codeman.git
synced 2026-11-30 16:39:33 +01:00
docs(auth): list the no-header step after the Basic check; changeset
The pipeline list said it "runs in this order" but put the no-header challenge before the HTTP Basic check, while single-user auth.ts checks the correct password first. Swap steps 3 and 4. Note in the README and the Security / Remote-Access wiki pages that a request with no credentials is never counted, and add the patch changeset. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
ad08cb957d
commit
cc2b7d9c25
5 files changed
+20
-12
No files matched your search
@@ -0,0 +1,5 @@
|
||||
---
|
||||
'aicodeman': patch
|
||||
---
|
||||
|
||||
A request with no `Authorization` header always gets the `401` login challenge and is no longer counted as a failed login. After a server restart (cookie sessions live in memory) an open tab's background requests carry only the dead cookie; ten of them used to fill the per-IP bucket in seconds, and the `429` that followed carries no challenge, so the browser never asked for the password again and every user behind the same tunnel IP was locked out for the 15-minute decay. Wrong passwords and malformed `Authorization` headers are still counted and rate-limited as before, in both single-user and multi-user mode.
|
||||
@@ -708,7 +708,7 @@ By default Codeman launches sessions with `--dangerously-skip-permissions`, so t
|
||||
|
||||
- **Loopback by default** — the server binary binds `127.0.0.1`, reachable only from the same machine, so the no-password default is safe out of the box (the guided installer asks about network access and configures the binding + password for you). Binding a non-loopback host without `CODEMAN_PASSWORD` _starts but prints a loud warning_ with three concrete fixes (set a password, loopback + an authenticated tunnel, or explicitly acknowledge with `--allow-unauthenticated-network`)
|
||||
- **Optional auth, real sessions** — HTTP Basic via `CODEMAN_USERNAME` (default `admin`) / `CODEMAN_PASSWORD`. Success issues an opaque 256-bit `codeman_session` cookie (`randomBytes(32)`) — validated server-side, not client-signed, so it can't be forged offline (24h TTL, auto-extend, device-context audit log)
|
||||
- **Per-IP rate limiting** — 10 failed attempts → `429` with `Retry-After` (15-min decay). A valid cookie or correct password recovers _immediately_ even while an attacker hammers the same IP — important because all tunnel traffic shares one loopback IP. Multi-user mode allows 50 failures per IP instead, plus 10 failed guesses per account from one IP; both are checked before the password, so past either a correct password from that IP also waits for the decay, while the account still logs in from another IP. QR auth has its own separate limiter
|
||||
- **Per-IP rate limiting** — 10 failed attempts → `429` with `Retry-After` (15-min decay). A valid cookie or correct password recovers _immediately_ even while an attacker hammers the same IP — important because all tunnel traffic shares one loopback IP. Multi-user mode allows 50 failures per IP instead, plus 10 failed guesses per account from one IP; both are checked before the password, so past either a correct password from that IP also waits for the decay, while the account still logs in from another IP. A request with no credentials (an open tab after a restart) is never counted and always gets the login prompt. QR auth has its own separate limiter
|
||||
- **Configurable permission mode** - `--dangerously-skip-permissions` is only the default. **App Settings → Agents & CLIs → Claude → Startup Mode** can switch new sessions to Anthropic's classifier-guarded `auto` mode (low-prompt, needs Claude Code 2.1.207+), `normal` prompting, or an explicit allowed-tools list. In multi-user mode, non-granted users are forced to `auto`, and shell sessions / skip-permissions require an explicit per-user grant
|
||||
|
||||
### Always-on browser hardening (v0.9.5)
|
||||
|
||||
@@ -136,15 +136,16 @@ loopback bind matters. The auth pipeline (`src/web/middleware/auth.ts`,
|
||||
so misfiring hooks can never lock out the login path.
|
||||
2. **Session cookie** check — a valid `codeman_session` cookie short‑circuits to
|
||||
allow.
|
||||
3. **No `Authorization` header** — return `401` with the `WWW-Authenticate`
|
||||
challenge, **without counting it** and even while the IP is locked out (both
|
||||
modes; in multi-user mode this comes before the pre-verify gates). Such a
|
||||
request is no guess and runs no password check. Counting it let an open tab's
|
||||
background requests after a restart (cookie sessions live in memory) fill the
|
||||
bucket in seconds, and a `429` carries no challenge, so the browser never showed
|
||||
its login dialog again.
|
||||
4. **HTTP Basic** check — correct credentials short‑circuit to allow and clear
|
||||
3. **HTTP Basic** check — correct credentials short‑circuit to allow and clear
|
||||
that IP's failure counter.
|
||||
4. **No `Authorization` header** — return `401` with the `WWW-Authenticate`
|
||||
challenge, **without counting it** and even while the IP is locked out (both
|
||||
modes; in multi-user mode this comes before the pre-verify gates and the
|
||||
verify, which a missing header could never pass). Such a request is no guess
|
||||
and runs no password check. Counting it let an open tab's background requests
|
||||
after a restart (cookie sessions live in memory) fill the bucket in seconds,
|
||||
and a `429` carries no challenge, so the browser never showed its login dialog
|
||||
again.
|
||||
5. **Rate‑limit gate** — if the credentials did not pass and the IP is locked
|
||||
out, return `429` with a `Retry-After` header.
|
||||
6. Otherwise (wrong credentials, or an `Authorization` header that is not valid
|
||||
@@ -160,7 +161,8 @@ by presence in a server‑side map, so they cannot be forged offline.
|
||||
### Rate limiting / lockout recovery
|
||||
|
||||
Failed logins are tracked **per IP**: 10 failures (`AUTH_FAILURE_MAX`) → `429`, with a 15‑minute decay. Multi-user mode replaces that with three buckets, all with the same decay: a wider per-IP **pre-gate** of 50 failures (`AUTH_IP_FAILURE_MAX`), checked before the scrypt verify, which bounds scrypt cost from one source and tolerates many users behind one egress IP; a **per-(username, IP)** gate of 10 failures (`AUTH_FAILURE_MAX`), also checked before the verify, which is what caps verified guesses against one account from one source; and a **per-username** bucket, checked after the verify, that answers `429` to failed guesses from the 10th on, from any IP (the count is incremented before the check). The last two exist in multi-user mode only. So the wider per-IP cap does not widen guessing against any one account from one IP, and other IPs cannot lock an account out.
|
||||
The QR path has its own separate limiter.
|
||||
A request with no `Authorization` header is never counted (step 4), so an open
|
||||
tab after a restart cannot fill any bucket. The QR path has its own separate limiter.
|
||||
|
||||
The lockout check sits **after** the cookie/credential checks (step 5, not first).
|
||||
This is deliberate: a user with a **valid cookie or correct password recovers
|
||||
|
||||
@@ -236,7 +236,8 @@ Notes and current limits:
|
||||
The first request prompts for HTTP Basic credentials. On success the server issues an opaque
|
||||
`codeman_session` cookie (24 hour lifetime, extended on activity, validated server-side so
|
||||
it cannot be forged offline). Ten failed attempts from one IP produce a `429` with a 15
|
||||
minute decay.
|
||||
minute decay. A request with no credentials, such as an open tab whose cookie a restart
|
||||
invalidated, is never counted and always gets the login prompt.
|
||||
|
||||
A valid cookie or a correct password recovers immediately even while an attacker is hammering
|
||||
the same IP, which matters because all tunnel traffic arrives from one loopback address.
|
||||
|
||||
@@ -54,7 +54,7 @@ When authentication is enabled:
|
||||
| ------------------- | ------------------------------------------------------------------------------------------------ |
|
||||
| **HTTP Basic** | `CODEMAN_USERNAME` (default `admin`) and `CODEMAN_PASSWORD`. |
|
||||
| **Session cookie** | A 256-bit opaque token validated server side, so it cannot be forged offline. 24 hours, extended on activity, with a device-context audit trail. |
|
||||
| **Rate limiting** | Ten failed attempts per IP produce a `429` with a 15 minute decay. A correct password or valid cookie recovers immediately even under attack, which matters because all tunnel traffic shares one loopback address. In multi-user mode the per-IP cap is 50, and each account allows ten failed guesses from any one IP. Both are checked before the password, so past either a correct password from that IP also waits for the decay (the account still logs in from another IP, and a valid cookie keeps working). From the tenth failed guess on, an account's wrong guesses get a `429` from every IP, which never refuses a correct password. |
|
||||
| **Rate limiting** | Ten failed attempts per IP produce a `429` with a 15 minute decay. A correct password or valid cookie recovers immediately even under attack, which matters because all tunnel traffic shares one loopback address. In multi-user mode the per-IP cap is 50, and each account allows ten failed guesses from any one IP. Both are checked before the password, so past either a correct password from that IP also waits for the decay (the account still logs in from another IP, and a valid cookie keeps working). From the tenth failed guess on, an account's wrong guesses get a `429` from every IP, which never refuses a correct password. A request with no credentials at all (such as an open tab after a restart) is never counted and always gets the login prompt. |
|
||||
| **QR auth** | Single-use 60-second tokens with their own separate rate limiter, so a mistyped password cannot lock out QR login. |
|
||||
| **Hook endpoints** | The hook and telemetry endpoints skip Basic auth because they are called from localhost by the CLI, but when auth is on, that bypass additionally requires a per-instance hook secret. |
|
||||
|
||||
|
||||
Reference in new issue
Block a user