Original Post
Hi, Political forces are at work in my company and I'm being forced to implement a custom I-just-thought-this-up-in-5-minutes-but-it'll-be-good-enough security solution for our application. I'm very demoralized at this point, and only this blog entry http://www.butunclebob.com/ArticleS.MichaelFeathers.LameDuck is keeping me going. What I'd like to know is, if I have a pure socket connection so there's no authentication to ActiveDirectory, no SSL, no encryption, no nothing, what are the potential security holes I face here? Is is possible for someone to authenticate to our system, using our hair-brained scheme, and then have someone else inject messages into the socket stream so that we (the server) can't tell the difference between who's putting in valid data, and who's impersonating? Our hair-brained scheme involves generating a daily key, which is sent to the client as a challenge every time they connect. They then use this to encrypt a couple of pieces of known information, which they then pass back to us. We encrypt the same information out of our database and compare the two, and, if they're the same, then we retrieve their ActiveDirectory password out of our database, which is stored in plaintext. We pass their username, which they supply in the login packet, with their password out of our database, to a .NET AD call which determines simply if their username and password are in AD. If this process succeeds, then we assume they're a valid user, and we trust every further piece of information received on this socket for the rest of the day. So, in order that I don't go out of my mind, and so that our client gets a system worthy of the money they're paying us for, can you guys please highlight all the flaws and holes in the system so that I can pass these along. The first hole I can see is that the daily key is the same every time you connect today. So presumably someone can sniff your login packet, and that packet will then be valid for login for the rest of the day, which would allow unauthorised access for the rest of the day.
m_ServerSocket = new Socket(ipe.AddressFamily, SocketType.Stream, ProtocolType.Tcp);
m_ServerSocket.Bind(ipe);
m_ServerSocket.Listen(100);
m_ServerSocket.BeginAccept(new AsyncCallback(OnClientConnect), m_ServerSocket);