INFO 344 Web Tools And Development CK Wang University of Washington Spring 2014
Announcements PA4 due Tonight! No late days. – Canvas shuts down at 11:00pm, please submit earlier!
Security
Firewall Software or Hardware Separate local area network from Internet Protocol/Port, inbound & outbound
SQL Injection Common security risk What is SQL Injection – Go to site, insert malicious SQL Before hacking: – Understanding “Union” mysql clause – MySQL versions, latest version has: INFORMATION_SCHEMA.TABLES Take a look locally to understand the columns/etc
SQL Injection Try hacking this! Strategy – Get it working normally – Find out how many columns in current table – Get database name via database() – Show all tables in current database – Identify table with sensitive info (and # rows it has) – Identify column names in sensitive table – Get sensitive info! What is my username & password? Groups of 2 Lab submission
SQL Injection Solution – Use PDO! – See PHP best practices slides – PDO, prepare, bind parameters, execute
Cross Site Scripting (XSS) Attack Common security risk What is XSS Attack? – Send victim compromised site url Try hacking this! (use Firefox) Strategy – Add JS to parameter, get it to show “compromised” alert box – Look at source code, understand how it works – Add JS to override the current onclick function and alert instead – Change override function to send 15x the payment entered Groups of 2 Lab submission Hint: Google jquery override onclick Hint: need to url encode the # tag
Cross Site Scripting (XSS) Attack A lot of browsers disable this But sanitize your inputs! Reject ones with script tags!
Validate Cookies Cookies are stored on client side User can actually go change them! So if you assume cookie data is valid = Dangerous!!! A lot of websites will store “ID=XXX” in the cookie and the next time assume it’s real/valid/authenticated => not true!
Encrypt Passwords Encrypt passwords stored in your database If your system gets hacked, the passwords aren’t leaked
Sanitize HTML Same reason to prevent XSS Sanitize with PHP functions – C# Sanitize –
Questions?