Skip to content

Logging of Tarpit requests cause a stack dump #84

@alexeiser

Description

@alexeiser

Example caddy file

{
    auto_https off
	admin off
	skip_install_trust
    log {
        level DEBUG
    }

}

:8080 {
    log
	route {
		defender tarpit {
			ranges 0.0.0.0/0
			tarpit_config {
				content http://example.com
				# Optional. Complete request at this duration if content EOF is not reached. Default 30s
				#headers {
				#	content-length "0"
				#}

				timeout 60s
				# Optional. Rate of data stream. Default 24
				bytes_per_second 2000
			}
		}
	}
}

Run docker container:

docker run -it --rm -p 8080:8080 -v $(pwd)/Caddyfile:/etc/caddy/Caddyfile  ghcr.io/jasonlovesdoggo/caddy-defender:latest   caddy run --config /etc/caddy/Caddyfile --adapter caddyfile

Causes stack dump:

2025/05/22 17:04:48.748	DEBUG	http.stdlib	http: panic serving 192.168.65.1:62029: interface conversion: *caddyhttp.responseRecorder is not http.Flusher: missing method Flush
goroutine 70 [running]:
net/http.(*conn).serve.func1()
	net/http/server.go:1947 +0xbe
panic({0x1888440?, 0xc0004ad8c0?})
	runtime/panic.go:792 +0x132
pkg.jsn.cam/caddy-defender/responders/tarpit.(*Responder).ServeHTTP(0xc000a23d28, {0x7fffb8897548, 0xc0007c7900}, 0xc000c272c0, {0x1?, 0x1?})
	pkg.jsn.cam/[email protected]/responders/tarpit/tarpit.go:113 +0x546
pkg.jsn.cam/caddy-defender.Defender.ServeHTTP({{0x2036c60, 0xc000a23d28}, 0xc0007905e0, 0xc0006d6700, {0x0, 0x0}, {0x0, 0x0}, {0xc0004b480a, 0x6}, ...}, ...)
	pkg.jsn.cam/[email protected]/middleware.go:69 +0x709
github.com/caddyserver/caddy/v2/modules/caddyhttp.wrapMiddleware.func1.1({0x7fffb8897548, 0xc0007c7900}, 0xc000c272c0)
	github.com/caddyserver/caddy/[email protected]/modules/caddyhttp/routes.go:331 +0xd2
github.com/caddyserver/caddy/v2/modules/caddyhttp.HandlerFunc.ServeHTTP(0x203a200?, {0x7fffb8897548?, 0xc0007c7900?}, 0xc000c272c0?)
	github.com/caddyserver/caddy/[email protected]/modules/caddyhttp/caddyhttp.go:74 +0x29
github.com/caddyserver/caddy/v2/modules/caddyhttp.RouteList.Compile.wrapRoute.func1.1({0x7fffb8897548, 0xc0007c7900}, 0xc000c272c0)
	github.com/caddyserver/caddy/[email protected]/modules/caddyhttp/routes.go:298 +0x24e
github.com/caddyserver/caddy/v2/modules/caddyhttp.HandlerFunc.ServeHTTP(0xc0006cc360?, {0x7fffb8897548?, 0xc0007c7900?}, 0x203a200?)
	github.com/caddyserver/caddy/[email protected]/modules/caddyhttp/caddyhttp.go:74 +0x29
github.com/caddyserver/caddy/v2/modules/caddyhttp.(*Subroute).ServeHTTP(0xc000790540, {0x7fffb8897548, 0xc0007c7900}, 0xc000c272c0, {0x203a200, 0x1e2c288})
	github.com/caddyserver/caddy/[email protected]/modules/caddyhttp/subroute.go:74 +0x62
github.com/caddyserver/caddy/v2/modules/caddyhttp.wrapMiddleware.func1.1({0x7fffb8897548, 0xc0007c7900}, 0xc000c272c0)
	github.com/caddyserver/caddy/[email protected]/modules/caddyhttp/routes.go:331 +0xd2
github.com/caddyserver/caddy/v2/modules/caddyhttp.HandlerFunc.ServeHTTP(0x203a200?, {0x7fffb8897548?, 0xc0007c7900?}, 0xc000c272c0?)
	github.com/caddyserver/caddy/[email protected]/modules/caddyhttp/caddyhttp.go:74 +0x29
github.com/caddyserver/caddy/v2/modules/caddyhttp.RouteList.Compile.wrapRoute.func1.1({0x7fffb8897548, 0xc0007c7900}, 0xc000c272c0)
	github.com/caddyserver/caddy/[email protected]/modules/caddyhttp/routes.go:298 +0x24e
github.com/caddyserver/caddy/v2/modules/caddyhttp.HandlerFunc.ServeHTTP(0x1a4d940?, {0x7fffb8897548?, 0xc0007c7900?}, 0xc0003810e0?)
	github.com/caddyserver/caddy/[email protected]/modules/caddyhttp/caddyhttp.go:74 +0x29
github.com/caddyserver/caddy/v2/modules/caddyhttp.(*Server).enforcementHandler(0x0?, {0x7fffb8897548?, 0xc0007c7900?}, 0xc0003810e0?, {0x203a200?, 0xc0005929c0?})
	github.com/caddyserver/caddy/[email protected]/modules/caddyhttp/server.go:481 +0x24b
github.com/caddyserver/caddy/v2/modules/caddyhttp.(*App).Provision.(*Server).wrapPrimaryRoute.func2({0x7fffb8897548?, 0xc0007c7900?}, 0x4eee73?)
	github.com/caddyserver/caddy/[email protected]/modules/caddyhttp/server.go:457 +0x35
github.com/caddyserver/caddy/v2/modules/caddyhttp.HandlerFunc.ServeHTTP(0xc0006c4500?, {0x7fffb8897548?, 0xc0007c7900?}, 0xc000c272c0?)
	github.com/caddyserver/caddy/[email protected]/modules/caddyhttp/caddyhttp.go:74 +0x29
github.com/caddyserver/caddy/v2/modules/caddyhttp.(*Server).ServeHTTP(0xc0006d4008, {0x2049880, 0xc0005f89a0}, 0xc000c27040)
	github.com/caddyserver/caddy/[email protected]/modules/caddyhttp/server.go:370 +0xc85
net/http.serverHandler.ServeHTTP({0xc0002a99e0?}, {0x2049880?, 0xc0005f89a0?}, 0x1?)
	net/http/server.go:3301 +0x8e
net/http.(*conn).serve(0xc00038d320, {0x204cd40, 0xc0000b4660})
	net/http/server.go:2102 +0x625
created by net/http.(*Server).Serve in goroutine 50
	net/http/server.go:3454 +0x485

ghcr.io/jasonlovesdoggo/caddy-defender:latest sha:454d3d479c88

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinggoPull requests that update go code

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions