-
Hello, I am trying to connect to some APC devices and I the tool is not connecting due to, what I think, a malformed, MSG_USERAUTH_BANNER. The package received is as follows:
and the responese is as follows:
The problem is coming from the last I have made some changes in the code and I was able to make it work. Now, it looks like this when connecting:
I was wondering if I could create a pull request with the changes and if so, to which branch development or master. |
Beta Was this translation helpful? Give feedback.
Replies: 7 comments 3 replies
-
You're right - the MSG_USERAUTH_BANNER message is definitely malformed. There's an extra NUL byte that doesn't belong after the banner text and language fields, and AsyncSSH doesn't allow for unexpected data at the end of a packet except in very specific circumstances. What version string does the server send when you first connect to it? Is it something unique to this type of device? |
Beta Was this translation helpful? Give feedback.
-
Hello, What version string does the server send when you first connect to it?
Is it something unique to this type of device? |
Beta Was this translation helpful? Give feedback.
-
Ok - I believe cryptlib is referring to https://cryptlib.com, which appears to provide SSH functionality on a number of embedded systems. There is an open-source version of the code, but based on a quick look at that source I don't see code which actually generates an auth banner message, so I can't quite tell if this bug was fixed at some point in cryptlib. I'm also not sure if all of the code is available as open source, or if some features are only available in the commercial closed-source version. You might want to report this issue to the cryptlib authors and see if it is something they're aware of. I'm happy to work around the issue in AsyncSSH as well, but just wanted to narrow down the check to avoid impacting other platforms. Here's an example of such a check in AsyncSSH today in SSHConnection._process_ignore: # Work around missing payload bytes in an ignore message
# in some Cisco SSH servers
if b'Cisco' not in self._server_version: # pragma: no branch
_ = packet.get_string() # data
packet.check_end() I'm thinking something similar might be possible in _process_userauth_banner for this issue, replacing: msg_bytes = packet.get_string()
lang_bytes = packet.get_string()
packet.check_end() with: msg_bytes = packet.get_string()
lang_bytes = packet.get_string()
if b'cryptlib' in self._server_version:
# Work around an extra NUL byte appearing in user
# auth banner message in some cryptlib servers
if len(packet.get_remaining_payload()) == 1: # pragma: no cover
packet.get_byte()
packet.check_end() Could you give this a try and see if it solves the problem? |
Beta Was this translation helpful? Give feedback.
-
The changes that you are proposing worked like a charm :) Below, if you dont mind, I would like to show you what I came out with for
I added some extra logging to write the auth banner and language detected. |
Beta Was this translation helpful? Give feedback.
-
This fix is now in commit 3242743 in the "develop" branch. It will get merged to master when I do the next release. I've got a few other changes I'd like to get in before doing a release, but if all goes well I should be able get that out in the next couple of weeks. Regarding updating to a newer version of cryptlib, I don't know for sure if this has already been fixed in cryptlib or not. You may want to report the bug to the cryptlib maintainers first. That would also let you know which version to suggest upgrading to if it has been fixed. Thanks for reporting this, and sharing your proposed fix! |
Beta Was this translation helpful? Give feedback.
-
Thanks to you Ron for the fast support provided. I will be looking from time to time if the fix was deployed |
Beta Was this translation helpful? Give feedback.
-
This change is now available in AsyncSSH 2.15.0. |
Beta Was this translation helpful? Give feedback.
This fix is now in commit 3242743 in the "develop" branch. It will get merged to master when I do the next release.
I've got a few other changes I'd like to get in before doing a release, but if all goes well I should be able get that out in the next couple of weeks.
Regarding updating to a newer version of cryptlib, I don't know for sure if this has already been fixed in cryptlib or not. You may want to report the bug to the cryptlib maintainers first. That would also let you know which version to suggest upgrading to if it has been fixed.
Thanks for reporting this, and sharing your proposed fix!