Repository navigation
Harden login, agent registration, the GitHub token and three fail-open defaults - #170
Open
blakebauman wants to merge 8 commits into
Open
blakebauman wants to merge 8 commits into
blakebauman wants to merge 8 commits into
Conversation
…c workers The login handler checked the lockout, awaited the argon2 verify, and only then recorded the failure, so a parallel burst all passed the check and the guess rate was bounded by CPU rather than by the lockout. LoginGuard now hands out a reservation (begin_attempt) that counts failures plus attempts in flight, settled by finish() and released on drop so an early return cannot leak a slot. Alongside: argon2 hash/verify run in spawn_blocking (login, change password, create user and so add member), an unknown username is verified against a dummy hash so it costs the same as a wrong password, at most 8 logins are verified at once (429 beyond that), and a full guard table evicts expired then lowest-count entries instead of dropping every entry that is not locked out. fiber-core's tokio moves from dev-dependencies to dependencies; it was already in the graph through sqlx, and Cargo.lock is unchanged. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Hello reloaded the agent row for pool scope but registered the agent with the labels and concurrency the client sent, so any agent token could reconnect claiming every label and u32::MAX slots and lease other agents' steps, with their secrets. The row is now the ceiling: labels are the row's labels the agent also claims, concurrency is the smaller of the two, and asking for more is logged with the agent id. The decision is a pure function, effective_registration, with tests. Intersection rather than taking the row verbatim, because both sides are configured today and their defaults disagree (the UI pre-fills os=linux,docker=true where the installer defaults to os=linux): an agent must not be offered work for a label it did not claim. A row with no labels restricts nothing, so an agent registered with an empty label set is not stripped on upgrade. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
resolve_token fell back to FIBER_GITHUB_TOKEN / GITHUB_TOKEN in fiber-api's environment, and the repository it was spent on came from the webhook payload. A project admin sets the webhook secret that payload is trusted on, and any user can create a project, so a user could sign a pull_request payload naming a private repository and learn from the response what the instance token can read there. Both GitHub calls now go through resolve_project_token (project secrets only), as commit statuses already did. Matching the payload repository against a pipeline's workspace.repo was the alternative and is not a boundary: the same user writes the pipeline. The environment variable is read only to warn, once, that it is ignored. Docs said the environment was also a fallback for commit statuses, which the code had already stopped doing; corrected alongside. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…s, and admin/fiber A FIBER_SECRETS_KEY that was set but not 64 hex characters was treated as unset: the boot log said 'unset (dev only)' and every secret written afterwards was plaintext. It is now a boot error naming the problem (never the value), via parse_key; encrypt and decrypt fail on such a key too instead of passing plaintext through. Unset is still allowed and warned about. Compose now requires FIBER_SECRETS_KEY like the other credentials. The Makefile's dev credentials supply a throwaway one so 'make infra' still interpolates the file; scripts/smoke_compose.sh already exported one. fiber-api's default listen address is 127.0.0.1:18080 instead of 0.0.0.0:18080, and on a non-loopback address it refuses to start while the bootstrap admin can log in with the default password, unless FIBER_ALLOW_DEFAULT_ADMIN=1. The check asks the database once users exist, because FIBER_ADMIN_PASSWORD only applies to an empty one, and runs before the admin is created so a refused first boot can be fixed by setting the variable. The Compose smoke logs in as admin/fiber on 0.0.0.0, so it sets the override. The image now sets FIBER_LISTEN=0.0.0.0:8080 to match its EXPOSE and HEALTHCHECK. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
… of refusing The login cap was a handler-side try_acquire: it refused at once, so eight concurrent junk logins kept every real login at 429, and because the permit lived in the handler future while argon2 ran in a detached blocking task, a client that hung up freed the permit with the hash still running. Change password, create user and add member had no cap at all. One gate in fiber-core::tokens now bounds every *_blocking hash and verify to MAX_CONCURRENT_HASHES (4). The permit moves into the blocking closure and is released when the hash finishes. Callers queue in arrival order for up to HASH_SLOT_WAIT (5 s), then fail with HashBusy, which the API answers as 503 with Retry-After and its own message; the login reservation is dropped, so it is never a failed attempt. The queue is bounded by that timeout and by MAX_WAITING_HASHES. LOGIN_SLOTS is gone. A legacy salt$sha256 hash now also pays for one argon2id verify and is compared with constant_time_eq, which moves to fiber-core so the webhook check shares it. Also folds upstream's '### Changed' heading and this branch's into one section, which the rebase onto #166 had left as two. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…dits
A row with no labels took the agent's Hello labels as sent, which left the original
hole open for those rows and inverted an admin clearing labels to restrict an agent.
The intersection is now unconditional: an empty row grants none, and the agent is
offered only label-less steps (the queue match is step.labels <@ agent.labels).
PUT /api/agents/{id} installed the row's labels and concurrency verbatim on a live
agent, so widening a row gave it labels it never claimed until it reconnected. The
handler now only narrows (AgentPresence::narrow_to, via a new
Scheduler::narrow_agent_presence), and the agent's WebSocket session, which is what
knows what Hello claimed, recomputes effective_registration(row, hello) on every
heartbeat from the row it already re-reads. Narrowing is immediate on the replica
that took the edit and within one heartbeat elsewhere; widening lands on the next
heartbeat.
AgentPresence and register_agent are unchanged; the scheduler change is additive.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
The boot refusal asked only whether FIBER_ADMIN_USER could log in with the default password. An instance bootstrapped as admin/fiber whose FIBER_ADMIN_USER was later pointed at another account still has admin/fiber in its users table, and booted publicly. Both names are now checked, and the message names the one that matched. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
The Makefile's throwaway credentials are skipped when deploy/.env exists, and Compose now requires FIBER_SECRETS_KEY, so a deploy/.env written before that makes make infra and make down fail at interpolation. Say so in docs/development.md, with the one-liner. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Audit findings SEC-2 to SEC-6 and SEC-8 (11 Nov). Eight commits; the last four are the follow-ups from an independent security review of the first four.
Operators: before upgrading
FIBER_SECRETS_KEY(openssl rand -hex 32). A contributor's existingdeploy/.envneeds it too, ormake infrafails at interpolation.admin/fibercan still log in. Change the password, or setFIBER_ALLOW_DEFAULT_ADMIN=1. The bare binary now listens on127.0.0.1:18080by default; the image sets0.0.0.0:8080itself.FIBER_GITHUB_TOKENin the API's environment is no longer used. Path-filtered pull request pipelines need aGITHUB_TOKENproject secret.SELECT id, name FROM agents WHERE labels = '[]'::jsonb;).What was wrong, and the fix
begin_attempt→ a guard that settles onfinishor drop). An unknown username costs the same argon2id verify as a real one, as does a legacy-format hash. Eviction under pressure takes expired, then fewest-failure entries first, never one with attempts in flight.Helloset its own labels and concurrency. The effective registration is now the row's labels that the agent also claims, and the smaller concurrency. Applied atHello, on every heartbeat from the row it already re-reads, and onPUT /api/agents/{id}(which narrows a live agent at once; widening lands on its next heartbeat).FIBER_SECRETS_KEYmeant plaintext secrets. Set-but-invalid is now a boot error that names the problem and never echoes the value.0.0.0.0withadmin/fiberby default. See the operator notes. The boot check asks the database whether the configured admin — and the literaladmin— can still log in with the default password.Verified
make checkgreen;cargo test --workspacegreen (477 tests). Each new test was broken, seen red and restored — including one that drops the caller mid-hash and asserts the slot is still held, and a 64-thread barrier test on the login budget.3f4de4c.docker compose configfails without the key with the new message and resolves with it.Not verified
Store::password_isis runtime sqlx and has not executed (it is the same one-column select aschange_password).PUTnarrowing and the 503 path have unit coverage of their pure parts only; no smoke edits a connected agent's row.ENVline).docs/authz.mdsays so.Conflicts with #168
Both touch the
register_agentcall in theHelloarm ofws.rs. Whichever merges second needs a small rebase there.🤖 Generated with Claude Code