mbrubeck / agate

Very simple server for the Gemini hypertext protocol
Apache License 2.0
605 stars 37 forks source link

Crash when fetching remote IP address #59

Closed lifelike closed 3 years ago

lifelike commented 3 years ago

Agate died suddenly with this message:

thread 'tokio-runtime-worker' panicked at 'could not get peer address: Os { code: 107, kind: NotConnected, message: "Transport endpoint is not connected" }', src/main.rs:302:22
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

It was a process that had been running for a while, built from git version ac5b030ec2ed7b5029476b3b727563dc44fe2aee, so it might have all sorts of now fixed issues.

The server is on a public IP, but only used by me for testing, never announced anywhere. There are a few broken TLS requests per day from unknown sources that are presumably bots looking for HTTPS servers on random ports. It crashed when I was not using it, so likely it was some kind of malicious request not a proper gemini request.

Johann150 commented 3 years ago

This has not been fixed yet, the panic message comes from this line: https://github.com/mbrubeck/agate/blob/92673c54fb9a77736975900b798b52554628149b/src/main.rs#L305

I am a bit puzzled how this could happen in the first place, but seeing that it can happen means that this should probably be handled differently. Otherwise this is a DoS attack vector.

Dropping the connection seems like a better idea than panicking and bringing down the whole server.