Skip to content

[CPLAT-12776] Port Sendbird patches to envoy v1.39.2 (Istio 1.31.1) - #27

Merged
gavin-jeong merged 11 commits into
release/v1.39.2-sendbird-customfrom
CPLAT-12776-v1.39.2-sendbird-custom
Oct 15, 2026
Merged

gavin-jeong merged 11 commits into
release/v1.39.2-sendbird-customfrom
CPLAT-12776-v1.39.2-sendbird-custom

Conversation

@gavin-jeong

Copy link
Copy Markdown

JIRA: https://sendbird.atlassian.net/browse/CPLAT-12776

Carries the Sendbird envoy patches onto ae1505b84c (v1.39.2-dev), the envoy
that istio/proxy 1.31.1 pins. Base for the 1.31.1 proxyv2 image.

Why this one is not a routine rebase

1.29.5 -> 1.30.2 moved envoy by 2 commits. 1.30.2 -> 1.31.1 moves it by
743 commits ahead / 78 behind. Of 11 patches, 4 cherry-picked clean and 7
conflicted.

Dropped: QUIC keylog

envoy 1.39 implements SSLKEYLOGFILE support natively, behind
envoy.restart_features.quic_keylog_support. Carrying ours would be a
duplicate definition, not a feature.

Hand-resolved (4)

All four were code movement or the absl::nullopt -> std::nullopt rename, not
competing logic:

File Resolution
source/extensions/clusters/redis/redis_cluster.cc kept our parentInfo() destruction guard, took upstream std::nullopt
source/extensions/filters/network/common/redis/supported_commands.h set union
source/common/formatter/http_specific_formatter.cc re-seated TraceSampledFormatter above the rewritten GrpcStatusFormatter factory
source/extensions/request_id/uuid/config{,_test}.cc see below

supported_commands.h is a set union, deliberately. Upstream added the
hexpire/hpexpire family while we added pubsub commands. Both lists are
absl::flat_hash_set initializers, so order carries no meaning -- but taking
either side wholesale would silently drop the other side commands, and an
unlisted command stops being routed or counted as a write. The merge was
computed as upstream + (ours - base) and then checked three ways against both
inputs:

prod (1.38.3) upstream (1.39.2) merged
simpleCommands 158 162 167
writeCommands 79 83 84

Nothing dropped from either side, nothing invented. The 5 additions to
simpleCommands are spublish, ssubscribe, subscribe, sunsubscribe,
watch; writeCommands gains spublish.

request_id/uuid needed its tests reworked, not just merged. Upstream added
two cases asserting getInteger() rejects a sign-prefixed id:

request_headers.setRequestId("-1aaaaaa-0012-0110-00ff-0c00400600ff");
EXPECT_FALSE(uuid_utils.getInteger(request_headers).has_value());

They put the sign at index 0, which getInteger() no longer reads -- our UUIDv7
change parses indices 28-35, where that id yields a perfectly valid 400600ff.
Merged as written, the cases would have failed. The sign was moved into the
parsed window (a0090100-0012-0110-00ff-0c00-1aaaaaa) so they still test what
they were written to test. StringUtil::strtoull rejects a leading + or -
explicitly, so the assertion holds for the new ids.

A triage trap worth recording

The first pass decided "upstream absorbed this" by grepping upstream for a
symbol each patch touches. onClusterSlotUpdate hit 6 times in
redis_cluster.cc, so the redis race/use-after-free patch was reported as
droppable. That was wrong -- it is an upstream function name that exists either
way. Probing for a symbol the patch introduces (parent_destroyed_,
isParentAlive) returns 0, so the patch is still ours. Dropping it would have
deleted a use-after-free guard in redis cluster destruction.

Verification

  • no conflict marker survives in source/, test/ or api/ (the 1.38.3
    branch shipped one for months; 870986ce exists to delete it)
  • all 7 Sendbird features present, each checked by a symbol the patch introduces
  • every ported commit has the same file set as its original, so no hand
    resolution silently dropped a file from a commit
  • compiles on both architectures: Build completed successfully, 17418 total actions (amd64) and 16988 (arm64), no warning in any resolved file
  • tarball for this commit resolves (HTTP 200), tagged
    build/proxyv2-1.31.1-sendbird-custom-v0.0.1 so branch cleanup cannot 404 the
    proxy-istio build

Security checklist (Infrastructure code)

  • I have checked below conditions:
    • This PR does not contain any SecurityGroup rule changes which are not allowed via INF Jira ticket
    • This PR does not contain any public open SecurityGroup inbound rules(0.0.0.0/0) except the predefined service port
    • This PR does not contain any resources in a public subnet except those are needed with a specific technical reason
    • This PR does not contain any credentials (AWS Secret key, password, API tokens, etc)
    • This PR does not contain any IAM users which are not allowed via UAC Jira approval
    • The contents of this PR is following the guide from OSWAP and SendBird Secure Software Development Lifecycle

dlunch and others added 11 commits October 14, 2026 15:43
(cherry picked from commit 8287a74)
Include code formatting improvements for consistent style in trace test files.

(cherry picked from commit 2af673c)
…uction

This commit combines multiple fixes for Redis cluster stability:

- Fix race conditions in cluster destruction by capturing is_destroying_ flag
- Add comprehensive null checks to prevent segfaults during cluster destruction
- Use local shared_ptr copies to prevent race conditions
- Use shared_from_this() to keep RedisDiscoverySession alive during timer callbacks
- Fix use-after-free by using session-owned flag instead of parent reference

These fixes ensure safe cleanup of Redis clusters and prevent crashes
during cluster removal and timer callback execution.

(cherry picked from commit 6bd87fc)
(cherry picked from commit a298a4b)
Add TraceSampledFormatter that uses Envoy's internal tracing decision
(stream_info.traceReason())

This approach works correctly at trace origin points (e.g., Istio Ingress
Gateway) where no incoming traceparent header exists.

Usage: %TRACE_SAMPLED% in access log format
Returns: "true" if traced, "false" otherwise

Co-Authored-By: Claude Opus 4.5 <[email protected]>
(cherry picked from commit f733d65)
Add per-shard statistics for Redis proxy to track hot shard usage:

- enable_per_shard_stats: Emits per-shard request counters
  - upstream_rq_total: Total requests to each shard
  - upstream_rq_success: Successful requests
  - upstream_rq_failure: Failed requests
  - upstream_rq_active: Active requests (gauge)

- enable_per_shard_latency_stats: Emits latency histogram
  - upstream_rq_time: Request latency in microseconds

All metrics are scoped under: cluster.<cluster_name>.shard.<host_address>.*

Per-shard command-level stats are also recorded when enable_command_stats
is enabled alongside the per-shard options.

Note: These options may significantly increase metric cardinality in
large clusters. Use with caution in production environments.

(cherry picked from commit 41e7a3d)
In v1.37, FormatterProvider uses format/formatValue with Context&
instead of formatWithContext/formatValueWithContext with
HttpFormatterContext&. Updated TraceSampledFormatter accordingly.

(cherry picked from commit 3f9d804)
Cherry-pick of eval_ro/evalsha_ro support (4759ad9) onto upstream
v1.38.3 left a stray diff3 base marker
'||||||| parent of 36be96a' in redis_cluster_lb_test.cc, which also
dropped the closing brace of the LocalZoneAffinityEmptyClientZone test.
Replace the marker with the missing '}' so the file compiles and both
the zone-aware and ReadOnlyCommand tests are well-formed.

CPLAT-10838

(cherry picked from commit 870986c)
envoy 1.39 declares FormatterProvider::format as returning
std::optional<std::string>, and every other formatter in
http_specific_formatter.h follows it. TraceSampledFormatter was the only
one left on absl::optional, which overrides correctly today only because
Abseil aliases absl::optional to std::optional under ABSL_USES_STD_OPTIONAL.
Depending on that alias to satisfy an `override` is a build break waiting
for a flag change, so match the base signature directly.
@upwind-code-us

upwind-code-us Bot commented Oct 14, 2026 •

Copy link
Copy Markdown

Upwind Upwind Code Scan - ⚠️ Warn

60 newly introduced vulnerabilities · 0 resolved · 62 total in this PR vs main

Total breakdown: 🔴 6 Critical | 🔶 39 High | 🟡 16 Medium | ⚪ 1 Unknown


🔴 Critical · 5 findings
CVE Package Version Fix
CVE-2026-78676 gitpython 3.1.50 3.1.59
CVE-2026-102266 pyjwt 2.13.0 2.14.0
CVE-2026-102268 pyjwt 2.13.0 2.14.0
CVE-2026-78663 golang.org/x/net v0.55.0 0.60.0
CVE-2026-102267 pyjwt 2.13.0 2.14.0

🔶 High · 39 findings
CVE Package Version Fix
CVE-2026-76222 gitpython 3.1.50 3.1.58
CVE-2026-102274 pyjwt 2.13.0 2.14.0
CVE-2026-69247 cryptography 46.0.7 50.0.0
CVE-2026-76218 gitpython 3.1.50 3.1.58
CVE-2026-67322 gitpython 3.1.50 3.1.52
CVE-2026-73625 gitpython 3.1.50 —
CVE-2026-101917 pyjwt 2.13.0 2.14.0
UWV-2026-48452 google.golang.org/grpc v1.79.3 —
CVE-2026-59885 pyasn1 0.6.3 0.6.4
CVE-2026-102275 pyjwt 2.13.0 2.15.0
CVE-2026-78669 golang.org/x/net v0.55.0 0.60.0
CVE-2026-87817 gitpython 3.1.50 3.1.60
CVE-2026-67325 gitpython 3.1.50 3.1.51
CVE-2026-102271 pyjwt 2.13.0 2.14.0
CVE-2026-84445 google.golang.org/grpc v1.79.3 1.82.2
CVE-2026-84304 google.golang.org/grpc v1.79.3 1.83.1
CVE-2026-67323 gitpython 3.1.50 3.1.51
CVE-2026-69244 aiohttp 3.14.1 3.14.3
CVE-2026-78675 gitpython 3.1.50 3.1.59
CVE-2026-102272 pyjwt 2.13.0 2.14.0
CVE-2026-78677 gitpython 3.1.50 3.1.59
CVE-2026-69247 cryptography 47.0.0 50.0.0
CVE-2026-76219 gitpython 3.1.50 3.1.58
CVE-2026-87819 gitpython 3.1.50 3.1.60
CVE-2026-97689 urllib3 2.7.0 2.8.0
CVE-2026-69249 cryptography 47.0.0 49.0.0
CVE-2026-46600 golang.org/x/net v0.55.0 0.56.0
CVE-2026-56852 golang.org/x/text v0.37.0 0.39.0
CVE-2026-78660 golang.org/x/net v0.55.0 0.60.0
CVE-2026-76220 gitpython 3.1.50 3.1.58
CVE-2026-102273 pyjwt 2.13.0 2.14.0
CVE-2026-59884 pyasn1 0.6.3 0.6.4
CVE-2026-56851 golang.org/x/text v0.37.0 0.41.0
CVE-2026-97687 urllib3 2.7.0 2.8.0
CVE-2026-59886 pyasn1 0.6.3 0.6.4
CVE-2026-55099 icalendar 7.1.1 7.1.3
CVE-2026-69249 cryptography 46.0.7 49.0.0
CVE-2026-78659 golang.org/x/net v0.55.0 0.60.0
CVE-2026-101918 pyjwt 2.13.0 2.15.0

🟡 Medium · 15 findings
CVE Package Version Fix
CVE-2026-78678 gitpython 3.1.50 3.1.59
CVE-2026-102270 pyjwt 2.13.0 2.14.0
CVE-2026-97688 urllib3 2.7.0 2.8.0
CVE-2026-78679 gitpython 3.1.50 3.1.59
CVE-2026-104874 multidict 6.7.1 6.9.1
CVE-2026-59881 aiohttp 3.14.1 3.14.2
CVE-2026-103001 pyjwt 2.13.0 —
CVE-2026-84303 google.golang.org/grpc v1.79.3 1.83.1
CVE-2026-59890 setuptools 82.0.1 83.0.0
CVE-2026-76217 gitpython 3.1.50 3.1.58
CVE-2026-69243 aiohttp 3.14.1 3.14.2
CVE-2026-102269 pyjwt 2.13.0 2.14.0
CVE-2026-69248 cryptography 47.0.0 49.0.0
CVE-2026-102265 pyjwt 2.13.0 2.14.0
CVE-2026-69248 cryptography 46.0.7 49.0.0

⚪ Unknown · 1 finding
CVE Package Version Fix
CVE-2026-97032 golang.org/x/net v0.55.0 0.60.0

View full analysis in Upwind Console

Scan completed in 11s

Scan history (1 scan)
Commit Scanned at New Resolved Net
5ff9653 < 2026-10-14 09:29 UTC +60 0 +60

Last scanned: 5ff9653 · 2026-10-14 09:29 UTC

@upwind-code-us

upwind-code-us Bot commented Oct 14, 2026 •

Copy link
Copy Markdown

Upwind Upwind IaC Scan - ✅ Passed

0 newly introduced misconfigurations · 0 resolved · 5 total in this PR vs main

Total breakdown: 🔶 2 High | 🟡 1 Medium | 🟢 2 Low

View full analysis in Upwind Console →

Scan completed in 4s

Scan history (1 scan)
Commit Scanned at New Resolved Net
5ff9653 < 2026-10-14 09:29 UTC 0 0 0

Last scanned: 5ff9653 · 2026-10-14 09:29 UTC

@Kairo-Kim Kairo-Kim added the auto-review/approved Auto-approved by pr-approver label Oct 14, 2026

@jinsekim jinsekim left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@semgrep-code-sendbird

Copy link
Copy Markdown

Semgrep found 1 ssc-0c30345c-710e-41c6-b371-0d0ae8ec73e1 finding:

🟠 High severity issue identified in your code:

Risk: Affected versions of cryptography are vulnerable to Dependency on Vulnerable Third-Party Component / Out-of-bounds Read. The PyPI wheels for the cryptography package statically link a version of OpenSSL that contains security vulnerabilities (including a high-severity use-after-free in PKCS7_verify and several denial-of-service and forgery issues). Any application installed from an affected wheel ships the vulnerable OpenSSL binary, so an attacker may trigger out-of-bounds reads, crashes, or other memory-safety issues through cryptographic operations that reach the bundled OpenSSL code.

Manual Review Advice: A vulnerability from this advisory is reachable if you installed the cryptography package from a PyPI binary wheel not built from a source distribution

Fix: Upgrade this library to at least version 48.0.1 at envoy/tools/base/requirements.txt:545.

Reference(s): GHSA-537c-gmf6-5ccf

Semgrep found 1 ssc-27437c7b-e7dd-4126-948d-05cba4bb51bf finding:

  • source/extensions/dynamic_modules/builtin_extensions/hickory_dns.rs

🟠 High severity issue identified in your code:

Risk: Affected versions of hickory-resolver are vulnerable to Insufficient Control of Network Message Volume (Network Amplification) / Loop with Unreachable Exit Condition ('Infinite Loop') / Uncontrolled Resource Consumption. hickory-resolver's NameServerPool::try_send re-queues a request to the same nameserver with UDP disabled whenever a response has the TC (truncated) bit set, without checking which transport answered and without any retry counter. A malicious upstream or authoritative nameserver that answers with TC=1 over TCP as well keeps the resolver spinning in a tight retry loop until the per-request deadline expires, which exhausts resources (denial of service). Every query sent by Resolver/TokioResolver, NameServerPool, and the recursor::Recursor goes through this loop.

Fix: Upgrade this library to at least version 0.26.2 at envoy/Cargo.lock:485.

Reference(s): GHSA-6w6g-hm98-mhgm

@gavin-jeong
gavin-jeong changed the base branch from release/v1.38.3-sendbird-custom to release/v1.39.2-sendbird-custom October 14, 2026 09:58
@gavin-jeong

Copy link
Copy Markdown
Author

On the Upwind "60 newly introduced vulnerabilities (6 Critical)" finding: it is real data measured against the wrong baseline for this repo, and this PR moves every flagged dependency forward, not backward.

This PR touches no dependency manifest. All 29 changed files are source/, test/, api/ and one docs/ rst:

git diff --name-only ae1505b84c..HEAD | grep -iE "requirements|go\.(mod|sum)|Cargo\.|package.*json|\.bzl$"
# no output

Upwind compares against main, which is not what we run. main on this fork tracks upstream envoy main — 28,801 commits ahead of ae1505b84c, the commit Istio 1.31.1 pins. Production runs release/v1.38.3-sendbird-custom. Against the branch that is actually deployed:

package running today (1.38.3) this PR (1.39.2) on main
pyjwt[crypto] 2.12.1 2.13.0 2.13.0
gitpython 3.1.47 3.1.50 3.1.59
golang.org/x/net v0.48.0 v0.55.0 v0.58.0

So the three packages named in the scan summary are each newer here than in production. They read as "newly introduced" only because main is further ahead still, and a diff against main counts every dependency that is behind it.

That gap is not something this PR can close. Istio pins one exact envoy commit (ENVOY_SHA in istio/proxy 1.31.1), and the proxyv2 image has to be built from that commit or the sidecar will not match istiod. Bumping these dependencies here would mean diverging from the pin, which is the one thing this branch must not do. They move when Istio moves.

Worth noting the scan also counts docs/tools/python/requirements.txt and tools/base/requirements.txt — envoy documentation and build tooling, not code linked into the proxy binary. golang.org/x/net is in envoy go.mod, which builds test and tooling binaries, not the C++ proxy.

Suggested read: treat the Upwind delta on this PR as "the Istio 1.31.1 pin vs envoy main", which is information about Istio release cadence rather than about this change. If the CVEs matter on their own, the place to act is a separate review of whether we can carry dependency bumps on top of the pin — that would apply equally to the 1.30.2 branch running in production today, which has strictly older versions of all three.

@gavin-jeong

Copy link
Copy Markdown
Author

Tested the built binary before merge. The two patches I resolved by hand were each verified against a differential, since both could compile cleanly and fail silently.

Image under test: mesg/istio/proxyv2:v1.31.1-sendbird-custom-v0.0.1, built from this branch (https://github.com/sendbird/proxy-istio/pull/16).

envoy: 9f4f4328f63026a6cf885cb6c6dedf7d7e208877/1.39.2-dev/Modified/RELEASE/BoringSSL

TRACE_SAMPLED formatter

Its signature was changed by hand (absl::optional -> std::optional, formatWithContext -> format) and it was re-seated above upstream rewritten GrpcStatusFormatter factory. So registration is the thing a successful compile does not prove. Same config, two images:

ours:                  configuration /cfg/trace_sampled.yaml OK
istio/proxyv2:1.31.1:  error ... Not supported field in StreamInfo: TRACE_SAMPLED

And it renders at runtime, not only at config load — the access log line was sampled=false id=f1a13a5a-4366-7423-92ec-a14235ed87b1.

supported_commands.h set union

This is the resolution most likely to lose something quietly: the list is an absl::flat_hash_set built at runtime, so a command dropped during the union compiles and only fails in production. Probed a redis_proxy listener pointed at a dead upstream, where an unlisted command is rejected by the command splitter before any connection is attempted (command_splitter_impl.cc:1050, ERR unknown command):

command origin ours istio/proxyv2:1.31.1
eval_ro, evalsha_ro our patch accepted rejected
subscribe, ssubscribe, sunsubscribe, spublish our patch accepted rejected
hexpire, hpexpire, hpersist, httl upstream, new in 1.39 accepted accepted
definitely_not_a_command control rejected rejected

13/13 as expected on ours, and the upstream column shows the probe actually discriminates. Both sides of the union survive — which is what the diff counts in the PR body asserted statically and this confirms at runtime.

request_id UUIDv7

Generated ids still carry version nibble 7 at index 15 (f1a13a5a-4366-7423-...), matching the 1.30.2 image. On the reworked sign-prefix tests: StringUtil::strtoull rejects a leading +/- explicitly before std::strtoull runs (source/common/common/utility.cc:370), so a0090100-0012-0110-00ff-0c00-1aaaaaa — sign at index 28, inside the window getInteger now parses — keeps those two EXPECT_FALSE assertions meaningful.

In a cluster

The image also ran as a real sidecar against istiod 1.31.1 on a dev cluster: all four xDS types ACKED per istiod /debug/syncz, update_rejected: 0, SDS cert issued, mTLS traffic 200 with both SPIFFE principals present, 0 restarts, clean logs. Details on https://github.com/sendbird/proxy-istio/pull/16.

A note on watch, not introduced here

watch sits in both simpleCommands and transactionCommands after the merge. That came from our own pubsub patch (a298a4b6), not from this port — it is the same on release/v1.38.3-sendbird-custom running in production. Behaviour is identical to upstream because transactionCommands registers last (command_splitter_impl.cc:1014 vs :981) and RadixTree::add defaults to overwrite_existing = true, so watch resolves to transaction_handler_. Redundant rather than wrong, but it would become a real behaviour change if that registration order were ever swapped.

@gavin-jeong
gavin-jeong merged commit a51dc14 into release/v1.39.2-sendbird-custom Oct 15, 2026
5 checks passed
@gavin-jeong
gavin-jeong deleted the CPLAT-12776-v1.39.2-sendbird-custom branch October 15, 2026 06:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

auto-review/approved Auto-approved by pr-approver

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants