{"record":{"id":"c9cddfc6d4776598","repo":"shadow1ng/fscan","slug":"activemq-stomp-read-failed-w","errorCode":null,"errorMessage":"activemq_stomp_read_failed: %w","messagePattern":"activemq_stomp_read_failed: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"plugins/services/activemq.go","lineNumber":177,"sourceCode":"func (p *ActiveMQPlugin) authenticateSTOMP(conn net.Conn, username, password string, config *common.Config) (bool, error) {\n\ttimeout := config.ModuleTimeout()\n\tif err := rejectLineBreaks(username, password); err != nil {\n\t\treturn false, err\n\t}\n\n\tstompConnect := fmt.Sprintf(\"CONNECT\\naccept-version:1.0,1.1,1.2\\nhost:/\\nlogin:%s\\npasscode:%s\\n\\n\\x00\",\n\t\tusername, password)\n\n\t_ = conn.SetWriteDeadline(time.Now().Add(timeout))\n\tif _, err := conn.Write([]byte(stompConnect)); err != nil {\n\t\treturn false, fmt.Errorf(\"%s: %w\", i18n.GetText(\"activemq_stomp_send_failed\"), err)\n\t}\n\n\t_ = conn.SetReadDeadline(time.Now().Add(timeout))\n\tresponse := make([]byte, 1024)\n\tn, err := conn.Read(response)\n\tif err != nil {\n\t\treturn false, fmt.Errorf(\"%s: %w\", i18n.GetText(\"activemq_stomp_read_failed\"), err)\n\t}\n\tif n == 0 {\n\t\treturn false, fmt.Errorf(\"%s\", i18n.GetText(\"activemq_stomp_empty_response\"))\n\t}\n\n\tresponseStr := string(response[:n])\n\n\tif strings.Contains(responseStr, \"CONNECTED\") {\n\t\treturn true, nil\n\t} else if strings.Contains(responseStr, \"ERROR\") {\n\t\terrorMsg := i18n.GetText(\"activemq_stomp_auth_error\")\n\t\tif strings.Contains(responseStr, \"Authentication failed\") {\n\t\t\terrorMsg = \"Authentication failed\"\n\t\t} else if strings.Contains(responseStr, \"Access denied\") {\n\t\t\terrorMsg = \"Access denied\"\n\t\t} else if strings.Contains(responseStr, \"Invalid credentials\") {\n\t\t\terrorMsg = \"Invalid credentials\"\n\t\t}","sourceCodeStart":159,"sourceCodeEnd":195,"githubUrl":"https://github.com/shadow1ng/fscan/blob/95cc12e753bf43de7004e5aef42a9ffba3934303/plugins/services/activemq.go#L159-L195","documentation":"Guard in ActiveMQ authenticateSTOMP: reading the STOMP CONNECT response from the broker failed (I/O error or timeout after SetReadDeadline). The broker accepted the connection but never returned a readable frame, so credentials could not be verified.","triggerScenarios":"The read deadline (timeout) expires before the broker answers, the connection is reset, or the socket is closed while awaiting the CONNECTED/ERROR frame.","commonSituations":"Broker slow to respond beyond the configured timeout, TLS/plain mismatch (speaking STOMP to a TLS-only port), broker crash or restart mid-handshake, network device dropping the flow.","solutions":["Increase the read timeout so slow brokers can answer","Confirm the port actually serves STOMP (61613) and matches TLS settings","Check broker logs for connection resets or authentication-plugin hangs","Retry; transient network errors often clear on reconnect"],"exampleFix":"// before\nn, err := conn.Read(response)\nif err != nil {\n    return false, fmt.Errorf(\"%s: %w\", i18n.GetText(\"activemq_stomp_read_failed\"), err)\n}\n// after (distinguish timeout from reset)\nn, err := conn.Read(response)\nif err != nil {\n    if ne, ok := err.(net.Error); ok && ne.Timeout() {\n        return false, fmt.Errorf(\"broker did not answer within %v\", timeout)\n    }\n    return false, fmt.Errorf(\"%s: %w\", i18n.GetText(\"activemq_stomp_read_failed\"), err)\n}","handlingStrategy":"retry","validationCode":"// pre-check: confirm the port is reachable and tolerant of a probe\nconn.SetReadDeadline(time.Now().Add(10 * time.Second))","typeGuard":null,"tryCatchPattern":"n, err := conn.Read(buf)\nif err != nil {\n    if errors.Is(err, os.ErrDeadlineExceeded) { /* timeout: retry or fail fast */ }\n    return fmt.Errorf(\"stomp read: %w\", err)\n}","preventionTips":["Budget generous read timeouts for slow brokers","Match TLS/plain expectations to the actual transport","Monitor broker health before credential sweeps","Retry once on transient read errors"],"tags":["network","stomp","activemq","timeout"],"backgroundTag":"request-timeout","analyzedSha":"95cc12e753bf43de7004e5aef42a9ffba3934303","analyzedAt":"2026-09-06T17:07:30.094Z","contentChangedAt":"2026-09-06T17:07:30.094Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}