Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2.6.4 issues with proxying paths w/ %2F for literal forward slashes #2112

Closed
bitsofinfo opened this issue Feb 12, 2019 · 0 comments · Fixed by #2138
Closed

2.6.4 issues with proxying paths w/ %2F for literal forward slashes #2112

bitsofinfo opened this issue Feb 12, 2019 · 0 comments · Fixed by #2138

Comments

@bitsofinfo
Copy link

bitsofinfo commented Feb 12, 2019

v2.6.4

Do you want to request a feature or report a bug?

bug

What is the current behavior?

I need get use my beercan api to request beer can by "name" which is literally this string:

99999-XXXX // dog 9 ffféo party

I make a GET request that is url encoded to my API:

https://mygateway/my/api/1.0/beercans/99999-XXXX+%2F%2F+dog+9+fff%C3%A9o+party

Tyk gets the request, and executes my plugin. Note the value of request.RequestURI at this point (from inside the JSVM plugin) is 99999-XXXX+/+dog+9+fff%C3%A9o+party. My plugin does nothing with this value other than log it btw.

The JSVM plugin sets the following request header: X-My-Proxytourl: https://mybackend/bcans

Next Tyks URL rewriter runs w/ this config:=

"url_rewrites": [
    {
        "path": "my/api/\\d.\\d/beercans/(.*)",
        "method": "GET",
        "match_pattern": "my/api/\\d.\\d/beercans/(.*)",
        "rewrite_to": "$tyk_context.headers_X_My_Proxytourl/$1",
        "triggers": [],
        "MatchRegexp": null
    }
]

This rewrites the url but the the target backend receives the following instead which fails as the "name" is messed up. Its like the something inside Tyk drops the %2F%2F encoding and replaces it w/ just a single / literally in the url, and mybackend server then improperly parses this path.

https://mybackend/bcans/99999-XXXX+/+dog+9+fff%C3%A9o+party

What is the expected behavior?

mybackend should be proxied to with the below:

https://mybackend/bcans/99999-XXXX+%2F%2F+dog+9+fff%C3%A9o+party

Minimized config

  {
    "id": "xxxxx",
    "name": "/my/api/1.0/beercans",
    "slug": "my/api/1.0/beercans",
    "api_id": "xxxxx",
    "org_id": "xxxxx",
    "use_keyless": true,
    "use_oauth2": false,
    "use_openid": false,
    "openid_options": {
        "providers": [],
        "segregate_by_client": false
    },
    "oauth_meta": {
        "allowed_access_types": [],
        "allowed_authorize_types": [],
        "auth_login_redirect": ""
    },
    "auth": {
        "use_param": false,
        "param_name": "",
        "use_cookie": false,
        "cookie_name": "",
        "auth_header_name": "",
        "use_certificate": false
    },
    "use_basic_auth": false,
    "basic_auth": {
        "disable_caching": false,
        "cache_ttl": 0
    },
    "use_mutual_tls_auth": false,
    "client_certificates": [],
    "upstream_certificates": {},
    "pinned_public_keys": {},
    "enable_jwt": false,
    "use_standard_auth": false,
    "enable_coprocess_auth": false,
    "jwt_signing_method": "",
    "jwt_source": "",
    "jwt_identity_base_field": "",
    "jwt_client_base_field": "",
    "jwt_policy_field_name": "",
    "jwt_issued_at_validation_skew": 0,
    "jwt_expires_at_validation_skew": 0,
    "jwt_not_before_validation_skew": 0,
    "jwt_skip_kid": false,
    "notifications": {
        "shared_secret": "",
        "oauth_on_keychange_url": ""
    },
    "enable_signature_checking": false,
    "hmac_allowed_clock_skew": -1,
    "hmac_allowed_algorithms": [],
    "base_identity_provided_by": "",
    "definition": {
        "location": "header",
        "key": "x-api-version",
        "strip_path": false
    },
    "version_data": {
        "not_versioned": true,
        "default_version": "",
        "versions": {
            "Default": {
                "name": "Default",
                "expires": "",
                "paths": {
                    "ignored": [],
                    "white_list": [],
                    "black_list": []
                },
                "use_extended_paths": true,
                "extended_paths": {
                    "white_list": [
                        {
                            "path": "my/api/\\d.\\d/beercans/(.*)",
                            "method_actions": {
                                "GET": {
                                    "action": "no_action",
                                    "code": 200,
                                    "data": "",
                                    "headers": {}
                                }
                            }
                        }
                    ],
                    "url_rewrites": [
                        {
                            "path": "my/api/\\d.\\d/beercans/(.*)",
                            "method": "GET",
                            "match_pattern": "my/api/\\d.\\d/beercans/(.*)",
                            "rewrite_to": "$tyk_context.headers_X_My_Proxytourl/$1",
                            "triggers": [],
                            "MatchRegexp": null
                        }
                    ]
                },
                "global_headers": {},
                "global_headers_remove": [],
                "global_size_limit": 0,
                "override_target": ""
            }
        }
    },
    "uptime_tests": {
        "check_list": [],
        "config": {
            "expire_utime_after": 0,
            "service_discovery": {
                "use_discovery_service": false,
                "query_endpoint": "",
                "use_nested_query": false,
                "parent_data_path": "",
                "data_path": "",
                "port_data_path": "",
                "target_path": "",
                "use_target_list": false,
                "cache_timeout": 60,
                "endpoint_returns_list": false
            },
            "recheck_wait": 0
        }
    },
    "proxy": {
        "preserve_host_header": false,
        "listen_path": "/xxxx/",
        "target_url": "https://not-relevant-set.via.plugin.header.X_My_Proxytourl",
        "disable_strip_slash": false,
        "strip_listen_path": true,
        "enable_load_balancing": false,
        "target_list": [],
        "check_host_against_uptime_tests": false,
        "service_discovery": {
            "use_discovery_service": false,
            "query_endpoint": "",
            "use_nested_query": false,
            "parent_data_path": "",
            "data_path": "",
            "port_data_path": "",
            "target_path": "",
            "use_target_list": false,
            "cache_timeout": 0,
            "endpoint_returns_list": false
        },
        "transport": {
            "ssl_ciphers": [],
            "ssl_min_version": 0,
            "proxy_url": ""
        }
    },
    "disable_rate_limit": false,
    "disable_quota": false,
    "custom_middleware": {
        "pre": [],
        "post": [],
        "post_key_auth": [],
        "auth_check": {
            "name": "",
            "path": "",
            "require_session": false
        },
        "response": [],
        "driver": "",
        "id_extractor": {
            "extract_from": "",
            "extract_with": "",
            "extractor_config": {}
        }
    },
    "custom_middleware_bundle": "my-jsvm-plugin.zip",
    "cache_options": {
        "cache_timeout": 60,
        "enable_cache": false,
        "cache_all_safe_requests": false,
        "cache_response_codes": [],
        "enable_upstream_cache_control": false,
        "cache_control_ttl_header": ""
    },
    "session_lifetime": 0,
    "active": true,
    "auth_provider": {
        "name": "",
        "storage_engine": "",
        "meta": {}
    },
    "session_provider": {
        "name": "",
        "storage_engine": "",
        "meta": {}
    },
    "event_handlers": {
        "events": {}
    },
    "enable_batch_request_support": false,
    "enable_ip_whitelisting": false,
    "allowed_ips": [],
    "enable_ip_blacklisting": false,
    "blacklisted_ips": [],
    "dont_set_quota_on_create": false,
    "expire_analytics_after": 0,
    "response_processors": [],
    "CORS": {
        "enable": false,
        "allowed_origins": [],
        "allowed_methods": [],
        "allowed_headers": [],
        "exposed_headers": [],
        "allow_credentials": false,
        "max_age": 24,
        "options_passthrough": false,
        "debug": false
    },
    "domain": "",
    "certificates": [],
    "do_not_track": false,
    "tags": [],
    "enable_context_vars": true,
    "config_data": { },
    "tag_headers": [],
    "global_rate_limit": {
        "rate": 0,
        "per": 0
    },
    "strip_auth_data": false
}
@bitsofinfo bitsofinfo changed the title 2.6.4 url rewriter %2F and forward slashes 2.6.4 issues with proxying paths w/ %2F for literal forward slashes Feb 12, 2019
@furkansenharputlu furkansenharputlu self-assigned this Feb 22, 2019
buger pushed a commit that referenced this issue Mar 9, 2019
buger pushed a commit that referenced this issue May 4, 2019
buger pushed a commit that referenced this issue Aug 6, 2019
@ilijabojanovic ilijabojanovic added this to the Release 2.8.4 milestone Aug 14, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants