Skip to content

"Data longer than 2147483647 is not supported" exception when connecting to Tectia ssh server running on a mainframe #713

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
edmlin opened this issue Jul 30, 2020 · 13 comments · Fixed by #823
Milestone

Comments

@edmlin
Copy link

edmlin commented Jul 30, 2020

This is similar to issue #41 but not exactly the same.
When connecting to Tectia ssh server running on a mainframe, I intermittently got an exception: Data longer than 2147483647 is not supported.
Tracing into the code I found that it looks like sometimes the first 4 bytes in the SSH_MSG_IGNORE message are filled with arbitrary numbers instead of the actual data length. When the number is greater than int.MaxValue the exception is thrown.
Changing IgnoreMessage.LoadData to the following fixed the issue:

        protected override void LoadData()
        {
            var dataLength = ReadUInt32();
            if (dataLength > (DataStream.Length - DataStream.Position))
            {
                DiagnosticAbstraction.Log("SSH_MSG_IGNORE: Length exceeds data bytes, data ignored.");
                Data = Array<byte>.Empty;
            }
            else if (dataLength > int.MaxValue)
            {
                throw new NotSupportedException(string.Format(CultureInfo.CurrentCulture, "Data longer than {0} is not supported.", int.MaxValue));
            }
            else
            {
                Data = ReadBytes((int) dataLength);
            }
        }

The server version says "SSH-2.0-4.3.6500.1 SSH Secure Shell".

@drieseng
Copy link
Member

drieseng commented Aug 1, 2020

@edmlin Would it be possible to contact Tectia, and ask them whether this is a know issue? I'm ok with adding targeted workarounds, but for this to happen we need to be able to uniquely identify the SSH (server) software and version to which the workaround applies.

@edmlin
Copy link
Author

edmlin commented Aug 4, 2020

I can't get a confirmation from Tectia.
The change in above post only swaps the 2 abnormal condition handling and protect clients from malformed messages. I don't think there will be any negative effect. Maybe there's a better way to do it. I hope this can be addressed in this repo so in the future when I upgrade to a newer version my app won't break.
Thanks.

@dinehs
Copy link

dinehs commented Jan 7, 2021

Hi Edmin,

Do you have any workarounds of this issues.
I am used the latest ssh.net 2020 version, but still the issue persist again.

Thanks,
Dinesh

@edmlin
Copy link
Author

edmlin commented Jan 7, 2021

Yes my workaround is the code change I mentioned above in file src/Renci.SshNet/Messages/Transport/IgnoreMessage.cs.

@dinehs
Copy link

dinehs commented Jan 7, 2021 via email

@edmlin
Copy link
Author

edmlin commented Jan 7, 2021

Yes. Then you can build a DLL from the modified source code or include the project to you solution.

@dinehs
Copy link

dinehs commented Jan 7, 2021 via email

@dinehs
Copy link

dinehs commented Jan 7, 2021

Hi Drieseng,

Do you have any plan to fix the issue for the upcoming release?.

Thanks,
Dinesh

@drieseng
Copy link
Member

drieseng commented Jan 9, 2021

@edmlin @dinehs Are you both using (the same version of) "Tectia ssh server"?

@dinehs
Copy link

dinehs commented Jan 9, 2021 via email

@dinehs
Copy link

dinehs commented Feb 25, 2021 via email

@jglazer63
Copy link

Is there any way we can get this compiled into the nuget package? My company will not allow me to download source or bring in "unknown" software. Nuget is fine though.

@WojciechNagorski
Copy link
Collaborator

The 2023.0.1 version has been released to Nuget: https://www.nuget.org/packages/SSH.NET/2023.0.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants