cinny icon indicating copy to clipboard operation
cinny copied to clipboard

Crash when `/_matrix/client/v3/login` does not have `flows` key

Open MisguidedEmails opened this issue 2 months ago • 0 comments

Describe the bug

If the response from /_matrix/client/v3/login is valid JSON and doesn't contain the flows key, the application crashes.

Reproduction

  1. Open app, it asks for server to login
  2. Type Bad Server - In this example localhost:8089
  3. As soon as final character is entered, crashes.
Go code that will trigger this
package main

import (
	"fmt"
	"net/http"
)

func main() {
	mux := http.NewServeMux()
	srv := &http.Server{
		Addr: ":8089",
		Handler: mux,
	}

	mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {

		fmt.Println(r.URL.Path)

		w.Header().Set("Access-Control-Allow-Origin", "*")
		w.Header().Set("Access-Control-Allow-Methods", "GET, POST, PUT, DELETE, OPTIONS")
		w.Header().Set("Access-Control-Allow-Headers", "X-Requested-With, Content-Type, Authorization")
	
		switch r.URL.Path {
		case "/_matrix/client/versions":
			w.Header().Set("Content-Type", "application/json")
			w.Write([]byte(`{"versions":["v1.16"]}`))
		case "/_matrix/client/v3/login":
			w.Header().Set("Content-Type", "application/json")
			w.Write([]byte(`{}`))
		default:
			w.WriteHeader(http.StatusNotFound)
		}
	})

	srv.ListenAndServeTLS("cert.pem", "key.pem")
}

Any self signed cert should do, but if it helps:

#!/usr/bin/env bash

openssl req -x509 -newkey rsa:4096 -keyout key.pem -nodes -out cert.pem -sha256 -days 365 -subj "/CN=localhost"

Expected behavior

Return an error. Not crash the application.

Platform and versions

1. OS: Linux
2. Broswer: Firefox 142.0.1
3. Cinny version: 4.10.1 [via app.cinny.in]
4. Matrix homeserver: :)

Additional context

Not really a big issue, or one that almost anyone will run into. But I'm reporting it in the interest of robustness.

MisguidedEmails avatar Oct 01 '25 21:10 MisguidedEmails