Skip to content

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

Closed

Description

@edmlin

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".

Activity

  1. drieseng commented on Aug 1, 2020

    @drieseng
    Member

    @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.

  2. edmlin commented on Aug 4, 2020

    @edmlin
    Author

    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.

  3. dinehs commented on Jan 7, 2021

    @dinehs

    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

  4. edmlin commented on Jan 7, 2021

    @edmlin
    Author

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

  5. dinehs commented on Jan 7, 2021

    @dinehs
  6. edmlin commented on Jan 7, 2021

    @edmlin
    Author

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

  7. dinehs commented on Jan 7, 2021

    @dinehs
  8. dinehs commented on Jan 7, 2021

    @dinehs

    Hi Drieseng,

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

    Thanks,
    Dinesh

  9. drieseng commented on Jan 9, 2021

    @drieseng
    Member

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

  10. dinehs commented on Jan 9, 2021

    @dinehs
  11. dinehs commented on Feb 25, 2021

    @dinehs
  12. jglazer63 commented on Apr 8, 2021

    @jglazer63

    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.

  13. added this to the 2023.0.1 milestone on Nov 19, 2023
  14. WojciechNagorski commented on Dec 29, 2023

    @WojciechNagorski
    Collaborator
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions