Uploaded image for project: 'Red Hat 3scale API Management'
  1. Red Hat 3scale API Management
  2. THREESCALE-6834

Routing policy is changing the encoding of some characters in the upstream path

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Major Major
    • None
    • 2.9.1 GA, 2.14.0 GA, 2.13.2 GA
    • Gateway
    • False
    • False
    • Not Started
    • Not Started
    • Not Started
    • Not Started
    • Not Started
    • Not Started
    • +
    • Undefined
    • Hide

      Routing Policy configured as follows (APIaaP with backend at /foo)

      {
          "name": "routing",
          "version": "builtin",
          "configuration": {
              "rules": [
                  {
                      "url": "https://echo-api.3scale.net:443",
                      "condition": {
                          "combine_op": "and",
                          "operations": [
                              {
                                  "op": "matches",
                                  "value": "^(/foo/.*|/foo/?)",
                                  "match": "path"
                              }
                          ]
                      },
                      "replace_path": "{{uri | remove_first: '/foo'}}"
                  }
              ]
          }
      }
      

      Example requests and responses:

      example 1

      $ curl -k  "https://api-3scale-apicast.apps-crc.testing:443/foo/+" -H'user_key:abc'
      {
        "method": "GET",
        "path": "/%20",
       [output truncated]
      

      example 2

      $ curl -k  "https://api-3scale-apicast-staging.apps-crc.testing:443/foo/%2B" -H'user_key:abc'
      {
        "method": "GET",
        "path": "/%20",
       [output truncated]
      

      example 3

      $ curl -k  "https://api-3scale-apicast-staging.apps-crc.testing:443/foo/%26%24%23" -H'user_key:abc'
      {
        "method": "GET",
        "path": "/&$%23",
       [output truncated]
      

      example 4

      $ curl -k  "https://api-3scale-apicast-staging.apps-crc.testing:443/foo/#####" -H'user_key:abc'
      {
        "method": "GET",
        "path": "/",
      [output truncated]
      
      Show
      Routing Policy configured as follows (APIaaP with backend at /foo) { "name" : "routing" , "version" : "builtin" , "configuration" : { "rules" : [ { "url" : "https: //echo-api.3scale.net:443" , "condition" : { "combine_op" : "and" , "operations" : [ { "op" : "matches" , "value" : "^(/foo/.*|/foo/?)" , "match" : "path" } ] }, "replace_path" : "{{uri | remove_first: '/foo' }}" } ] } } Example requests and responses: example 1 $ curl -k "https: //api-3scale-apicast.apps-crc.testing:443/foo/+" -H 'user_key:abc' { "method" : "GET" , "path" : "/%20" , [output truncated] example 2 $ curl -k "https: //api-3scale-apicast-staging.apps-crc.testing:443/foo/%2B" -H 'user_key:abc' { "method" : "GET" , "path" : "/%20" , [output truncated] example 3 $ curl -k "https: //api-3scale-apicast-staging.apps-crc.testing:443/foo/%26%24%23" -H 'user_key:abc' { "method" : "GET" , "path" : "/&$%23" , [output truncated] example 4 $ curl -k "https: //api-3scale-apicast-staging.apps-crc.testing:443/foo/#####" -H 'user_key:abc' { "method" : "GET" , "path" : "/" , [output truncated]

      As visible in the steps to reproduce, it seems that the routing policy is introducing an unpredictable behaviour on certain characters, when routing the request to upstream:

      +   --> encoded to %20 (wrong encoding)
      %2B --> changed to %20 
      %26 --> decoded to &
      %24 --> decoded to $
      %23 --> left unchanged
      

      The expected behaviour is that all the characters should be left unchanged
      The issue happens here, called from here e.g. whenever the routing rule specifies a replace_path

      Please read all comments.

              Unassigned Unassigned
              rhn-support-sillumin Samuele Illuminati (Inactive)
              Martin Kudlej Martin Kudlej
              Votes:
              0 Vote for this issue
              Watchers:
              15 Start watching this issue

                Created:
                Updated: