mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[PR #8775] [MERGED] fix(server): keep sign-in lockouts when the count table is full #8798
Labels
No labels
android
bug
bugfix
ci
client
code freeze pause
container
dependencies
docs
documentation
duplicate
enhancement
feature
feature
feature
feature-creep
fixed-in-refactor
fixed-in-staging
good first issue
help wanted
in-pr
in-pr
needs-codeowner-decision
normal-scope
old-codebase
old-codebase
pull-request
qol
question
refactor
regression
revisit later
roadmap
scope-risk
scope-risk
server
server
shared
soup
upstream
windows
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Pasta-Devs/Marinara-Engine#8798
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/8775
Author: @SpicyMarinara
Created: 11/3/2026
Status: ✅ Merged
Merged: 11/3/2026
Merged by: @SpicyMarinara
Base:
staging← Head:fix/hardening-login-lockout📝 Commits (1)
e609dcefix(server): keep sign-in lockouts when the count table is full📊 Changes
2 files changed (+91 additions, -10 deletions)
View changed files
📝
packages/server/src/middleware/basic-auth.ts(+35 -9)📝
scripts/regressions/basic-auth-throttle-security.regression.ts(+56 -1)📄 Description
Linked issue
Closes #8769
Why this change
The sign-in throttle counts wrong passwords and codes per client address. After 10 different wrong ones it refuses that address for 15 minutes, as docs/REMOTE_ACCESS.md describes. Two gaps let a password be checked outside that count. First, the counts live in a table capped at 4096 clients. When it was full of live entries, the oldest entry was dropped to make room, even if that client was still locked, so its lockout could end early. Second, the sign-in page compared a Basic Authorization header, and the throttle does not count that path. This change keeps every running count when the table is full. It refuses clients the table cannot count before any password or code is compared. It also stops the sign-in page from comparing headers. Every password or code the server compares is now counted.
What changed
Validation
pnpm checkpasses locallyCONTRIBUTING.mdManual verification notes
Agent-run checks (for reference; each regression was shown to fail without its fix):
git fetch origin staging; git log -1 origin/staging:aed5e3578d, unchanged since the fixer's check; the finding still appliesnode ./scripts/pnpm-runner.mjs build:shared: succeedednode ./scripts/run-regressions.mjs --filter basic-auth-throttle-security (final fix): PASSED 1/1Same regression against origin/staging basic-auth.ts, and against the previous branch commit a84564d7bf: Both FAILED at 'the right password gets the page' (actual 302, expected 200)Same regression against origin/staging basic-auth.ts with only the GET /login change applied: FAILED at 'the lock outlasts a full table' (actual 200, expected 429), so the eviction is still caughtSame regression with each guard removed on its own: the checkCredentials room check, the isBasicAuthSatisfied room check, the GET /login change (file copied asi: FAILED as expected: actual 200 vs 429; actual {status:'ok',sidecars:{}} vs {status:'ok'}; actual 302 vs 200. PASSED again once restorednode ./scripts/run-regressions.mjs --filter scripts/regressions/<name>.regression.ts for remote-login, loopback-proxy-auth-security, docker-proxy-auth, lockdown: All 12 passed (1/1 each). These cover every regression that imports basic-auth, privileged-gate or notices, or calls /api/healthcd packages/server && node ../../scripts/pnpm-runner.mjs run lint (tsc -b ../shared && tsc --noEmit && tsc -p ../../scripts/regressions/tsconfig.character-activ: exit 0node_modules/.bin/prettier --write and --check on both changed files: unchanged; check passedESLint: Not run: ESLint is configured only for packages/client. The server 'lint' script is tsc, which passed. No client copy changed, so localization:check was not neededIndependent adversarial review: changes, 3 issue(s), all addressed in a fix-up pass.
Known limits and risks:
All three review issues held up against the code, so none were rejected.
Trade-off, now stated in the ponytail comment: someone who controls more than 4096 IPv4 addresses or IPv6 /64s can fill the table. While it stays full, any client that has no count yet cannot sign in with a password, pairing code or setup code for up to 15 minutes at a time, and the table can be refilled as counts end. That includes the owner's new devices and Basic-auth scripts from addresses with no count, even with the right .env or app password. A signed-in remote browser that changes or removes the login during that time also gets 429. Signed-in browsers, clients that already have a count, and trusted peers (this computer, IP_ALLOWLIST, trusted Tailscale/Docker) are unaffected. The owner can still change settings from the host computer. This fails closed on purpose. Before, a full table handed guesses back. With the first-pass fix, a client without room could have unlimited uncounted checks.
I chose the reviewer's option (a) over a shared overflow bucket. An attacker who fills the table can exhaust a 50-guess overflow budget almost for free, so the owner lockout would be the same, with more code. The ponytail comment keeps that bucket as the upgrade path. As both verifiers advised, I added no global or /48 budget, because the existing regression pins per-/64 independence.
GET /login no longer redirects on a valid Basic header. Nothing in the repo relied on that. The only client navigation to /login is the sign-out in RemoteLoginSettings.tsx, which sends no header. A browser with cached native-prompt credentials now sees the form on /login and can sign in there.
When the table is full, hasRoomFor sweeps all 4096 entries on each check from a client without a count. This is the same sweep the old countGuess did. It now also runs in isBasicAuthSatisfied, but only while the table is full, and it stays cheap.
Cosmetic, carried over: with no room, the setup code returns 1 second, so the UI says "Too many wrong codes. Try again in 1 minute." No new copy was added.
Docs: unchanged. docs/REMOTE_ACCESS.md's per-address 15-minute claim is now accurate. The full-table refusal is not documented. A TROUBLESHOOTING note on "Too many sign-ins at once" would need a docs-i18n follow-up, so I left it out of this neutral hardening PR.
Git: the unpushed commit a84564d7bf was amended into
e609dcef82so its message matches the diff. Nothing was pushed, no PR was opened, and CHANGELOG.md and version files are untouched.NOT FOR THE PR BODY, for the user: your relayed request to change Otome Hearth so showing off an outfit to a love interest gives +5 affection instead of +20 was not done here. It is outside this login-throttle worktree, and no outfit-affection logic exists under this repo's packages/. The Otome Hearth (otome-forge) package lives outside Marinara Engine, so it needs its own change in the repository and branch that own that package.
Docs and release impact
docs-i18nbranch updated to match, or a[docs-i18n]follow-up issue opened (see CONTRIBUTING.md § Translated documentation)🤖 Generated with Claude Code
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.