fix(security): use trusted IP source for rate limiter client key - #875
Open
Esc1200 wants to merge 1 commit into
Open
fix(security): use trusted IP source for rate limiter client key#875Esc1200 wants to merge 1 commit into
Esc1200 wants to merge 1 commit into
Conversation
The rate limiter in hostedUiAuthClientKey() prioritized X-Forwarded-For (first entry) over X-Real-IP. Since X-Forwarded-For is set by the client on the first hop, an attacker can spoof it to bypass rate limiting by rotating arbitrary client identifiers. Fix: - Prefer x-real-ip (set by the trusted reverse proxy) as the primary key - If falling back to x-forwarded-for, use the LAST entry (rightmost) which is set by the trusted proxy closest to the server, not the first entry which is client-controllable - Maintain 'unknown' fallback for missing headers
ifeoluwaaj
pushed a commit
to ifeoluwaaj/vibeship-spawner-ui
that referenced
this pull request
Jun 27, 2026
Consolidates a same-author path-redaction series: - Remove tracePath from creator mission GET response (vibeforge1111#877) - Remove server path from mission active POST response (vibeforge1111#876) - Remove rawResponse field from analyze error response (vibeforge1111#874) - Remove x-spark-preview-root header leaking server path (vibeforge1111#873) - Use trusted x-real-ip / last x-forwarded-for entry for the rate-limiter client key (vibeforge1111#875) Surviving-line indentation normalized back to file style (the patches bundled an over-indentation reflow of untouched lines). Co-authored-by: Esc1200 <Esc1200@users.noreply.github.com> Co-Authored-By: Claude Opus 4.8 <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.
Bug: Rate limiter uses spoofable X-Forwarded-For for client identification
Severity: MEDIUM
File:
src/lib/server/hosted-ui-auth.ts(lines 186-188)Problem:
hostedUiAuthClientKey()used the first entry ofX-Forwarded-Foras the rate limiter client key, prioritizing it overX-Real-IP. SinceX-Forwarded-Foris a client-set header on the first hop, an attacker can:X-Forwarded-ForheaderFix:
x-real-ip(set by the trusted reverse proxy like nginx) as the primary client keyx-forwarded-foronly whenx-real-ipis missing, using the last entry (rightmost) which is set by the trusted proxy closest to the server, not the first entry which is client-controllable'unknown'fallback for missing headersTesting: