P4: Standalone web API can read past its request buffer on a large request body
I maintainer di solito rispondono entro 1 giorno
Valutazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Idoneità per principianti
- 65/100
Direzione di ricerca
Inizia esaminando code/network/stand_gui-unix.cpp intorno alle righe 650–656, dove mg_read riempie entityBuffer e json_loads lo analizza. Verifica come utilizzare il numero di byte restituito per mantenere l’analisi entro i limiti del buffer e come gestire i corpi troppo grandi. Il lavoro è completato quando un corpo della richiesta di almeno 1.024 byte non può far leggere all’analizzatore oltre il buffer e il server lo gestisce in modo sicuro.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Low priority: it needs the web panel login, only affects Linux and Mac dedicated servers, and I found it by reading the code, not by running it.
Problem
On a Linux or Mac dedicated server, the web API reads a request body into a 1,024-byte buffer and then parses it as text. When the body is 1,024 bytes or longer, the buffer is filled completely and has no zero byte at the end, so the parser keeps reading past the buffer until it happens to hit one. That can produce garbage input or crash the server.
The code is in code/network/stand_gui-unix.cpp on master (8afa31842), lines 650-656: mg_read fills entityBuffer with up to sizeof(entityBuffer) bytes, then json_loads reads it as a zero-terminated string. The byte count mg_read returns is commented out and unused.
Steps to reproduce (not run; from reading the code)
- Start a dedicated server on Linux:
fs2_open -standalonewith any mod, so the web panel starts on its port (8080 by default). - Send an authenticated
PUT /api/1/serverorPOST /api/1/chatwith a body of 1,024 bytes or more. - The JSON parser reads past the end of the 1,024-byte buffer.
Expected vs. actual behavior
Expected: an oversized body is cut off or rejected, and the server keeps running.
Actual (from the code): the parser reads memory past the buffer, which may give a parse error, wrong input, or a crash.
Proposed fixes
- Read one byte less so the zero byte from the
memsetalways stays at the end:mg_read(conn, entityBuffer, sizeof(entityBuffer) - 1). - Keep the byte count
mg_readreturns and parse withjson_loadb, which takes a length and never looks for a zero byte. - Read the whole body (up to a sane cap) into an
SCP_stringand reply with an error when it is too large, so long chat messages are not silently cut off either.
- Lingua principale
- C++
- Stelle
- 488
- Fork
- 184
- Merge medio
- 1g 23h
- PR unite (30g)
- 28
Preparare l'ambiente
Non abbiamo ancora controllato i file di configurazione di questo progetto. 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 scp-fs2open/fs2open.github.com
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 74/100
scp-fs2open/fs2open.github.com#7984 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
scp-fs2open/fs2open.github.com#7983 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
scp-fs2open/fs2open.github.com#7969 ·
I maintainer di solito rispondono entro 1 giorno
-
P2: A ship-specific HUD with "$Load Retail Configuration: YES" loses most of its retail gaugesAperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
scp-fs2open/fs2open.github.com#7956 ·
I maintainer di solito rispondono entro 1 giorno
-
bug HUD LLM-suggested
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
scp-fs2open/fs2open.github.com#7953 ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di scp-fs2open/fs2open.github.com
Issue simili
-
artifact:simulation-scenario domain:physics good first issue help wanted role:validation testing
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
I maintainer di solito rispondono entro 3 giorni
-
bug
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 88/100
NVIDIA/accelerated-computing-hub#294 ·
I maintainer di solito rispondono entro 4 giorni
-
bug P3
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 1 giorno
-
area-System.IO untriaged
Difficoltà 2/5 Mezza giornata Idoneità per principianti 72/100
dotnet/runtime#136802 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno