Skip to content

Assert failure when accessing config_dump from admin interface #15017

Open

Description

@NomadXD

Title: Assert failure when accessing config_dump from admin interface

Description:
I have a binary of envoy built with a custom http filter. The custom filter works without any issue. However when I access admin interface on localhost:9000 after deploying an API, I get the following assert failure.

[2021-02-10 14:13:12.485][7][critical][assert] [external/envoy/source/common/protobuf/utility.cc:730] assert failure: type_url_field_descriptor != nullptr && value_field_descriptor != nullptr && reflection->HasField(*message, type_url_field_descriptor).

It happens only when I use the ADS to config envoy. When I statically configure envoy there's no assert failure. The config of the custom http filter is defined from the following proto.

syntax = "proto3";

package envoy.extensions.filters.http.mgw_websocket.v3;

import "udpa/annotations/status.proto";
import "envoy/config/ratelimit/v3/rls.proto";
import "validate/validate.proto";

import "google/protobuf/duration.proto";

message RateLimit{
    string domain = 1 [(validate.rules).string = {min_len: 1}];

    string ratelimit_type = 2 [(validate.rules).string = {in:["downstream", "upstream", "", "default"]}];

    google.protobuf.Duration timeout = 3;

    bool failure_mode_deny = 4;

    envoy.config.ratelimit.v3.RateLimitServiceConfig rate_limit_service = 5 [(validate.rules).message = {required: true}];
}

envoy.yaml is as follows.

admin:
  access_log_path: /dev/null
  address:
    socket_address:
      address: '${ROUTER_ADMIN_HOST}'
      port_value: '${ROUTER_ADMIN_PORT}'
dynamic_resources:
  ads_config:
    api_type: GRPC
    transport_api_version: V3
    grpc_services:
      - envoy_grpc:
          cluster_name: xds_cluster
  cds_config:
    ads: {}
    resource_api_version: V3
  lds_config:
    ads: {}
    resource_api_version: V3
node:
  cluster: '${ROUTER_CLUSTER}'
  id: '${ROUTER_LABEL}'
static_resources:
  clusters:
    - name: xds_cluster
      type: STRICT_DNS
      connect_timeout: 1s
      hosts:
        - socket_address:
            address: '${ADAPTER_HOST}'
            port_value: '${ADAPTER_PORT}'
      http2_protocol_options: {}
      transport_socket:
        name: envoy.transport_sockets.tls
        typed_config:
          '@type': >-
            type.googleapis.com/envoy.extensions.transport_sockets.tls.v3.UpstreamTlsContext
          common_tls_context:
            tls_params:
              tls_minimum_protocol_version: TLSv1_2
              tls_maximum_protocol_version: TLSv1_2
            tls_certificates:
              private_key:
                filename: '${ROUTER_PRIVATE_KEY_PATH}'
              certificate_chain:
                filename: '${ROUTER_PUBLIC_CERT_PATH}'
            validation_context:
              trusted_ca:
                filename: '${ADAPTER_CA_CERT_PATH}'
    - name: ext-authz
      type: STRICT_DNS
      connect_timeout: 20s
      http2_protocol_options: {}
      transport_socket:
        name: envoy.transport_sockets.tls
        typed_config:
          '@type': >-
            type.googleapis.com/envoy.extensions.transport_sockets.tls.v3.UpstreamTlsContext
          common_tls_context:
            tls_params:
              tls_minimum_protocol_version: TLSv1_2
              tls_maximum_protocol_version: TLSv1_2
            tls_certificates:
              private_key:
                filename: '${ROUTER_PRIVATE_KEY_PATH}'
              certificate_chain:
                filename: '${ROUTER_PUBLIC_CERT_PATH}'
            validation_context:
              trusted_ca:
                filename: '${ENFORCER_CA_CERT_PATH}'
      load_assignment:
        cluster_name: ext-authz
        endpoints:
          - lb_endpoints:
              - endpoint:
                  address:
                    socket_address:
                      address: '${ENFORCER_HOST}'
                      port_value: '${ENFORCER_PORT}'

