eds: use-after-free in LEDS callback on subsequent EDS updates#43667
Merged
botengyao merged 2 commits intoenvoyproxy:mainfrom Mar 2, 2026
Merged
eds: use-after-free in LEDS callback on subsequent EDS updates#43667botengyao merged 2 commits intoenvoyproxy:mainfrom
botengyao merged 2 commits intoenvoyproxy:mainfrom
Conversation
The LEDS subscription callback lambda captured `used_load_assignment` by value as a raw pointer to the object owned by the `cluster_load_assignment_` unique_ptr. When a subsequent EDS update reassigned `cluster_load_assignment_`, the old object was destroyed but existing LEDS subscriptions (not recreated for unchanged configs) still held the dangling pointer. When the LEDS subscription later fired its callback (e.g. onConfigUpdateFailed), dereferencing this pointer caused a segfault. Stack trace: #0: [0x77b9d6de8330] envoyproxy#1: Envoy::Upstream::EdsClusterImpl::BatchUpdateHelper::batchUpdate() envoyproxy#2: Envoy::Upstream::PrioritySetImpl::batchHostUpdate() envoyproxy#3: std::__1::__function::__func<>::operator()() envoyproxy#4: Envoy::Upstream::LedsSubscription::onConfigUpdateFailed() envoyproxy#5: Envoy::Config::GrpcSubscriptionImpl::onConfigUpdateFailed() envoyproxy#6: event_process_active_single_queue envoyproxy#7: event_base_loop envoyproxy#8: Envoy::Server::InstanceBase::run() Fix by capturing `this` and accessing `cluster_load_assignment_` directly, which always reflects the current valid assignment. Signed-off-by: William Dauchy <william.dauchy@datadoghq.com>
70e391e to
ee9057a
Compare
Contributor
Author
|
/retest transients |
1 similar comment
Contributor
Author
|
/retest transients |
Contributor
Author
|
cc @botengyao |
botengyao
approved these changes
Mar 2, 2026
bmjask
pushed a commit
to bmjask/envoy
that referenced
this pull request
Mar 14, 2026
…proxy#43667) Commit Message: The LEDS subscription callback lambda captured `used_load_assignment` by value as a raw pointer to the object owned by the `cluster_load_assignment_` unique_ptr. When a subsequent EDS update reassigned `cluster_load_assignment_`, the old object was destroyed but existing LEDS subscriptions (not recreated for unchanged configs) still held the dangling pointer. When the LEDS subscription later fired its callback (e.g. onConfigUpdateFailed), dereferencing this pointer caused a segfault. Stack trace: ``` #0: [0x77b9d6de8330] envoyproxy#1: Envoy::Upstream::EdsClusterImpl::BatchUpdateHelper::batchUpdate() envoyproxy#2: Envoy::Upstream::PrioritySetImpl::batchHostUpdate() envoyproxy#3: std::__1::__function::__func<>::operator()() envoyproxy#4: Envoy::Upstream::LedsSubscription::onConfigUpdateFailed() envoyproxy#5: Envoy::Config::GrpcSubscriptionImpl::onConfigUpdateFailed() envoyproxy#6: event_process_active_single_queue envoyproxy#7: event_base_loop envoyproxy#8: Envoy::Server::InstanceBase::run() ``` Fix by capturing `this` and accessing `cluster_load_assignment_` directly, which always reflects the current valid assignment. Additional Description: Risk Level: Testing: Docs Changes: Release Notes: Platform Specific Features: [Optional Runtime guard:] [Optional Fixes #Issue] [Optional Fixes commit #PR or SHA] [Optional Deprecated:] [Optional [API Considerations](https://github.com/envoyproxy/envoy/blob/main/api/review_checklist.md):] Signed-off-by: William Dauchy <william.dauchy@datadoghq.com> Signed-off-by: bjmask <11672696+bjmask@users.noreply.github.com>
bvandewalle
pushed a commit
to bvandewalle/envoy
that referenced
this pull request
Mar 17, 2026
…proxy#43667) Commit Message: The LEDS subscription callback lambda captured `used_load_assignment` by value as a raw pointer to the object owned by the `cluster_load_assignment_` unique_ptr. When a subsequent EDS update reassigned `cluster_load_assignment_`, the old object was destroyed but existing LEDS subscriptions (not recreated for unchanged configs) still held the dangling pointer. When the LEDS subscription later fired its callback (e.g. onConfigUpdateFailed), dereferencing this pointer caused a segfault. Stack trace: ``` #0: [0x77b9d6de8330] envoyproxy#1: Envoy::Upstream::EdsClusterImpl::BatchUpdateHelper::batchUpdate() envoyproxy#2: Envoy::Upstream::PrioritySetImpl::batchHostUpdate() envoyproxy#3: std::__1::__function::__func<>::operator()() envoyproxy#4: Envoy::Upstream::LedsSubscription::onConfigUpdateFailed() envoyproxy#5: Envoy::Config::GrpcSubscriptionImpl::onConfigUpdateFailed() envoyproxy#6: event_process_active_single_queue envoyproxy#7: event_base_loop envoyproxy#8: Envoy::Server::InstanceBase::run() ``` Fix by capturing `this` and accessing `cluster_load_assignment_` directly, which always reflects the current valid assignment. Additional Description: Risk Level: Testing: Docs Changes: Release Notes: Platform Specific Features: [Optional Runtime guard:] [Optional Fixes #Issue] [Optional Fixes commit #PR or SHA] [Optional Deprecated:] [Optional [API Considerations](https://github.com/envoyproxy/envoy/blob/main/api/review_checklist.md):] Signed-off-by: William Dauchy <william.dauchy@datadoghq.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Commit Message:
The LEDS subscription callback lambda captured
used_load_assignmentby value as a raw pointer to the object owned by thecluster_load_assignment_unique_ptr. When a subsequent EDS update reassignedcluster_load_assignment_, the old object was destroyed but existing LEDS subscriptions (not recreated for unchanged configs) still held the dangling pointer. When the LEDS subscription later fired its callback (e.g. onConfigUpdateFailed), dereferencing this pointer caused a segfault.Stack trace:
Fix by capturing
thisand accessingcluster_load_assignment_directly, which always reflects the current valid assignment.Additional Description:
Risk Level:
Testing:
Docs Changes:
Release Notes:
Platform Specific Features:
[Optional Runtime guard:]
[Optional Fixes #Issue]
[Optional Fixes commit #PR or SHA]
[Optional Deprecated:]
[Optional API Considerations:]