-
Notifications
You must be signed in to change notification settings - Fork 366
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
BufferException: Underflow error #509
Comments
Which servers? Which SFTP protocol version? Use debug or trace logging to capture the content of the response to the STAT request, then provide the log. (Or run the client with a debug breakpoint in |
Next time please provide the buffer content as copyable text. A screenshot is extremely cumbersome to work with. What server is this? It appears to be broken. If I parse this buffer content as an SFTP v6 SSH_FXP_ATTR packet, I cannot match it against the draft RFC.
Because we read an allocation size (due to the wrong flags), we skip 8 bytes and end up reading some of the characters (bytes 99 111 95 114, hex 0x63_6F_5F_72) as a string length, and then the exception occurs. What server is this? It is broken; it sends invalid flags. We cannot do anything about this in the client side. File a bug report against that server, and try to avoid using SFTP v6 for that server: force SFTP v3. |
I'm sorry for just attaching a screenshot. This is our internal SFTP server (ProFTPD), which is old. I'll let our team know about this. I managed to avoid the exception by using SFTP version 3 in the client. Thank you very much for your help. |
I'll close this issue |
BTW: this is proftpd/proftpd#578 . Was fixed in proftpd version 1.3.7rc1 in October 2019. |
There is a minor bug in Apache MINA sshd, though: when we request file attributes, we tell the server we're interested in all items: mina-sshd/sshd-sftp/src/main/java/org/apache/sshd/sftp/client/impl/AbstractSftpClient.java Lines 1027 to 1029 in 5a78e6d
This sends 0x00_00_FF_FF. But this is not correct. In SFTP >= v4, bit 0x2 MUST NOT be set:
Therefore re-opening to fix this. |
In SFTP versions >= 4, the flags must not include flag 0x2 (SSH_FILEXFER_ATTR_UIDGID).[1] Throw an exception if the client receives this flag from the server, and ensure the client does not send this flag. On the server side, we never send back this flag in SFTP >= v4, and we silently ignore it if a client sends it. [1] https://datatracker.ietf.org/doc/html/draft-ietf-secsh-filexfer-03#section-5.1 Bug: #509
Done in commit 37d239e. |
Version
2.12.1
Bug description
code example:
Actual behavior
SFTP client not working as expected.
I'm receiving this error
org.apache.sshd.common.util.buffer.BufferException: Underflow: requested=1668243314, available=39
This happens only with some SFTP servers.
Expected behavior
To resolve this issue
Relevant log output
No response
Other information
No response
The text was updated successfully, but these errors were encountered: