[JsRuntimeHost] UrlLib: Apple backend use-after-free when a UrlRequest is destroyed in flight
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ó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 30/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Ít trao đổi
- Công nghệ
- cpp, ios, macos
- Lĩnh vực
- networking
Hướng nghiên cứu
Start with UrlRequest_Apple.mm, specifically the SendAsync() completion handler and the Impl class, which has no destructor and never reads m_cancellationSource or calls [task cancel]. Check how ImplBase::~ImplBase() calls Abort() and why that does not reach the NSURLSessionDataTask. Done means a request destroyed in flight no longer lets its handler write into freed memory, verified with the UrlLib tests on Apple, and the other backends audited for the same pattern.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Split out from review feedback on BabylonJS/UrlLib#37 (filed here because BabylonJS/UrlLib has Issues disabled).
Problem
On the Apple (NSURLSession) backend, an in-flight UrlRequest that is destroyed before it settles leads to a use-after-free.
UrlRequest_Apple.mm's SendAsync() builds a completion handler that writes m_statusCode, m_headers, m_responseString / m_responseBuffer and calls SetError(...) — so it implicitly captures a raw this. Nothing keeps the Impl alive for the duration of the task:
UrlRequest::Implthere has no destructor.- It never reads
m_cancellationSource. - It never calls
[task cancel].
ImplBase::~ImplBase() calls Abort(), but Abort() only does m_cancellationSource.cancel(), which this backend ignores. So destroying a UrlRequest neither stops the resumed NSURLSessionDataTask nor extends the impl's lifetime — the task keeps running and its handler later writes into freed memory.
Impact
Any caller that drops a UrlRequest before it completes (e.g. abandoning a request on teardown) can corrupt whatever the freed allocation is reused for. This is not theoretical: it was observed in UrlLib CI, where an abandoned request's late failure handler wrote its error into a subsequent test's Impl, making an unrelated, previously-passing test report NSURLErrorCancelled (-999) with a non-empty ErrorString/ErrorSymbol.
Notes
- Pre-existing; not introduced by BabylonJS/JsRuntimeHost#37. That PR's new test was simply the first code to exercise it, and now works around it by waiting for the request to settle before leaving scope.
- Worth auditing the other backends for the same pattern.
Possible fixes
- Have
Implinheritstd::enable_shared_from_thisand capture a strong reference in the completion handler, so the impl outlives the task. - And/or make
Abort()actually cancel theNSURLSessionDataTaskon this backend, honoringm_cancellationSource.
- Ngôn ngữ chính
- C++
- Star
- 931
- Fork
- 169
- Merge trung bình
- 2 ngày 17 giờ
- Pull request đã merge (30 ngày)
- 66
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Không 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 BabylonJS/BabylonNative
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
BabylonJS/BabylonNative#2138 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
BabylonJS/BabylonNative#2042 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
BabylonJS/BabylonNative#2052 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
testing
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 45/100
BabylonJS/BabylonNative#2136 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Support useNDCHalfZRange (half-range NDC depth) so Babylon.js half-range depth visual tests can runCó thể đã có người làm Có pull request liên kết đang mở hoặc đã được merge. Đang mở
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 48/100
BabylonJS/BabylonNative#2134 ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của BabylonJS/BabylonNative
Issue tương tự
-
Make the HTTP server's keep-alive and headers timeouts configurableCó thể đã có người làm @mattgodbolt đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
compiler-explorer/compiler-explorer#9902 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
Nixtla/statsforecast#1371 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
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
-
[Bug]: pip install -U cudaq-qec fails with a conflict that names cudaq-qec itselfCó thể đã có người làm @fedonman đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
Maintainer thường phản hồi trong vòng 1 ngày
-
task
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
SparseLinearAlgebra/spla#316 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày