perf_hooks: Histogram.DoImport reads SharedArrayBuffer-backed data without copying (TOCTOU)
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
- 62/100
- Tipo di issue
- Bug
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Attiva
- Stack tecnologico
- cpp, javascript
- Ambito
- security
Direzione di ricerca
Read HistogramImpl::DoImport in src/histogram.cc and compare its buffer handling with the SharedArrayBuffer copy in src/node_buffer.cc. Find the existing histogram import tests and check how they cover Uint8Array inputs. Done means SAB-backed input is copied before Histogram::Import parses it, with normal inputs retaining their behavior and tests covering the case.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Summary
HistogramImpl::DoImport in src/histogram.cc accepts a Uint8Array and reads the underlying buffer directly during CBOR parsing. When the Uint8Array is backed by a SharedArrayBuffer, a concurrent Worker thread can mutate the buffer while parsing is in progress, causing a time-of-check/time-of-use (TOCTOU) race.
Affected code
src/histogram.cc — HistogramImpl::DoImport (around line 3202):
Local<Uint8Array> input = args[0].As<Uint8Array>();
auto backing = input->Buffer()->GetBackingStore();
const uint8_t* data =
static_cast<const uint8_t*>(backing->Data()) + input->ByteOffset();
size_t len = input->ByteLength();
// ← no IsSharedArrayBuffer() check
auto histogram = Histogram::Import(data, len); // reads data during multi-step CBOR parse
There is no check for input->Buffer()->IsSharedArrayBuffer(). The CBOR parser in Histogram::Import performs multi-step parsing over data without any snapshot or copy.
Scenario
// Worker A — triggers importHistogram with a SAB-backed view
const sab = new SharedArrayBuffer(exportedBytes.length);
const view = new Uint8Array(sab);
view.set(exportedBytes);
// SAB is shared with Worker B via workerData or postMessage
importHistogram(view); // Worker A starts CBOR parse
// Worker B — running concurrently
const view2 = new Uint8Array(sab); // same SAB
view2[criticalOffset] = 0xff; // mutates header field mid-parse
The perf_hooks worker-import pattern in handleMetricsImportWorker-style code already uses this exact shape: the server creates a SAB, copies request data into it, and passes it to a Worker. If the main thread or another Worker modifies the SAB while the Worker is inside importHistogram, the CBOR parser sees inconsistent data.
Existing precedent
src/node_buffer.cc lines 587–592 already handles this case for Buffer.toString():
if (view->Buffer()->IsSharedArrayBuffer()) {
data_copy = std::make_unique_for_overwrite<char[]>(length);
memcpy(data_copy.get(), data_ptr + start, length);
data_ptr = data_copy.get();
start = 0;
}
Proposed fix
Copy SAB-backed data to a local buffer before passing to Histogram::Import, matching the node_buffer.cc pattern. This eliminates the race without changing behavior for normal (non-SAB) Uint8Array inputs.
Severity
Low. Exploitation requires the caller to intentionally share a SAB with the histogram import thread and mutate it during parsing. This is not remotely triggerable without cooperation from same-process JavaScript. It is a defense-in-depth hardening, not a CVE-eligible vulnerability.
- Lingua principale
- JavaScript
- Stelle
- 123k
- Fork
- 39.3k
- Merge medio
- 4g 16h
- PR unite (30g)
- 227
Preparare l'ambiente
- 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 nodejs/node
-
http2: content-encoding is incorrectly listed in kSingleValueHeadersForse già presa @inoway46 l’ha presa 1 giorno fa. Apertaconfirmed-bug http2
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
nodejs/node#67151 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
util.parseEnv and --env-file keep a leading UTF-8 BOM in the first keyForse già presa @helmipradita l’ha presa 3 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 1 giorno
-
node:internal/inspector/network_http: `TypeError: Missing dataLength` in event when response uses `setEncoding()`Forse di nuovo libera Una pull request per questa issue è stata chiusa senza essere unita. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
nodejs/node#66551 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
[Docs] `process.loadEnvFile()` does not document behaviour when variables already existForse già presa @Sepandard l’ha presa 37 giorni fa. Apertadoc
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 90/100
I maintainer di solito rispondono entro 1 giorno
-
Stream.prototype.forEach will block in first promise in queue before read more chunkForse già presa @mmustafasenoglu l’ha presa 38 giorni fa. Apertadoc
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
I maintainer di solito rispondono entro 1 giorno
Issue simili
-
good first issue
Difficoltà 2/5 3-5 giorni Idoneità per principianti 62/100
paipai1999/POS-system#3 ·
-
good first issue
Difficoltà 2/5 1-3 ore Idoneità per principianti 85/100
r-afael/better-yt-recommendations#36 ·
I maintainer di solito rispondono entro 1 giorno
-
needs-triage
Difficoltà 2/5 1-3 ore Idoneità per principianti 66/100
microsoft/playwright#43875 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
cli good first issue
Difficoltà 2/5 1-3 ore Idoneità per principianti 85/100
I maintainer di solito rispondono entro 1 giorno
-
Run the dependency drift checkForse già presa @spaceninja l’ha presa oggi. Aperta
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 82/100
cloudfour/stylelint-config-cloudfour#683 ·
I maintainer di solito rispondono entro 1 giorno