Websocket origin rejection warning does not mention a trusted X-Forwarded-Proto when that is the cause
I maintainer di solito rispondono entro 1 giorno
Valutazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Idoneità per principianti
- 78/100
Direzione di ricerca
Leggi _SocketOriginCheck.__call__ in reflex/app.py e il test test_socketio_rejection_warns_once_with_fix in tests/units/test_app.py. Aggiungi all’avviso il valore considerato attendibile di X-Forwarded-Proto e copri il caso in cui un’origine http:// corrisponde all’host della richiesta, ma è in conflitto con l’https considerato attendibile; verifica che il suggerimento spieghi la discrepanza dello schema senza proporre l’origine rifiutata come valore di configurazione.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Problem
In prod mode the event websocket accepts the backend's own origin. With trusted_proxy_hops >= 1, a trusted X-Forwarded-Proto: https makes an http:// origin a mismatch (by design, #7799). When that is the reason for a rejection, the once-per-worker warning describes the wrong cause. It prints the Host and X-Forwarded-Host it saw, then advises setting REFLEX_DEPLOY_URL and says "a reverse proxy must forward the original Host header". The Host already matches, and the real cause is the scheme: the trusted proxy claims https while the page was loaded over http, for example a misconfigured proxy or an http page behind a hop that sets X-Forwarded-Proto: https.
The rejection itself is correct; only the diagnosis is misleading.
Repro (reflex 0.11.0a2)
REFLEX_TRUSTED_PROXY_HOPS=1 REFLEX_API_URL=http://app.test:3341 reflex run --env prod --backend-port 3340(single-port).- Put a plain-http reverse proxy on :3341 that keeps
Hostand setsX-Forwarded-Proto: https. - Open
http://app.test:3341/in a browser.
Actual: the websocket gets 403 forever, and the log says:
Rejected an event websocket from origin 'http://app.test:3341': in prod mode the backend accepts only its own origin (request Host 'app.test:3341', X-Forwarded-Host None trusted); if it is your frontend's origin, set REFLEX_DEPLOY_URL on the backend to the frontend's public URL or add it to cors_allowed_origins; a reverse proxy must forward the original Host header.
Expected: the warning names the trusted X-Forwarded-Proto value it used. When the origin's host matches and only the scheme differs, the hint says so: the page is served over http while the trusted proxy reports https, so fix the proxy's X-Forwarded-Proto or serve the page over https.
Fix
reflex/app.py,_SocketOriginCheck.__call__: include the trustedX-Forwarded-Protoentry in the "request Host …, X-Forwarded-Host …" part of the warning.- When
_origin_matches_request(origin, hosts, None)is true but the call with the trusted proto is false, use a scheme-specific hint instead of the Host-forwarding one. Do not put the rejected origin into any setting's value (any client can send the first rejected handshake). - Extend
test_socketio_rejection_warns_once_with_fixintests/units/test_app.pywith anX-Forwarded-Proto: https+http://origin case attrusted_proxy_hops=1.
- Lingua principale
- Python
- Stelle
- 29k
- Fork
- 1.8k
- Merge medio
- 2g 22h
- PR unite (30g)
- 154
Preparare l'ambiente
Avvia il container di sviluppo del progetto nel browser, con il tuo account GitHub.
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di reflex-dev/reflex
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
reflex-dev/reflex#7915 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Kept env.py failure: the "move it aside" hint is dropped and a full traceback is logged when alembic.ini uses a relative script_locationForse già presa @MaiAditya l’ha presa 4 giorni fa. Apertabug release-train
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
reflex-dev/reflex#7856 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Unit tests: invoking the reflex CLI in-process leaves REFLEX_MANAGED_LOGGING=true in os.environ for every later testForse già presa @zeyadrabie l’ha presa 2 giorni fa. Apertarelease-train
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
reflex-dev/reflex#7844 · 2 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
A dev run stopped before its backend loads leaves .web/nocompile, so the next run or export skips the compileForse già presa @YusefSyed l’ha presa 6 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
reflex-dev/reflex#7825 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
PropsBase nested serialization applies parent include/exclude filters to child fieldsForse già presa @harsh21234i l’ha presa 7 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
reflex-dev/reflex#7787 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di reflex-dev/reflex
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
ip-tools/patzilla#219 · 2 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
EPSSClient commits to its SQLite cache once per score: a 100-CVE bulk fetch makes 101 disk flushesApertapriority:p3 technical-debt
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
jimmy058910/jmo-security-repo#1673 ·
I maintainer di solito rispondono entro 1 giorno
-
enhancement ready
Difficoltà 2/5 1-3 ore Idoneità per principianti 86/100
-
integration: frontier_silicon
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
home-assistant/core#193176 · 2 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
task create and task update take --body-file and --stdinForse già presa @JuanBarriosS l’ha presa oggi. Apertacli enhancement good first issue help wanted
Difficoltà 2/5 1-3 ore Idoneità per principianti 92/100
pyrite-wiki/pyrite#1687 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno