fix(selfhost): cap setup token form parsing - #1287
Merged
Merged
Conversation
Contributor
|
Superagent didn't find any vulnerabilities or security issues in this PR. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1287 +/- ##
=======================================
Coverage 95.41% 95.41%
=======================================
Files 193 193
Lines 21006 21018 +12
Branches 7609 7613 +4
=======================================
+ Hits 20043 20055 +12
Misses 383 383
Partials 580 580
🚀 New features to boost your workflow:
|
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
gittensory-ui | 49e2678 | Commit Preview URL Branch Preview URL |
Jun 26 2026, 08:35 AM |
Owner
Author
|
Verdict: MERGE · gittensor:bug. Pre-parse DoS cap (411/400/413/415 before formData()) on the unauthenticated /setup POST; all branches covered, green. On-direction (self-host hardening). |
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.
Motivation
POST /setuppath parsedrequest.formData()for browser-submitted tokens before any size or content-type checks, allowing an unauthenticated client to submit a large or malformed body and cause memory/CPU exhaustion (bootstrap DoS).Description
SETUP_TOKEN_FORM_MAX_BYTESand asetupTokenFormRejection(headers: Headers): Response | undefinedhelper insrc/selfhost/setup-wizard.tsthat enforcesContent-Length, a 4 KiB max, valid numeric lengths, and only allowsapplication/x-www-form-urlencodedormultipart/form-data./setuphandler insrc/server.tsso the route returns early for rejected requests before callingrequest.formData().test/unit/selfhost-setup-wizard.test.tsfor oversized, missing/invalid length, unsupported content-type, and accepted content-type cases.Testing
git diff --checkwhich produced no errors.npx vitest run test/unit/selfhost-setup-wizard.test.tsand the new unit tests passed.npm run typecheckwhich completed successfully.npm run test:coveragewhich encountered unrelated suite timeouts and a coverage remap error (TypeError: jsTokens is not a function) during global coverage generation.npm audit --audit-level=moderatewhich failed due to the registry audit endpoint returning403 Forbidden.Codex Task