CVE-2020-8815 (C#, published 2020-02-12T15:15Z)
Description: value: Improper connection handling in the base connection handler in IKTeam BearFTP before v0.3.1 allows a remote attacker to achieve denial of service via a Slowloris approach by sending a large volume of small packets.
Severity: MEDIUM (CVSS v3 base score: 7.5)
Weakness: CWE-20 \u2014 Improper Input Validation
The product receives input or data, but it does
        not validate or incorrectly validates that the input has the
        properties that are required to process the data safely and
        correctly.
Repository: https://github.com/kolya5544/BearFTP
Files changed:
BearFTP/Program.cs
CHANGELOG.txt
Commit message: Anonymous configuration fix, base thread vulnerability fix. v0.3.1


Vulnerable code:
                                //Receiving handler START
                                string answ = "";
                                bool flag = true;
                                bool upper = true;

                                while (flag)
                                {
                                    int a = sr.Read();
                                    if (upper)
                                    {
                                        answ += char.ToUpper((char)a);
                                    } else
                                    {
                                        answ += (char)a;
                                    }
                                    if (a == 13)
                                    {
                                        flag = false;
                                    }
                                    if (a == 0x20)
                                    {
                                        upper = false;
                                    }
                                    if (answ.Length > 128)
                                    {
                                        client.Close();
                                    }
                                }
                                answ = answ.Trim();
                                //Receiving handler END
                                    if (r.IsMatch(temp) && temp.Length < 32 && temp.Length > 1 && (temp != "anonymous" && !AllowAnonymous))
                                            var bytes = default(byte[]);
                                                bytes = memstream.ToArray();
                                            System.IO.File.WriteAllBytes("dumps/dump_i" + rnd.Next(1, 2000000000).ToString() + ".txt", bytes);
v0.3.0:
- Toggleable anonymous logins
- Per-IP logs (create "iplogs" folder)
- Max connections per second and max active connections are now changeable
- Buffer size can now be changed (def.8192) 
- Fixed lower-case command handling
- Final attempt to fix an encoding bug related to outputting control characters
- Changeable bantime
- Toggleable ban on big amount of errors (a.k.a some sort of service probe)
- Moved default config to Resources

Fixed code:
                                
                                string answ = sr.ReadLine(); //Who'd think this ACTUALLY works. BUT: It's doesnt work on Linux? (Needs testing)
                                //Tested on Ubuntu 16.04 client and 18.04 server. Seems to work!
                         
                                string upperfix = answ.Split(' ')[0].ToUpper();
                                answ.Replace(answ.Split(' ')[0], upperfix); //Fixing the lowercase commands an easy way
                                    if (r.IsMatch(temp) && temp.Length < 32 && temp.Length > 1 && (temp != "anonymous" || AllowAnonymous))
                                            var bytess = default(byte[]);
                                                bytess = memstream.ToArray();
                                            System.IO.File.WriteAllBytes("dumps/dump_i" + rnd.Next(1, 2000000000).ToString() + ".txt", bytess);
v0.3.1:
- Fixed AllowAnonymous handling (oops)
- One more attempt to fix encoding break on some characters (only affects console)
- Fixed improper handling of incoming data on base socket (a.k.a base socket thread overuse fix)