Description
The opentelemetry_cowboy telemetry handler crashes when processing an HTTP/2 request with a malformed :scheme pseudo-header. Once the handler crashes, the Erlang telemetry library permanently detaches it, causing all subsequent requests on that node to lose OpenTelemetry tracing.
Root Cause
In opentelemetry_cowboy.erl:239, the extract_scheme/2 function only handles <<"http">> and <<"https">>:
case ReqScheme of
<<"http">> ->
http;
<<"https">> ->
https
end;
Any other value causes a case_clause crash. Cowboy does not validate the :scheme pseudo-header and passes through arbitrary values, so malformed requests (from scanners, bots, or misconfigured proxies) can trigger this crash.
Reproduction
Minimal reproduction repository: https://github.com/velimir/scheme_crash
git clone https://github.com/velimir/scheme_crash
cd scheme_crash
mix deps.get
iex -S mix
In another terminal:
nghttp -v -n -H':scheme: http://example.com/?' http://localhost:8080/
Error Output
[error] Handler {:opentelemetry_cowboy, :otel_cowboy} has failed and has been detached. Class=:error
Reason={:case_clause, "http://example.com/?"}
Stacktrace=[
{:opentelemetry_cowboy, :extract_scheme, 2,
[file: '.../opentelemetry_cowboy.erl', line: 239]},
{:opentelemetry_cowboy, :handle_event, 4,
[file: '.../opentelemetry_cowboy.erl', line: 295]},
...
]
Versions
opentelemetry_cowboy: 1.0.0
cowboy: 2.14.2
opentelemetry: 1.7.0
- Erlang/OTP: 27.x
Description
The
opentelemetry_cowboytelemetry handler crashes when processing an HTTP/2 request with a malformed:schemepseudo-header. Once the handler crashes, the Erlangtelemetrylibrary permanently detaches it, causing all subsequent requests on that node to lose OpenTelemetry tracing.Root Cause
In
opentelemetry_cowboy.erl:239, theextract_scheme/2function only handles<<"http">>and<<"https">>:Any other value causes a
case_clausecrash. Cowboy does not validate the:schemepseudo-header and passes through arbitrary values, so malformed requests (from scanners, bots, or misconfigured proxies) can trigger this crash.Reproduction
Minimal reproduction repository: https://github.com/velimir/scheme_crash
git clone https://github.com/velimir/scheme_crash cd scheme_crash mix deps.get iex -S mixIn another terminal:
nghttp -v -n -H':scheme: http://example.com/?' http://localhost:8080/Error Output
Versions
opentelemetry_cowboy: 1.0.0cowboy: 2.14.2opentelemetry: 1.7.0