 Okay, I recently did a video where I was talking about a website I went to for my kids and it's a website for kids and how I realized that that website was accidentally dumping a lot of user information. Again, this is a website for kids. It was dumping their birth dates, their email address and their real names, stuff like that. And of course I can't show you the actual site because that wouldn't be safe for those kids. I've already contacted the company. I'm waiting for them to do something about it but I want to give you an example. People asked exactly what was wrong and what could be fixed and of course I can't see what's on the server side but I created this example. I spent the last 30 minutes just creating this basic little example with some fake user data and fake comments and stuff like that. So I can show you the sort of thing that went wrong and it's an honest mistake but it should be a simple fix unless they have spaghetti code on their server. So real quick, here's my web browser. This is a server I just threw up. I save that and it sounds like I'm throwing up. This is a server I just spun up. There we go and I got a few files here. Got a couple HTML and then I got some server side PHP scripts that I'm going to show you. On the right here I got my developers console so we can see what's loading and then here is a I'm logged into the shell and again this is just a server I threw up. I spun up just about 20-30 minutes ago to run this on so I can show it to you. So let's just see what's going on here. I made this basic little I have comments and comments bad. Let's look at comments first. So it loads up this little comment box to post. It doesn't actually post anything. It's just there for looks and then it loads up these comments from a database with a nice little avatar and user names, dates that they were commented and we can also see what their comment is. So that was comments. Now let's look at bad comment. It looks exactly the same but there is a key difference. So when you're loading up, so you have databases and you have to cross reference databases. So normally you wouldn't, you could have a database with all your comments in it and basically hard code, user names and stuff like that into there but you normally wouldn't do that. And this example I'm going to show you one of the reasons you would cross reference is avatars and so let's say someone changes their avatar. You want it to update in the comments and you want to go through and change every entry in the database. So what is happening here is I have three PHP scripts. Get comments, get user data and get user data bad. Now again let's look at, I guess we'll look at the bad one first. Comments bad. And the only difference between this and the other one is the PHP side of the script. So you can see here, if you open your developer's console and you go to network and we can go to all or XHR since that's what we're looking at but I'll just leave it as all for now. You can see here that we get user data bad and we get user comments. So what my code is doing is it's loading up both those things, loading up user data, putting that into an array and doing the same with the comments and as it loops through the arrays for the comments, the comment, it's grabbing stuff from the database, it's grabbing the user name, the date the comment was posted and what the comment is but again we need the avatar and you don't want to embed that into the table for the comments because if someone changes their avatar you want it to change on the comments. So that's why we also load up user data. So all we're loading up here, all we need is we need the user name and their avatar so we can cross-reference it but if I expand all of these you can see that I'm loading up, I'm grabbing their user name, their avatar, their email address, their status, whether they're a child or parent which is how this was set up on that website. I did notice after I set this up just before I went to record this video that I set up some of those parents but their birth dates they're only like seven years old but that was just because this is made up data. The last time they logged in the date it was created and their date of birth, first name and last name this is all sort of things that I saw on that website and that should not be dumped. You're not seeing it on the web page but it's being sent to your web browser and then the script is going through and grabbing information it needs and displaying it and you may not see it over here but it's still coming to your computer. It is on your computer. Let's go back now and we'll just go to comments and now we'll look at or I forgot to change it in the script. Okay let's look at the script. Let me go ahead and go into comments.html. Yeah so right now comments and comments bad are the same except for this line. We just changed that. Now let's go back in here and refresh this. So again we're grabbing the comments and we're also grabbing user data but this time under user data we are only grabbing the username and their avatar because we don't need that information. That information shouldn't be pushed to other users so it looks the same acts the same but all that extra information is not being sent. Let's look again at that that output. So again we have three PHP codes here we'll actually look at the code in a moment but here's the output. This one outputs your comments in a JSON format so you get the username you get the date it was posted and what the comment is and does that for each of the comments but then you have user data here and this is giving us the username for each user and their avatar but get user data bad is dumping all of their information. So how easy is this to fix? Well let's look at those examples so we got get we'll say get user bad so what we're doing here is we're looking oh by the way again this is just a test an example so there's lots of bad things about this that could be done better for example I'm not using a MySQL database which is on a real website you should be using something like MySQL. I'm using SQLite3 database so that I can put it into this folder so I copy this server put it in a folder and share it with you guys going to post this on GitLab for you and I'll put a link in the description so you can download this code and look at it but right now the database is actually in a database file in the folder with all the scripts and that is super super bad you never want to do that because basically anybody who knows that what's being called can just pull down that entire database with all the tables so when you're using MySQL you're actually using a server to connect to all this stuff the server is connecting to itself if that makes any sense we're here I'm just using a database file you don't want to do that if you are going to use SQLite3 on a website I'd recommend not in most cases you want it outside of your web directory but that's not what was wrong with the website I'm talking about I'm just pointing out I know that I did this in this example because this is just an example our big problem again going back into our database here is the same the same exact code would be for MySQL I'm pretty sure SQL and SQLite and SQLite3 is the select so you're saying select what do you want to select and where do you want to select it from so we're using this database file and there's two tables in there right now a users table and a comments table right here we're saying select all everything from the users table which means it's displaying everything from the users table you don't want to do that and that's going through that now putting it as JSON what we do want to do is if we go into get user data instead of get user data bad this is all we had to change is this one line instead of having an asterisk there saying all we say we just want the username and the avatar those are the only two things want so I can't see what that website is doing on their server but again unless it's spaghetti code it's something as simple either they have an asterisk in this spot and it's dumping everything or they went in here and did things like show me the username show me their date of birth show me their last login date log in something like that I don't remember exactly how I wrote it in the database which is an easy thing to do by accident but it's also very bad when you do it by accident especially on a website like the one I'm talking about but it should be easy to fix they should be able to go through again they don't they shouldn't have to go and change every single page just the server side that's serving it up so again the only thing they would have to do for example if this was their code was come in here and do this username comma avatar and save that and that's all they would have to do and it would fix the problem and they might have to do that in a few different files but hopefully they've written the code so that it's not there should be too many files they have to share change because things should be code should be used more than once and if you're grabbing information in a certain way that code should be in one spot again not repeating code programming I kind of fumbled around there but I think hopefully you guys get what I'm saying so again this is something you should look at especially if your kids are using a website it doesn't take a lot so let's say you are Joe Schmo you know nothing about computers your kids are on a website okay like this okay this is their website and there's comments and stuff and other users whatever it is all you have to do is open up your developers console okay f12 in chrome or control shift i if you don't have f12 keys might be a little bit different other browsers but just look it up and then you just go to your network tab right here network make sure you have all selected and just start clicking on these things and you'll start seeing different information now if you don't want to go through it all again just click xhr that's usually xml html reference or htp reference or something like that and most of the time nowadays it's going to be javascript but you click on that that's usually information being sent from a database on the server or something like that and from there you can come in here and just right click this and say expand recursively and just start looking through here again you don't have to be a genius you start seeing other people's email addresses or phone numbers or private information you got to go whoa whoa that's bad again you open up your developers tools f12 in a chrome based browser go to networks xhr and then just start clicking through these and see if you see anything you shouldn't if you do you need to stop using that site and let them know so that they can fix it so again that is hopefully that explains the question because i did have comments asking you know what exactly was the problem and how easy is it to fix uh and it was just someone asking because they they were wondering again i don't know what's going on the server side but this is what's happening their server is sending my web browser everyone's information i'm not seeing it in the web page but it's being sent to my server whether i have this console open or closed it's being sent to my web browser um and that means that anybody who's surfing that site can see that information and even if you're not going to do something bad with it that doesn't mean someone else is going to do something bad with it again i contacted them just over a week ago uh they sent me a response saying it was going to be passed along and asked me to log out and log back in again this has nothing to do with logging out logging back in because this is information coming from the server um that's something it's it's a security thing security things should never be done on the client side so if logging out logging back in fix the problem there's still a problem um so yeah again i'll put this up on gitlab and i'll put a link in the description of this video so you can download and all you have to do is you know spin up a web server uh with a php and um the sql light three or sql light three or have you say i think it's sql light three um plug in or module for php and you just copy this folder again in this example i put the database right in the folder you never want to do that because that means anybody who can figure out figures out that's that they can just type in data.db and now they i can download the entire um database and they have it on their computer everything whether it was coming out in the script or not so you never want to put your database in the folder that your program is running in on your website should be outside of the web directory or preferably using a server like mysql uh sequel light is usually used for local things like on your phone it will be used for contacts your sms messages where it's all stored on your phone not necessarily on servers you can use it on servers and i'm saying it's horrible but even the creators of it say if you're going to have big databases this is that you shouldn't be using their project because it's for smaller stuff so definitely if your website's big um i know that if you set up like a next cloud server uh you have the option to go either way i think the default is a sequel light database and but it constantly warns you you should upgrade to or switch over to or migrate to however you want to say it to a mysql so again uh yeah check this out uh don't don't try going to the server because i'm going to shut down as soon as i'm done recording this but i'll put a link in the description to gitlab gitlab.com forward slash metalx 1000 i'll call it something like um bad database dump or something like that but i'll try to link in the description and you can just download this file unpackage it to uh to your web directory and as long as you have php and sequel light php module installed uh you should be good to go and you can play around with this yourself so check that out i thank you for watching i hope that answers some questions i hope it educated people who may not be technical you do want to open up this developers console every once in a while and look at stuff um because it doesn't it doesn't take much doesn't take much to go oh look there's information here that shouldn't be here you know it's it's plain text and words so thanks for watching visit filmsbychris.com that's chris the k and check out all the links in the description i hope that you have a great day