Note
I have the following observations about the issue.

  1. Assert failure does not happen in static configuration. Only in ADS.
  2. Assert failure occurs only after deploying an API to envoy. Before deploying I can access config_dump without any issue.
  3. Even when I'm not configuring my custom filter from go-control-plane, I'm getting the assert failure. So my guess is the issue got something to do with my filter config. My BUILD file is as follows.
api_proto_package(
    name = "proto_mgw",
    srcs = ["mgw_websocket_rls.proto", "mgw_websocket.proto"],
    deps = [
        "@envoy_api//envoy/config/ratelimit/v3:pkg",
        "@com_github_cncf_udpa//udpa/annotations:pkg",
        "@envoy_api//envoy/config/core/v3:pkg",
    ],
)

Any help or tip to solve the issue is highly appreciated since I'm stucked with this for couple of days. I can provide more info too. Thanks

Activity

  1. added
    triage
    on Feb 10, 2021
  2. NomadXD commented on Feb 11, 2021

    @NomadXD
    ContributorAuthor

    I added some logs to redactOpaque() method in utility.cc. The assert which fails is *reflection->HasField(message, type_url_field_descriptor). Th issue is with this method in utility.cc . It gets an empty protobuf as the parameter. ENVOY_LOG_MISC(trace, "protobuf : {}, {}", message->DebugString(), message->GetTypeName()) returns [external/envoy/source/common/protobuf/utility.cc:748] protobuf : , google.protobuf.Any.

  3. antoniovicente commented on Feb 11, 2021

    @antoniovicente
    Contributor
  4. htuch commented on Feb 12, 2021

    @htuch
    Member

    Can you share your LDS dynamic config dump? I'm a bit perplexed how we reach this code and ASSERT. Are you embedding inside an Any or a TypedStruct?

  5. NomadXD commented on Feb 12, 2021

    @NomadXD
    ContributorAuthor

    @htuch The issue is with an empty typed_config field. But what's so confusing to me is it's not throwing an assert failure in the original envoy v1.16.2 pulled from dockerhub. But for the binary that I built with the custom filter using envoy v1.16.2 source, it sends the assert failure when config_dump is accessed from admin interface. I just added an extra http filter and didn't do any modifications to envoy source. Maybe envoy does something other than bazel build to create their production binaries which removes some of these protobuf related validations ?

     "http_filters": [
               Here the cors filter has empty typed_config
               {
                "name": "envoy.filters.http.cors",
                "typed_config": {}
               },
               {
                "name": "envoy.filters.http.ext_authz",
                "typed_config": {
                 "@type": "type.googleapis.com/envoy.extensions.filters.http.ext_authz.v3.ExtAuthz",
                 "grpc_service": {
                  "envoy_grpc": {
                   "cluster_name": "ext-authz"
                  },
                  "timeout": "20s"
                 },
                 "with_request_body": {
                  "max_request_bytes": 1024
                 },
                 "clear_route_cache": true,
                 "transport_api_version": "V3"
                }
               },
               {
                "name": "envoy.filters.http.router",
                "typed_config": {
                 "@type": "type.googleapis.com/envoy.extensions.filters.http.router.v3.Router"
                }
               }
          ],
  6. NomadXD commented on Feb 12, 2021

    @NomadXD
    ContributorAuthor

    The LDS dynamic config dump

    {
     "configs": [
      {
       "@type": "type.googleapis.com/envoy.admin.v3.ListenersConfigDump.DynamicListener",
       "name": "default",
       "active_state": {
        "version_info": "1",
        "listener": {
         "@type": "type.googleapis.com/envoy.config.listener.v3.Listener",
         "name": "default",
         "address": {
          "socket_address": {
           "address": "0.0.0.0",
           "port_value": 9095
          }
         },
         "filter_chains": [
          {
           "filters": [
            {
             "name": "envoy.filters.network.http_connection_manager",
             "typed_config": {
              "@type": "type.googleapis.com/envoy.extensions.filters.network.http_connection_manager.v3.HttpConnectionManager",
              "stat_prefix": "ingress_http",
              "rds": {
               "config_source": {
                "ads": {},
                "resource_api_version": "V3"
               },
               "route_config_name": "default"
              },
              "http_filters": [
               {
                "name": "envoy.filters.http.cors",
                "typed_config": {}
               },
               {
                "name": "envoy.filters.http.ext_authz",
                "typed_config": {
                 "@type": "type.googleapis.com/envoy.extensions.filters.http.ext_authz.v3.ExtAuthz",
                 "grpc_service": {
                  "envoy_grpc": {
                   "cluster_name": "ext-authz"
                  },
                  "timeout": "20s"
                 },
                 "with_request_body": {
                  "max_request_bytes": 1024
                 },
                 "clear_route_cache": true,
                 "transport_api_version": "V3"
                }
               },
               {
                "name": "envoy.filters.http.router",
                "typed_config": {
                 "@type": "type.googleapis.com/envoy.extensions.filters.http.router.v3.Router"
                }
               }
              ],
              "access_log": [
               {
                "name": "envoy.access_loggers.file",
                "typed_config": {
                 "@type": "type.googleapis.com/envoy.extensions.access_loggers.file.v3.FileAccessLog",
                 "path": "/tmp/envoy.access.log",
                 "format": "[%START_TIME%] '%REQ(:METHOD)% %REQ(X-ENVOY-ORIGINAL-PATH?:PATH)% %PROTOCOL%' %RESPONSE_CODE% %RESPONSE_FLAGS% %BYTES_RECEIVED% %BYTES_SENT% %DURATION% %RESP(X-ENVOY-UPSTREAM-SERVICE-TIME)% '%REQ(X-FORWARDED-FOR)%' '%REQ(USER-AGENT)%' '%REQ(X-REQUEST-ID)%' '%REQ(:AUTHORITY)%' '%UPSTREAM_HOST%'\n"
                }
               }
              ],
              "upgrade_configs": [
               {
                "upgrade_type": "websocket",
                "filters": [
                 {
                  "name": "envoy.filters.http.ext_authz",
                  "typed_config": {
                   "@type": "type.googleapis.com/envoy.extensions.filters.http.ext_authz.v3.ExtAuthz",
                   "grpc_service": {
                    "envoy_grpc": {
                     "cluster_name": "ext-authz"
                    },
                    "timeout": "20s"
                   },
                   "with_request_body": {
                    "max_request_bytes": 1024
                   },
                   "clear_route_cache": true,
                   "transport_api_version": "V3"
                  }
                 },
                 {
                  "name": "envoy.filters.http.router",
                  "typed_config": {
                   "@type": "type.googleapis.com/envoy.extensions.filters.http.router.v3.Router"
                  }
                 }
                ],
                "enabled": true
               }
              ]
             }
            }
           ],
           "transport_socket": {
            "name": "envoy.transport_sockets.tls",
            "typed_config": {
             "@type": "type.googleapis.com/envoy.extensions.transport_sockets.tls.v3.DownstreamTlsContext",
             "common_tls_context": {
              "tls_certificates": [
               {
                "certificate_chain": {
                 "filename": "/home/security/keystore/mg.pem"
                },
                "private_key": {
                 "filename": "[redacted]"
                }
               }
              ]
             }
            }
           }
          }
         ]
        },
        "last_updated": "2021-02-12T08:51:35.605Z"
       }
      }
     ]
    }
  7. htuch commented on Feb 12, 2021

    @htuch
    Member

    @NomadXD behavior difference is probably because Envoy release binaries are built with -c opt which removes ASSERTs.

    I think we should have rejected this config earlier, at LDS ingestion time, since it's not really valid to have a typed_config without a type URL.

  8. NomadXD commented on Feb 12, 2021

    @NomadXD
    ContributorAuthor

    @htuch Yeah, probably since it's an invalid config. Thanks a lot for the help.

  9. added
    help wanted
    and removed
    triage
    on Feb 12, 2021
  10. mattklein123 commented on Feb 12, 2021

    @mattklein123
    Member

    @adisuissa or @dmitri-d can you potentially take a look at this? This seems like a legitimate bug somewhere.

  11. adisuissa commented on Feb 12, 2021

    @adisuissa
    Contributor

    I'll take a look.

  12. justincely commented on Jun 9, 2021

    @justincely
    Contributor

    I just ran into this as well because the examples for the sandbox envs demonstrate the empty typed config for the router. I didn't check them all but I saw it in a few:

    These examples should be updated to give the url if that's supposed to be required.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions