perf_hooks: Histogram.DoImport reads SharedArrayBuffer-backed data without copying (TOCTOU)
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 62/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- cpp, javascript
- Lĩnh vực
- security
Hướng nghiên cứu
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.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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.
- Ngôn ngữ chính
- JavaScript
- Star
- 123k
- Fork
- 39.3k
- Merge trung bình
- 4 ngày 16 giờ
- Pull request đã merge (30 ngày)
- 227
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của nodejs/node
-
http2: content-encoding is incorrectly listed in kSingleValueHeadersCó thể đã có người làm @inoway46 đã nhận 1 ngày trước. Đang mởconfirmed-bug http2
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
nodejs/node#67151 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
util.parseEnv and --env-file keep a leading UTF-8 BOM in the first keyCó thể đã có người làm @helmipradita đã nhận 3 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Maintainer thường phản hồi trong vòng 1 ngày
-
node:internal/inspector/network_http: `TypeError: Missing dataLength` in event when response uses `setEncoding()`Có thể làm lại được Pull request cho issue này đã bị đóng mà không được merge. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
nodejs/node#66551 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[Docs] `process.loadEnvFile()` does not document behaviour when variables already existCó thể đã có người làm @Sepandard đã nhận 37 ngày trước. Đang mởdoc
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 90/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Stream.prototype.forEach will block in first promise in queue before read more chunkCó thể đã có người làm @mmustafasenoglu đã nhận 38 ngày trước. Đang mởdoc
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
Maintainer thường phản hồi trong vòng 1 ngày
Issue tương tự
-
good first issue
Độ khó 2/5 3-5 ngày Mức phù hợp với người mới 62/100
paipai1999/POS-system#3 ·
-
good first issue
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
r-afael/better-yt-recommendations#36 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
needs-triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 66/100
microsoft/playwright#43875 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
cli good first issue
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Run the dependency drift checkCó thể đã có người làm @spaceninja đã nhận hôm nay. Đang mở
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 82/100
cloudfour/stylelint-config-cloudfour#683 ·
Maintainer thường phản hồi trong vòng 1 ngày