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

Panic: nil pointer at transport.(*Backend).evalTransport #206

Closed
malud opened this issue Apr 13, 2021 · 1 comment · Fixed by #283
Closed

Panic: nil pointer at transport.(*Backend).evalTransport #206

malud opened this issue Apr 13, 2021 · 1 comment · Fixed by #283
Labels
bug Something isn't working

Comments

@malud
Copy link
Collaborator

malud commented Apr 13, 2021

Describe the bug
This client requests triggers a nil pointer panic which gets written to the error template but can not be found in any log fields.

To Reproduce
Steps to reproduce the behavior:

  1. Which Couper version? Run couper version or docker run avenga/couper version
    1.0
  2. Provide your configuration file *.hcl. Remove sensitive data.
server "fuzz" {
  endpoint "/**" {
    add_request_headers = {
      x-fuzz = request.headers.x-data
    }

    add_query_params = {
      x-quzz = request.headers.x-data
    }

    request "sidekick" {
      url = "http://%s/anything/"
      body = request.headers.x-data
    }

    # default
    proxy {
      path = "/anything"
      url = "http://%s"
    }

    add_response_headers = {
      y-fuzz = request.headers.x-data
      x-sidekick = backend_responses.sidekick.json_body
    }
  }
}
  1. Provide a curl call for reproduction
    3.1 You may use your browsers developer console and hit copy as curl.
nc localhost 8080

quoted input: "\n\x00\n\x00"
raw input:

GET / HTTP/1.1
Host: localhost
Connection: close
X-Data:
�
�



  1. See an error response or error log.

logs:

ERRO[0806] parse "http://%s": invalid URL escape "%s"    backend=default build=dev hcl=backend type=couper_daemon version=0
ERRO[0806] parse "http://%s/anything/": invalid URL escape "%s"  backend=default build=dev hcl=backend type=couper_daemon version=0
ERRO[0806] Server error                                  build=dev bytes=59771 client_ip=127.0.0.1 code=1000 endpoint="/**" handler=endpoint method=GET proto=HTTP/1.1 realtime=1.773 request="map[addr:localhost:8080 headers:map[] host:localhost path:/?x-quzz= port:8080 tls:false]" response="map[bytes:59771 headers:map[content-type:text/html]]" scheme=http server=fuzz status=500 type=couper_access uid=c1qrhqgi7qknopja9lsg url="http://localhost:8080/?x-quzz=" version=0

response:

<body>
		<h1>Error -
800
500</h1>
		<section id="ctx">
			<div>
				<strong>Code:</strong> 1000 - "panic: runtime error: invalid memory address or nil pointer dereference
goroutine 28 [running]:
runtime/debug.Stack(0x16dcee4, 0x2, 0xc0001baf00)
	/Users/marcel/homebrew/Cellar/go/1.16/libexec/src/runtime/debug/stack.go:24 +0x9f
github.com/avenga/couper/handler/producer.roundtrip.func1(0xc000276600, 0xc0003d43c0, 0x16deb0e, 0x7)
	/Users/marcel/projects/couper-gateway/handler/producer/result.go:56 +0xf8
panic(0x163f600, 0x1aed260)
	/Users/marcel/homebrew/Cellar/go/1.16/libexec/src/runtime/panic.go:965 +0x1b9
github.com/avenga/couper/handler/transport.(*Backend).evalTransport(0xc0000a4d80, 0xc000276700, 0x17b4658, 0xc0000100b0, 0xc000276700)
	/Users/marcel/projects/couper-gateway/handler/transport/backend.go:271 +0x8af
github.com/avenga/couper/handler/transport.(*Backend).RoundTrip(0xc0000a4d80, 0xc000276700, 0x1b007a0, 0x1a9d518, 0x1630a20)
	/Users/marcel/projects/couper-gateway/handler/transport/backend.go:84 +0xbc
github.com/avenga/couper/logging.(*UpstreamLog).RoundTrip(0xc000305040, 0xc000276700, 0x16e1f12, 0xf, 0xc0001bfc20)
	/Users/marcel/projects/couper-gateway/logging/upstream_log.go:87 +0x6e7
net/http/httputil.(*ReverseProxy).ServeHTTP(0xc000096730, 0x17b2260, 0xc000275d70, 0xc000276600)
	/Users/marcel/homebrew/Cellar/go/1.16/libexec/src/net/http/httputil/reverseproxy.go:288 +0x2d8
github.com/avenga/couper/handler.(*Proxy).RoundTrip(0xc000306d80, 0xc000276600, 0x1a9d528, 0x1613bc0, 0xc00024f000)
	/Users/marcel/projects/couper-gateway/handler/proxy.go:64 +0x2f2
github.com/avenga/couper/handler/producer.roundtrip(0x17a8340, 0xc000306d80, 0xc000276600, 0xc0003d43c0, 0xc000434bd0)
	/Users/marcel/projects/couper-gateway/handler/producer/result.go:66 +0x142
created by github.com/avenga/couper/handler/producer.Proxies.Produce
	/Users/marcel/projects/couper-gateway/handler/producer/proxy.go:44 +0x245
"
			</div>
			<div>
				<strong>Path:</strong> /
			</div>
			<div>
				<strong>Request-ID:</strong> c1qrhqgi7qknopja9lsg
			</div>
		</secti
15
on>
	</body>

Expected behavior

  1. panic stack within log and not as response error message
  2. no panic / nil ref
@malud malud added bug Something isn't working fuzz Related to random input values labels Apr 13, 2021
@malud
Copy link
Collaborator Author

malud commented Apr 13, 2021

The nc raw data thing may hide the real issue here, it's just the %s url parse error.

Found another one related to those bytes, I will open another issue if its reproducible.

@malud malud removed the fuzz Related to random input values label Apr 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant