I swear companies would rather buy a million dollars to get their breached data back than hire an actual IT department>2018
>be me  
>interning at gov-adjacent org for the summer, i won't name.
>asked to fix login bug  
>open the code  
>some asshole wrote login logic in frontend JS  
>literally SELECT * FROM users  
>IN THE FUCKING BROWSER  
>it fetches the entire damn user table  
>plaintext passwords  
>looping through them  
>comparing with ===  
>I'm watching a goddamn credential leak live in HD  
>returns true if it finds a match  
>otherwise  
>wait for it  
>if ("true" === "true") return false;  
>WHAT  
>THE ACTUAL  
>FUCK  
>is this dumb-as-shit logic  
>log in fails because truth exists  
>uses $.cookie to save "loggedin=yes"  
>expires: 1  
>1 what? second? year? light decade? I DON'T FUCKING KNOW
>error handler is $("error_message").show(LogIn Failed)  
>doesn’t even put "LogIn Failed" in quotes  
>this shit doesn't even run  
>ask senior dev what the hell this is and who approved this 
>he shrugs and says "it did use to work" 
>wtf.jpg  
I vaguely remember taking a photo of it on my phone, and I didn't even know where to start when attempting to fix it. The problem was the login function they actually used... authenticates users... in the browser.. using SQL. 
Instead of sending a username and password to the server and letting it tell you "yes or no," it downloads the entire user database into your browser, and then it checks if your username/passwords match any record locally. 
I don't even remember correctly if they had a real backend API, they might as well just had read/write to the DB directly. 
Didn't get a chance to finish fixing it, mostly because this happened towards the end of my shit that day + by the time the next day arrived, somebody else was apparently already working on it. 
I didn't ask, I didn't want to know -- I did want to turn this into a YouTube video. I ranted to this to my grandpa about it. He was both surprised and not surprised lol