Skip to content

prefix_rewrite not being respected with caching enabled in Envoy 1.33 #39135

Closed as not planned
@ashishb-solo

Description

@ashishb-solo

If you are reporting any crash or any potential security issue, do not
open an issue in this repo. Please report the issue via emailing
envoy-security@googlegroups.com where the issue will be triaged appropriately.

Title: prefix_rewrite not being respected with caching enabled in Envoy 1.33

Description:

As of Envoy 1.33 and above, when caching is enabled on a filter chain, the prefix_rewrite configuration on the route is not being respected. Requests to the upstream are coming in with the original path provided by the downstream client instead.

I'm fairly certain this behaviour was introduced in this commit.

Repro steps:

Run an echo server on port 8090 (docker run -p 8090:8080 -e LOG_HTTP_HEADERS=true -e LOG_HTTP_BODY=true jmalloc/echo-server) and run Envoy with the below configuration.

  • With Envoy 1.32.5, the response is GET / HTTP/1.1 (which is correct).
  • In Envoy 1.33.2, the response is GET /test HTTP/1.1 which is incorrect (/test should be removed in accordance with the prefix_rewrite configuration on the route).
  • If the envoy.filters.http.cache filter is removed from the configuration, then Envoy 1.33 behaves the same as 1.32 (the upstream correctly sees / and not /test).
# required for toggling runtime reloadable features
layered_runtime:
  layers:
  - name: admin
    admin_layer: {}

# taken from https://www.envoyproxy.io/docs/envoy/latest/start/quick-start/configuration-static
# or view-source:https://www.envoyproxy.io/docs/envoy/latest/_downloads/92dcb9714fb6bc288d042029b34c0de4/envoy-demo.yaml
admin:
  address:
    socket_address: { address: 127.0.0.1, port_value: 9901 }

static_resources:

  listeners:
  - name: listener_0
    address:
      socket_address:
        address: 0.0.0.0
        port_value: 10000
    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
          access_log:
          - name: envoy.access_loggers.stdout
            typed_config:
              "@type": type.googleapis.com/envoy.extensions.access_loggers.stream.v3.StdoutAccessLog
              # log_format:
              #   text_format_source:
              #     inline_string: "test\n"
          http_filters:
          - name: envoy.filters.http.cache
            typed_config:
              "@type": type.googleapis.com/envoy.extensions.filters.http.cache.v3.CacheConfig
              typed_config:
                "@type": type.googleapis.com/envoy.extensions.http.cache.simple_http_cache.v3.SimpleHttpCacheConfig
          - name: envoy.filters.http.router
            typed_config:
              "@type": type.googleapis.com/envoy.extensions.filters.http.router.v3.Router
          route_config:
            name: listener-::-8080-routes
            virtual_hosts:
              - name: my-virtual-host
                domains:
                  - test-domain
                  - cache-hit.example.com
                routes:
                  - match:
                      prefix: /test
                    route:
                      cluster: my-cluster
                      prefix_rewrite: /
                    name: my-virtual-host
                typed_per_filter_config:
                  envoy.filters.http.ext_authz:
                    '@type': type.googleapis.com/envoy.extensions.filters.http.ext_authz.v3.ExtAuthzPerRoute
                    disabled: true

  clusters:
  - name: my-cluster
    type: LOGICAL_DNS
    # Comment out the following line to test on v6 networks
    dns_lookup_family: V4_ONLY
    load_assignment:
      cluster_name: my-cluster
      endpoints:
      - lb_endpoints:
        - endpoint:
            address:
              socket_address:
                address: 127.0.0.1
                port_value: 8090

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