Bug 171882 - [crypto] incorrect port fowarding with server allocated port
Summary: [crypto] incorrect port fowarding with server allocated port
Status: Open
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: Unspecified
Hardware: Any Any
: Normal Affects Only Me
Assignee: freebsd-bugs (Nobody)
URL:
Keywords: patch
Depends on:
Blocks:
 
Reported: 2012-09-23 03:40 UTC by HIROSHI OOTA
Modified: 2018-05-20 23:52 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description HIROSHI OOTA 2012-09-23 03:40:08 UTC
SSH standard supports server allocated port.
We can use the capability the ssh option -R 0:host:hostport.
But, I specify it multiple, all  port would be fowarded to the first port.

How-To-Repeat: 
term1$ ssh -v -R 0:localhost:23 -R 0:localhost:25 -R 0:127.0.0.1:80 -N
debug1: remote forward success for: listen 0, connect 127.0.0.1:21
Allocated port 41791 for remote forward to 127.0.0.1:21
debug1: remote forward success for: listen 0, connect 127.0.0.1:25
Allocated port 23513 for remote forward to 127.0.0.1:25
debug1: remote forward success for: listen 0, connect 127.0.0.1:80
Allocated port 59246 for remote forward to 127.0.0.1:80

term2$ telnet localhost 23513
Trying ::1...
Connected to localhost.
Escape character is '^]'.
220 xxx FTP server (Version xxx) ready.

term2$ telnet localhost 59246
Trying ::1...
Connected to localhost.
Escape character is '^]'.
220 xxx FTP server (Version xxx) ready.

these ports should be forwaded to 25(smtp) and 80(http), not 21(ftp).
Comment 1 HIROSHI OOTA 2012-09-23 13:39:12 UTC
This problem was corrected in OpenSSH V6.1.
Comment 2 HIROSHI OOTA 2012-09-23 15:00:00 UTC
I tested under newest source. but it does not run correctly.
The flags for datafellows is conflicted.

Index: /usr/src/crypto/openssh/compat.h
===================================================================
--- /usr/src/crypto/openssh/compat.h    (revision 240847)
+++ /usr/src/crypto/openssh/compat.h    (working copy)
@@ -60,7 +60,7 @@
  #define SSH_BUG_RFWD_ADDR      0x02000000
  #define SSH_NEW_OPENSSH                0x04000000
  #define SSH_BUG_DYNAMIC_RPORT  0x08000000
-#define SSH_BUG_LARGEWINDOW    0x08000000
+#define SSH_BUG_LARGEWINDOW    0x10000000

  void     enable_compat13(void);
  void     enable_compat20(void);
Comment 3 Eitan Adler freebsd_committer freebsd_triage 2018-05-20 23:52:57 UTC
For bugs matching the following conditions:
- Status == In Progress
- Assignee == "bugs@FreeBSD.org"
- Last Modified Year <= 2017

Do
- Set Status to "Open"