Forward mode blocks indefinitely upon certain content-disposition header value
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 35/100
- Tipo di issue
- Bug
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Ferma
- Stack tecnologico
- node.js, typescript
- Ambito
- backend, networking
Direzione di ricerca
Start in src/forward.ts, where the writeHead call throws and the error is silently swallowed around lines 97-113. Reproduce with the socat target and the curl -x localhost:8000 request from the issue, and confirm the request hangs. The issue offers three options (sanitize the content-disposition header, let the upstream error fail the request, or surface the error), and maintainers have not chosen one, so agree on an approach before coding. Done means the request either completes or fails with a visible error instead of blocking.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Overview
proxy-chain is observed to block indefinitely when certain conditions are met:
- It works in the forward mode (plain HTTP).
- There is
content-dispositionheader that contains certain non-ASCII content. - There is
content-lengthheader.
The root cause of issue is believed to originate from Node.js. Before an upstream fix is made (which might take time) proxy-chain here could apply some mitigation.
Upstream Issue: ServerResponse.writeHead may throw an error
There are already several upstream issue reports, one of which is https://github.com/nodejs/node/issues/50213
Mostly relevant is this section of code https://github.com/nodejs/node/blob/v20.16.0/lib/_http_outgoing.js#L554-L567 where the improper type change later involves implicit type conversion and unexpected charset decoding at https://github.com/nodejs/node/blob/v20.16.0/lib/_http_common.js#L216-L225
A minimal example for the decoding error: /[^\t\x20-\x7e\x80-\xff]/v.test(Buffer.from('à', 'latin1')) This then result in an invalid character error to be thrown (code) during ServerResponse.writeHead.
Impact to proxy-chain
As of the current revision, said issue would cause an error thrown from this call: https://github.com/apify/proxy-chain/blob/a1ac3f287e895270f4e34306ac754a62a9848fa4/src/forward.ts#L97-L101
It is then silently ignore here therefore the observed blocking: https://github.com/apify/proxy-chain/blob/a1ac3f287e895270f4e34306ac754a62a9848fa4/src/forward.ts#L110-L113
In earlier versions of proxy-chain (that is used when I noticed this issue), said error is not caught thus exposed. This leads to the error as reported here: https://github.com/apify/proxy-chain/issues/20
Sample Steps to Reproduce the Issue
Target web server:
$ socat -v -v TCP-LISTEN:8080,fork,reuseaddr,crlf SYSTEM:'echo HTTP/1.1 200 OK; echo "content-length: 6"; echo -e "content-disposition: \\\\xe0"; echo; echo -n "foobar"'
proxy-chain instance (just the minimal example from README.md):
const ProxyChain = require('proxy-chain');
const server = new ProxyChain.Server({ port: 8000 });
server.listen(() => {
console.log(`Proxy server is listening on port ${8000}`);
});
Sending the request:
$ curl -v -x localhost:8000 'http://localhost:8080'
Expected result: The request shall finish. (see also: curl -v 'http://localhost:8080')
Observed result: The request blocks indefinitely.
(checked with Node.js v20.16.0 which is the active LTS)
Proposed Actions
I'm afraid that it's unlikely that the upstream will make a fix soon, considering how long their tickets have been around (e.g. https://github.com/nodejs/node/issues/50213).
There are a few proposals on what could be done here:
- To manipulate the
content-dispositionheader ahead, so that the call ofServerResponse.writeHeadno longer fails. - Or, alter the response handler upon forwarding, so that the upstream error no longer blocks the request. Perhaps letting it fail is (slightly?) better than blocking.
- Also, maybe expose the error message to users so that they may have an idea on what's going on.
- Lingua principale
- TypeScript
- Stelle
- 1k
- Fork
- 167
- Merge medio
- 16h 22m
- PR unite (30g)
- 16
Preparare l'ambiente
Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.
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 apify/proxy-chain
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 15/100
apify/proxy-chain#635 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 15/100
apify/proxy-chain#634 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 12/100
apify/proxy-chain#633 ·
I maintainer di solito rispondono entro 1 giorno
-
good first issue low priority t-unblocking tech roadmap
Difficoltà 4/5 3-5 giorni Idoneità per principianti 35/100
apify/proxy-chain#632 ·
I maintainer di solito rispondono entro 1 giorno
-
low priority t-unblocking tech roadmap
Difficoltà 3/5 Mezza giornata Idoneità per principianti 28/100
apify/proxy-chain#631 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di apify/proxy-chain
Issue simili
-
fix(frontend): correct VITE_IS_DEVELPOMENT typo in shared/app.ts and align dev environment flagsAperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
vicharanashala/ajrasakha#1439 ·
I maintainer di solito rispondono entro 1 giorno
-
Add: TV5Monde AsieApertaapproved check:passed streams:add
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
backnotprop/plannotator#1932 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 Mezza giornata Idoneità per principianti 62/100
ibm-granite/granite.build#504 ·
I maintainer di solito rispondono entro 2 giorni
-
reproduced
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
anomalyco/opencode#55676 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno