Skip to content

fix: prevent nil pointer dereference in envoyGoFilterOnHttpData#17

Closed
johnlanni wants to merge 277 commits intomainfrom
fix-nil-pointer-in-onhttpdata
Closed

fix: prevent nil pointer dereference in envoyGoFilterOnHttpData#17
johnlanni wants to merge 277 commits intomainfrom
fix-nil-pointer-in-onhttpdata

Conversation

@johnlanni
Copy link
Copy Markdown

Description

Replace getState() with getOrCreateState() in envoyGoFilterOnHttpData to handle cases where OnHttpData is called before OnHttpHeader.

Problem

When envoyGoFilterOnHttpData is called before envoyGoFilterOnHttpHeader, the s.req pointer is not yet initialized, causing a nil pointer dereference panic:

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x7fe25dce3faf]

Solution

  • Changed getState(s) to getOrCreateState(s) in line 239
  • getOrCreateState checks if the request exists and creates it if needed, preventing the nil pointer access
  • This matches the pattern already used in envoyGoFilterOnHttpHeader

Testing

  • Fixes the SIGSEGV panic reported in production logs

phlax and others added 30 commits August 22, 2023 19:44
Signed-off-by: Ryan Northey <ryan@synca.io>
Signed-off-by: Ryan Northey <ryan@synca.io>
Signed-off-by: Ryan Northey <ryan@synca.io>
Signed-off-by: Ryan Northey <ryan@synca.io>
…lidation are set (envoyproxy#29002)

Signed-off-by: Xie Zhihao zhihao.xie@intel.com

Commit Message: tls: fix handshake failure when both private key provider and cert validation are set
Additional Description:

After envoyproxy#24297, when both private key provider and validation are set, e.g., using Envoy as sidecars, handshake may end with SSL internal error and HTTP 503 will return.

When both private key provider and validation are set, when the private key provider completed its calculation and resumed the handshake (ssl_do_handshake), an async cert validation will be triggered. If the custom validation is not provided, then the async cert validation will complete in the sync way and resume the handshake again (ssl_do_handshake), which cause the error.

Risk Level: Low
Testing: Unit tests
Docs Changes: N/A
Release Notes: Added
Platform Specific Features: N/A
Fixes commit 55a4cc7

Signed-off-by: Xie Zhihao <zhihao.xie@intel.com>
Backport of envoyproxy#29263

Fixes envoyproxy#28415

This reverts part of envoyproxy#24923

Signed-off-by: tyxia <tyxia@google.com>
Signed-off-by: Greg Greenway <ggreenway@apple.com>
Signed-off-by: Ryan Northey <ryan@synca.io>
Signed-off-by: Ryan Northey <ryan@synca.io>
Signed-off-by: Ryan Northey <ryan@synca.io>
Signed-off-by: Ryan Northey <ryan@synca.io>
Signed-off-by: Ryan Northey <ryan@synca.io>
Signed-off-by: Ryan Northey <ryan@synca.io>
Signed-off-by: Ryan Northey <ryan@synca.io>
Signed-off-by: Ryan Northey <ryan@synca.io>
Signed-off-by: Ryan Northey <ryan@synca.io>
Signed-off-by: Ryan Northey <ryan@synca.io>
* tools/format: Remove unused script
* readme: Update code format commands
* bazel/ci: Prevent leaking of build tools into env
* mobile/ci: Include format script in CI triggers

Signed-off-by: Ryan Northey <ryan@synca.io>

Signed-off-by: phlax <phlax@users.noreply.github.com>
Signed-off-by: Ryan Northey <ryan@synca.io>
Signed-off-by: Ryan Northey <ryan@synca.io>
Signed-off-by: Ryan Northey <ryan@synca.io>
Signed-off-by: Ryan Northey <ryan@synca.io>
Signed-off-by: Ryan Northey <ryan@synca.io>
Signed-off-by: Ryan Northey <ryan@synca.io>
tools: Add option to skip bazel for format fix

Signed-off-by: Joshua Marantz <jmarantz@google.com>

Signed-off-by: Ryan Northey <ryan@synca.io>
Signed-off-by: Ryan Northey <ryan@synca.io>
Signed-off-by: Ryan Northey <ryan@synca.io>
Signed-off-by: Ryan Northey <ryan@synca.io>
Signed-off-by: Ryan Northey <ryan@synca.io>
)

Signed-off-by: Jacob Bohanon <jacob.bohanon@solo.io>
Signed-off-by: Ryan Northey <ryan@synca.io>
johnlanni and others added 26 commits March 25, 2025 21:31
Signed-off-by: yongjie.yyj <yeyeyongjie@gmail.com>
Signed-off-by: spacewander <spacewanderlzx@gmail.com>
Signed-off-by: wangkai19 <wangkai19@corp.netease.com>
Signed-off-by: doujiang24 <doujiang24@gmail.com>
Signed-off-by: Meshkati <meshkat76@gmail.com>
Signed-off-by: Michael Sauter <mail@michaelsauter.net>
Signed-off-by: Ryan Northey <ryan@synca.io>
Signed-off-by: Braden Bassingthwaite <bbassingthwaite@digitalocean.com>
Signed-off-by: Willem Veerman <6502426+willemveerman@users.noreply.github.com>
Signed-off-by: duxin <duxin40@gmail.com>
Co-authored-by: antJack <52443884+antJack@users.noreply.github.com>
Co-authored-by: 罗泽轩 <spacewanderlzx@gmail.com>
Co-authored-by: StarryNight <wangkai19@corp.netease.com>
Co-authored-by: doujiang24 <doujiang24@gmail.com>
Co-authored-by: Seyed Mostafa Meshkati <meshkat76@gmail.com>
Co-authored-by: phlax <phlax@users.noreply.github.com>
Co-authored-by: Braden Bassingthwaite <bradenbass@gmail.com>
Co-authored-by: Braden Bassingthwaite <bbassingthwaite@digitalocean.com>
Co-authored-by: Willem Veerman <6502426+willemveerman@users.noreply.github.com>
Co-authored-by: duxin40 <33946910+duxin40@users.noreply.github.com>
…proxy#38597) (#7)

Signed-off-by: François JACQUES <fjacques@murex.com>
Co-authored-by: François JACQUES <fjacques@murex.com>
…or handle stream response body, getUpstreamHosts & setUpstreamOverrideHost for self-defined load balance policy (#8)
cherry-pick: envoyproxy@090e73d

use directLocalAddress instead of localAddress in LocalPortValueExtractorImpl of srds
Link: https://code.alibaba-inc.com/Ingress/envoy/codereview/21602142
* support direct local address

* add metrics stats
Signed-off-by: jue-yin <jueyin.hsl@alibaba-inc.com>
Co-authored-by: jueyin.hsl <jueyin.hsl@alibaba-inc.com>
Change-Id: If54bbcd6a39c6ef13243bd2b20c3b2c848f95ae6
Change-Id: Ie2f2feb07941843f202825061f84cb1bf546f098
Replace getState() with getOrCreateState() to handle cases where
OnHttpData is called before OnHttpHeader, preventing SIGSEGV panic
when s.req is not yet initialized.

Fixes: panic: runtime error: invalid memory address or nil pointer dereference
@lingma-agents
Copy link
Copy Markdown

lingma-agents bot commented Jan 31, 2026

🔍 代码审查进行中

⏳ 正在审查

⏰️ 剩余时间:约需数分钟

🔄 分支流向: fix-nil-pointer-in-onhttpdatamain

📦 提交: 审查当前PR从94a69e52b9a4e8的提交。


📒 文件清单 (100 个文件)
新增: 21 个文件
删除: 38 个文件
🔄 重命名: 1 个文件
📝 变更: 40 个文件

✅ 新增文件:

  • .azure-pipelines/ci.yml
  • .azure-pipelines/docker/clean_docker.sh
  • .azure-pipelines/docker/create_cache.sh
  • .azure-pipelines/docker/load_caches.sh
  • .github/config.yml
  • .github/workflows/envoy-dependency.yml
  • .github/workflows/request.yml
  • .github/workflows/verify-requirements.in
  • .github/workflows/verify-requirements.txt
  • api/contrib/envoy/extensions/custom_cluster_plugins/cluster_fallback/v3/BUILD
  • api/contrib/envoy/extensions/custom_cluster_plugins/cluster_fallback/v3/cluster_fallback.proto
  • api/contrib/envoy/extensions/filters/http/http_dubbo_transcoder/v3/BUILD
  • api/contrib/envoy/extensions/filters/http/http_dubbo_transcoder/v3/http_dubbo_transcoder.proto
  • api/contrib/envoy/extensions/filters/http/llm_inference/v3/BUILD
  • api/contrib/envoy/extensions/filters/http/llm_inference/v3/llm_inference.proto
  • api/contrib/envoy/extensions/filters/http/mcp_sse_stateful_session/v3alpha/BUILD
  • api/contrib/envoy/extensions/filters/http/mcp_sse_stateful_session/v3alpha/mcp_sse_stateful_session.proto
  • api/contrib/envoy/extensions/http/mcp_sse_stateful_session/envelope/v3alpha/BUILD
  • api/contrib/envoy/extensions/http/mcp_sse_stateful_session/envelope/v3alpha/envelope.proto
  • api/contrib/envoy/extensions/upstreams/http/dubbo_tcp/v3/BUILD
  • api/contrib/envoy/extensions/upstreams/http/dubbo_tcp/v3/tcp_connection_pool.proto

❌ 删除文件:

  • .azure-pipelines/bazel.yml
  • .azure-pipelines/docker/load_cache.sh
  • .azure-pipelines/stage/macos.yml
  • .azure-pipelines/stage/windows.yml
  • .github/actions/do_ci/action.yml
  • .github/actions/env/action.yml
  • .github/actions/pr_notifier/pr_notifier.py
  • .github/actions/pr_notifier/requirements.in
  • .github/actions/pr_notifier/requirements.txt
  • .github/actions/publish/release/setup/action.yml
  • .github/actions/verify/examples/setup/action.yml
  • .github/workflows/_cache_docker.yml
  • .github/workflows/_ci.yml
  • .github/workflows/_env.yml
  • .github/workflows/_stage_publish.yml
  • .github/workflows/_stage_verify.yml
  • .github/workflows/_workflow-start.yml
  • .github/workflows/commands.yml
  • .github/workflows/envoy-prechecks.yml
  • .github/workflows/envoy-publish.yml
  • .github/workflows/mobile-android_build.yml
  • .github/workflows/mobile-android_tests.yml
  • .github/workflows/mobile-asan.yml
  • .github/workflows/mobile-cc_tests.yml
  • .github/workflows/mobile-compile_time_options.yml
  • .github/workflows/mobile-core.yml
  • .github/workflows/mobile-coverage.yml
  • .github/workflows/mobile-docs.yml
  • .github/workflows/mobile-format.yml
  • .github/workflows/mobile-ios_build.yml
  • .github/workflows/mobile-ios_tests.yml
  • .github/workflows/mobile-perf.yml
  • .github/workflows/mobile-release_validation.yml
  • .github/workflows/mobile-traffic_director.yml
  • .github/workflows/mobile-tsan.yml
  • .github/workflows/mobile_release.yml
  • .github/workflows/workflow-complete.yml
  • api/bazel/utils.bzl

🔄 重命名文件:

  • examples/grpc-bridge/server/kv/go.modapi/contrib/envoy/extensions/filters/http/mcp_proxy/BUILD

📝 变更文件:

  • .azure-pipelines/cached.yml
  • .azure-pipelines/docker/prepare_cache.sh
  • .azure-pipelines/docker/prime_cache.sh
  • .azure-pipelines/docker/save_cache.sh
  • .azure-pipelines/env.yml
  • .azure-pipelines/pipelines.yml
  • .azure-pipelines/stage/checks.yml
  • .azure-pipelines/stage/linux.yml
  • .azure-pipelines/stage/prechecks.yml
  • .azure-pipelines/stage/publish.yml
  • .azure-pipelines/stage/verify.yml
  • .azure-pipelines/stages.yml
  • .bazelrc
  • .bazelversion
  • .devcontainer/Dockerfile
  • .devcontainer/setup.sh
  • .github/dependabot.yml
  • .github/workflows/POLICY.md
  • .github/workflows/check-deps.yml
  • .github/workflows/pr_notifier.yml
  • .github/workflows/stale.yml
  • .gitignore
  • BUILD
  • CODEOWNERS
  • VERSION.txt
  • api/BUILD
  • api/CONTRIBUTING.md
  • api/bazel/BUILD
  • api/bazel/repositories.bzl
  • api/bazel/repository_locations.bzl
  • api/envoy/api/v2/core/health_check.proto
  • api/envoy/config/core/v3/health_check.proto
  • api/envoy/config/filter/http/jwt_authn/v2alpha/config.proto
  • api/envoy/config/listener/v3/listener_components.proto
  • api/envoy/config/route/v3/route_components.proto
  • api/envoy/extensions/filters/http/composite/v3/composite.proto
  • api/envoy/extensions/filters/http/custom_response/v3/custom_response.proto
  • api/envoy/extensions/filters/http/jwt_authn/v3/config.proto
  • api/envoy/extensions/filters/network/http_connection_manager/v3/http_connection_manager.proto
  • api/envoy/extensions/http/custom_response/redirect_policy/v3/redirect_policy.proto

@johnlanni
Copy link
Copy Markdown
Author

Closing - wrong base branch. Will reopen with correct base.

@johnlanni johnlanni closed this Jan 31, 2026
@lingma-agents
Copy link
Copy Markdown

lingma-agents bot commented Jan 31, 2026

CodeReview流程已终止

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.