Snapshot.load accepts a blob from another V8 version, and Context.new then kills the process
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 52/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ệ
- javascript, ruby
Hướng nghiên cứu
Read ext/mini_racer_extension/mini_racer_extension.c around snapshot_load and ext/mini_racer_extension/mini_racer_v8.cc around v8_thread_init, where the blob reaches v8::Isolate::New. Check V8 snapshot header length and section offsets before V8 uses the data, including the truncated-tail case. Done means incompatible or malformed blobs raise MiniRacer::SnapshotError instead of terminating the process; add focused coverage for both reproductions.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Snapshot.load accepts an incompatible snapshot blob, then Context.new terminates the process inside V8. This affects trusted snapshots persisted across upgrades that change libv8-node.
Reproduce
require "mini_racer"
blob = MiniRacer::Snapshot.new("var a = 1").dump.dup
blob.setbyte(16, blob.getbyte(16) ^ 1)
MiniRacer::Context.new(snapshot: MiniRacer::Snapshot.load(blob))
puts "not reached"
Byte 16 is the first byte of the version string in V8 13.6's snapshot header, so flipping it stands in for a blob saved by a different libv8-node.
What happens
#
# Fatal error in , line 0
# Version mismatch between V8 binary and snapshot.
# V8 binary version: 13.6.233.17-node.37
# Snapshot version: 03.6.233.17-node.37
# The snapshot consists of 410911 bytes and contains 1 context(s).
Exit status 133 (SIGTRAP), followed by a native backtrace.
Cutting the last 16 bytes from the blob instead produces no message and exits with status 139 (SIGSEGV). Both cases reproduced in 3 of 3 runs.
Expected
Snapshot.load or Context.new should raise MiniRacer::SnapshotError when the current V8 cannot use the blob.
Cause
snapshot_load only duplicates the supplied String (ext/mini_racer_extension/mini_racer_extension.c:2152, ext/mini_racer_extension/mini_racer_extension.c:2160). v8_thread_init passes the blob to v8::Isolate::New without validating it (ext/mini_racer_extension/mini_racer_v8.cc:451, ext/mini_racer_extension/mini_racer_v8.cc:456). V8 handles a version mismatch with FATAL and invalid section offsets with CHECK, so malformed or stale data ends the process.
Possible fix
Check that the blob is longer than the header, then call v8::StartupData::IsValid() and raise SnapshotError on failure. The length check must come first because IsValid() checks the header bounds fatally. A truncated tail also needs bounds validation for the section offsets because V8 verifies the checksum only in debug builds.
Related: closed PR #101 discussed a version mismatch abort in 2018.
Environment
- mini_racer 0.22.1 with libv8-node 24.12.0.1 (V8 13.6.233.17-node.37)
- Ruby 3.4.2 x86_64-linux
- Fedora 44
Reproduced in 3 of 3 runs.
- Ngôn ngữ chính
- JavaScript
- Star
- 628
- Fork
- 100
- Merge trung bình
- 1 ngày 20 giờ
- Pull request đã merge (30 ngày)
- 2
Chuẩn bị môi trường
- Có Dockerfile hoặc tệp Docker Compose
- Không có mẫu pull request
- Không 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 rubyjs/mini_racer
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
rubyjs/mini_racer#449 ·
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 52/100
rubyjs/mini_racer#450 ·
-
bug/crash platform: linux/x86
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 42/100
rubyjs/mini_racer#422 · 10 bình luận ·
-
platform: darwin/x86
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 35/100
rubyjs/mini_racer#388 · 4 bình luận ·
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 20/100
rubyjs/mini_racer#376 ·
Tất cả issue của rubyjs/mini_racer
Issue tương tự
-
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 88/100
fossasia/visdom-dev#69 ·
Maintainer thường phản hồi trong vòng 3 ngày
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 74/100
-
建议写成 1949-Đang mở
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 62/100
DeanChensj/jiangshan-map#133 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Frontend build fails with Frappe version-16: DataImport is no longer exported by @framework/uiĐang mởbug
Độ 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
-
ew
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 66/100
Maintainer thường phản hồi trong vòng 1 ngày