question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Disconnect reason for authentication

See original GitHub issue

with AuthenticationEnabled you get a instand unknown disconnect if you send to server before the AuthenticationSucceeded event fired.

so here you get a disconnect because we send a message before auth event.

TcpClient.Connect();
if (TcpClient != null && TcpClient.Connected)
    TcpClient.Send(data, meta);

[WatsonTcpClient] connecting with SSL to 192.168.2.170:59141 [WatsonTcpClient] connected to 192.168.2.170:59141 –> Send is here [WatsonMessage] found header demarcation [WatsonMessage] header processing complete {“s”:“AuthRequired”,“len”:0} [WatsonTcpClient] authentication required by server; please authenticate using pre-shared key [WatsonMessage] non-graceful termination by peer [WatsonTcpClient] disconnect detected

with waiting for AuthenticationSucceeded event and then send the first messages to server you get: [WatsonTcpClient] connecting with SSL to 192.168.2.170:59141 [WatsonTcpClient] connected to 192.168.2.170:59141 [WatsonMessage] found header demarcation [WatsonMessage] header processing complete {“s”:“AuthRequired”,“len”:0} [WatsonTcpClient] authentication required by server; please authenticate using pre-shared key [WatsonMessage] found header demarcation [WatsonMessage] header processing complete{“s”:“AuthSuccess”,“len”:25} [WatsonTcpClient] authentication successful –> Send is here and working

it is logical and not an error, but if you do not recognize it, the reason for the disconnect is difficult to find. maybe you have an idea to some error message, or a new public bool Authenticated { get; private set; }

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:8 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
jchristncommented, Jul 13, 2021

Ok - so the reason this is happening is that a message is arriving without validation authentication. The message contains data that never gets read, meaning, when the server DataReceiver loop continues, it’s expecting to find the start of a new message, but there’s data from the past message waiting to be read in the stream.

I’m going to change the behavior such that on authentication failure, the server proactively disconnects and disposes the client rather than leaving the connection in-tact. Leaving it in-tact actually creates a DoS vulnerability in that anyone could connect and just keep firing messages at the server.

0reactions
jchristncommented, Jul 13, 2021

Hi @Jyck please check out the following and re-open if any issues. Thanks for filing this!

NuGet: https://www.nuget.org/packages/WatsonTcp/4.8.10 Commit: https://github.com/jchristn/WatsonTcp/commit/f7d1242fc93ec882f4f857e29acb14841616c180

Read more comments on GitHub >

github_iconTop Results From Across the Web

Disconnect Reason Guide
This code is similar to 401 (Unauthorized), but indicates that the client MUST first authenticate itself with the proxy. SIP access authentication is...
Read more >
C881G-4G-GA-K9 Session disconnect reason codes
Session disconnect reason = Authentication failed(29). Tried to find out what is the meaning of codes (6 and 29) but without success.
Read more >
Examine Disconnect Reason for IMS-AUTHORIZATION- ...
When the ims-authorization-revoked Disconnect Reason is Pegged? The most common scenario is the PGW receives Re-Auth-Request (RAR) from PCRF ...
Read more >
Outlook disconnected after enabling modern authentication
The mailbox shows "Disconnected" in the status bar. Cause. A known issue in Office creates a miscommunication between Office and Windows that ...
Read more >
What's the purpose? Strange login attemps "sshd[***] ...
It is likely that the attacker is using some custom code to brute-force the server which is ending up in malformed authentication requests ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found