Skip to content
Snippets Groups Projects
Commit ebece39d authored by Rob Swindell's avatar Rob Swindell :speech_balloon:
Browse files

Disable FTP Bounce (FXP) support by default

The Synchronet FTP server has (since 2001) disallowed PORT/EPRT/LPRT commands with a "reserved" port number (i.e. < 1024) as recommended by RFC2577 and when attempted, would log a "SUSPECTED FTP BOUNCE HACK ATTEMPT" in the data/hack.log file.

However, as Karloch (HISPAMSX) pointed out recently, an FTP Bounce Attack to other TCP ports was still possible (and detected/reported by some security scans as a potential vulnerability).

So, reject all PORT/EPRT/LPRT commands that specify an IP address other than that used for the control TCP connection unless the sysop specifically enables the new "ALLOW_BOUNCE" option flag (in the [ftp] section of sbbs.ini) and the user is an authenticated non-guest/anonymous user. And as before, log the attempt as a suspected hack attempt.

This change also removes the "Directory File Access" checkbox from the Synchronet Control Panel for Windows as that feature is "going away" soon (or at least, it won't be an FTP-specific option/feature if it remains).
parent 9344a7d8
No related branches found
No related tags found
1 merge request!463MRC mods by Codefenix (2024-10-20)
Pipeline #1332 passed
...@@ -78,7 +78,7 @@ void __fastcall TFtpCfgDlg::FormShow(TObject *Sender) ...@@ -78,7 +78,7 @@ void __fastcall TFtpCfgDlg::FormShow(TObject *Sender)
CmdLogCheckBox->Checked=MainForm->ftp_startup.options&FTP_OPT_DEBUG_RX; CmdLogCheckBox->Checked=MainForm->ftp_startup.options&FTP_OPT_DEBUG_RX;
DebugTxCheckBox->Checked=MainForm->ftp_startup.options&FTP_OPT_DEBUG_TX; DebugTxCheckBox->Checked=MainForm->ftp_startup.options&FTP_OPT_DEBUG_TX;
DebugDataCheckBox->Checked=MainForm->ftp_startup.options&FTP_OPT_DEBUG_DATA; DebugDataCheckBox->Checked=MainForm->ftp_startup.options&FTP_OPT_DEBUG_DATA;
DirFilesCheckBox->Checked=MainForm->ftp_startup.options&FTP_OPT_DIR_FILES; AllowBounceCheckBox->Checked=MainForm->ftp_startup.options&FTP_OPT_ALLOW_BOUNCE;
AllowQWKCheckBox->Checked AllowQWKCheckBox->Checked
=MainForm->ftp_startup.options&FTP_OPT_ALLOW_QWK; =MainForm->ftp_startup.options&FTP_OPT_ALLOW_QWK;
LocalFileSysCheckBox->Checked LocalFileSysCheckBox->Checked
...@@ -162,10 +162,10 @@ void __fastcall TFtpCfgDlg::OKBtnClick(TObject *Sender) ...@@ -162,10 +162,10 @@ void __fastcall TFtpCfgDlg::OKBtnClick(TObject *Sender)
MainForm->ftp_startup.options|=FTP_OPT_ALLOW_QWK; MainForm->ftp_startup.options|=FTP_OPT_ALLOW_QWK;
else else
MainForm->ftp_startup.options&=~FTP_OPT_ALLOW_QWK; MainForm->ftp_startup.options&=~FTP_OPT_ALLOW_QWK;
if(DirFilesCheckBox->Checked==true) if(AllowBounceCheckBox->Checked==true)
MainForm->ftp_startup.options|=FTP_OPT_DIR_FILES; MainForm->ftp_startup.options|=FTP_OPT_ALLOW_BOUNCE;
else else
MainForm->ftp_startup.options&=~FTP_OPT_DIR_FILES; MainForm->ftp_startup.options&=~FTP_OPT_ALLOW_BOUNCE;
if(LocalFileSysCheckBox->Checked==false) if(LocalFileSysCheckBox->Checked==false)
MainForm->ftp_startup.options|=FTP_OPT_NO_LOCAL_FSYS; MainForm->ftp_startup.options|=FTP_OPT_NO_LOCAL_FSYS;
else else
......
...@@ -164,13 +164,13 @@ object FtpCfgDlg: TFtpCfgDlg ...@@ -164,13 +164,13 @@ object FtpCfgDlg: TFtpCfgDlg
ShowHint = True ShowHint = True
TabOrder = 1 TabOrder = 1
end end
object DirFilesCheckBox: TCheckBox object AllowBounceCheckBox: TCheckBox
Left = 148 Left = 148
Top = 86 Top = 86
Width = 125 Width = 125
Height = 20 Height = 20
Hint = 'Allow users access to files in directory, but not in database' Hint = 'Allow authenticated users to use FTP Bounce (not recommended)'
Caption = 'Directory File Access' Caption = 'Allow Bouncing'
ParentShowHint = False ParentShowHint = False
ShowHint = True ShowHint = True
TabOrder = 8 TabOrder = 8
......
...@@ -69,7 +69,7 @@ __published: ...@@ -69,7 +69,7 @@ __published:
TButton *OKBtn; TButton *OKBtn;
TButton *CancelBtn; TButton *CancelBtn;
TButton *ApplyBtn; TButton *ApplyBtn;
TCheckBox *DirFilesCheckBox; TCheckBox *AllowBounceCheckBox;
TTabSheet *IndexTabSheet; TTabSheet *IndexTabSheet;
TCheckBox *AutoIndexCheckBox; TCheckBox *AutoIndexCheckBox;
TEdit *IndexFileNameEdit; TEdit *IndexFileNameEdit;
......
...@@ -2873,7 +2873,7 @@ static void ctrl_thread(void* arg) ...@@ -2873,7 +2873,7 @@ static void ctrl_thread(void* arg)
if(pasv_sock!=INVALID_SOCKET) { if(pasv_sock!=INVALID_SOCKET) {
ftp_close_socket(&pasv_sock,&pasv_sess,__LINE__); ftp_close_socket(&pasv_sock,&pasv_sess,__LINE__);
} }
memcpy(&data_addr, &ftp.client_addr, ftp.client_addr_len);
p=cmd+5; p=cmd+5;
SKIP_WHITESPACE(p); SKIP_WHITESPACE(p);
if(strnicmp(cmd, "PORT ",5)==0) { if(strnicmp(cmd, "PORT ",5)==0) {
...@@ -3009,7 +3009,9 @@ static void ctrl_thread(void* arg) ...@@ -3009,7 +3009,9 @@ static void ctrl_thread(void* arg)
} }
inet_addrtop(&data_addr, data_ip, sizeof(data_ip)); inet_addrtop(&data_addr, data_ip, sizeof(data_ip));
if(data_port< IPPORT_RESERVED) { bool bounce_allowed = (startup->options & FTP_OPT_ALLOW_BOUNCE) && !(user.rest & FLAG('G'));
if(data_port < IPPORT_RESERVED
|| (memcmp(&data_addr, &ftp.client_addr, ftp.client_addr_len) != 0 && !bounce_allowed)) {
lprintf(LOG_WARNING,"%04d <%s> !SUSPECTED BOUNCE ATTACK ATTEMPT to %s port %u" lprintf(LOG_WARNING,"%04d <%s> !SUSPECTED BOUNCE ATTACK ATTEMPT to %s port %u"
,sock,user.alias ,sock,user.alias
,data_ip,data_port); ,data_ip,data_port);
......
...@@ -106,6 +106,7 @@ static struct init_field ftp_init_fields[] = { ...@@ -106,6 +106,7 @@ static struct init_field ftp_init_fields[] = {
#define FTP_OPT_NO_LOCAL_FSYS (1<<5) #define FTP_OPT_NO_LOCAL_FSYS (1<<5)
#define FTP_OPT_DIR_FILES (1<<6) /* Allow access to files in dir but not in database */ #define FTP_OPT_DIR_FILES (1<<6) /* Allow access to files in dir but not in database */
#define FTP_OPT_KEEP_TEMP_FILES (1<<7) /* Don't delete temp files (for debugging) */ #define FTP_OPT_KEEP_TEMP_FILES (1<<7) /* Don't delete temp files (for debugging) */
#define FTP_OPT_ALLOW_BOUNCE (1<<8)
#define FTP_OPT_LOOKUP_PASV_IP (1<<9) /* resolve public IP address for PASV response */ #define FTP_OPT_LOOKUP_PASV_IP (1<<9) /* resolve public IP address for PASV response */
#define FTP_OPT_NO_HOST_LOOKUP (1<<11) #define FTP_OPT_NO_HOST_LOOKUP (1<<11)
#define FTP_OPT_NO_RECYCLE (1<<27) /* Disable recycling of server */ #define FTP_OPT_NO_RECYCLE (1<<27) /* Disable recycling of server */
...@@ -125,6 +126,7 @@ static ini_bitdesc_t ftp_options[] = { ...@@ -125,6 +126,7 @@ static ini_bitdesc_t ftp_options[] = {
{ FTP_OPT_NO_LOCAL_FSYS ,"NO_LOCAL_FSYS" }, { FTP_OPT_NO_LOCAL_FSYS ,"NO_LOCAL_FSYS" },
{ FTP_OPT_DIR_FILES ,"DIR_FILES" }, { FTP_OPT_DIR_FILES ,"DIR_FILES" },
{ FTP_OPT_KEEP_TEMP_FILES ,"KEEP_TEMP_FILES" }, { FTP_OPT_KEEP_TEMP_FILES ,"KEEP_TEMP_FILES" },
{ FTP_OPT_ALLOW_BOUNCE ,"ALLOW_BOUNCE" },
{ FTP_OPT_LOOKUP_PASV_IP ,"LOOKUP_PASV_IP" }, { FTP_OPT_LOOKUP_PASV_IP ,"LOOKUP_PASV_IP" },
{ FTP_OPT_NO_HOST_LOOKUP ,"NO_HOST_LOOKUP" }, { FTP_OPT_NO_HOST_LOOKUP ,"NO_HOST_LOOKUP" },
{ FTP_OPT_NO_RECYCLE ,"NO_RECYCLE" }, { FTP_OPT_NO_RECYCLE ,"NO_RECYCLE" },
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment