and how not to be bad at it ▸ The Owasp(Open Web Application Security project) is an organization dedicated to providing education to developers about web app sec ▸ They publish a list of the 10 most common and dangerous vulnerabilities for web apps ▸ This is a explanation of what the top 10 are and how to fix them
sample educational rails web app with the top 10 vulnerabilities baked in, plus some fun extras. ▸ I’ll also show a brief demo of how easy it is to find these bugs.
and Session Management ▸ XSS ▸ Insecure Direct Object Ref ▸ Misconfiguration ▸ Data Exposure ▸ Missing Function level access Control ▸ Cross Site Request Forgery ▸ Using components with Know Vulnerabilities ▸ Unvalidated Redirects and Forwards
INTRUDERS TO COMPROMISE INFORMATION SECURITY ARE COMPREHENSIVE USER TRAINING AND EDUCATION. ENACTING POLICIES AND PROCEDURES SIMPLY WON'T SUFFICE. EVEN WITH OVERSIGHT THE POLICIES AND PROCEDURES MAY NOT BE EFFECTIVE MY ACCESS TO MOTOROLA, NOKIA, ATT, SUN DEPENDED UPON THE WILLINGNESS OF PEOPLE TO BYPASS POLICIES AND PROCEDURES THAT WERE IN PLACE FOR YEARS BEFORE I COMPROMISED THEM SUCCESSFULLY Kevin Mitnick SHOULD ALL DEVS LEARN ABOUT THIS?
Happens when untrusted data is sent to a Query interpreter or command processor ▸ Never trust user input ▸ NEVER TRUST USER INPUT!!!! ▸ Common ways to mitigate the issue include escaping the user input, casting it to a strongly type variable (ie an int for int lookups), and parameterizing your query ▸ Example: user = User.where(email = #{param.email}).first ') OR admin = 't' --'")&user[password]=testtest1&user[p assword_confirmation]=testtest1
existing user accounts ▸ Happens when the user is presented with a message detailing user information ▸ Example: the user is presented with a message when unsuccessfully attempting to login “User [email protected] doesn’t exist in our user database” ▸ Dangerous because it narrows the attackers vector, instead of guessing a username and password they only need to crack the password
m’kay? ▸ Entropy is the real key measurement, passphrases are often better than passwords even random long passwords ▸ Example: ocean conduct people alpha 1972, that’s a strong example password and takes a lot longer to crack than a random 40 character password using CUDA or other GPU based attacks
to enumeration attacks and information leaking ▸ If there is a pause, even if it’s a short pause, after a username is found in the user db doing the hash to compare passwords, an attacker can use that to find all the valid usernames in a database. ▸ A good way around this is to create a blank user with a random password and compare that hash if the email passed in is not found.
header prevents javascript access to the cookies stored on the browser ▸ Setting this flag prevents session hijacking attacks via XSS and/or CSRF ▸ Most frameworks set this for you by default, LEAVE IT ON!
unescaped user input (Once again NEVER TRUST THE USER) ▸ Example: enter <script>alert(“broken website”)</script> during registration on the home page the site displays <h1>Welcome <%= current_user.first_name.html_safe %> and an alert saying broken website will be displayed. ▸ Escape your users input, all of it. Most frameworks help you with this.
and does not change the content of the response from the server but only on the client side ▸ Common types of issues relate to information that is planned to be hidden based on permission but are sent to the end user, this can be used to allow users to access data that is restricted.
allowing users having access to objects that they may not have access to. ▸ Common example: on the profile page of an app load the user based on the user id param passed in as opposed the currently logged in user
web server and firewalls surrounding the application, not much to say here because it’s dependent on the server software being used. ▸ Read up on best practices and follow them for your software, don’t allow directory listing, direct downloads of files via ftp, etc….
password leakage or against automated brute force attacks, passwords should be stored in a secure format. ▸ MD5 is not secure, a gpu can brute force an md5 quite quickly ▸ A one way hash is recommended not encryption. They are different encryption is reversible, hashing is not. Encryption is not recommended because if an attacker gets your keys they have the keys to the kingdom. Hashed passwords should be still secure if someone obtains them. ▸ bcrypt/scrypt with salts are recommended for hashing
your data will land in the hands of attackers ▸ If you would be upset if your personal information would be leaked then your users data SHOULD be encrypted while at rest in the db
an entire model and all of it’s attributes exposing sensitive data ▸ Example: a json api the serializes a user model returning password, ssn, email, date of birth, etc…
practice of hiding url links based on permissions but not checking permissions on the page themselves. This allows attackers to forge the restricted urls.
from another user ▸ Example: attacker steals a currently logged in user’s cookie and sends an order using that customer’s credit card. ▸ Best protection is a server side encrypted token that is generated with each request that the server can use to validate the request.
secure as your weakest link ▸ Libs and components have a published list of vulnerabilities, attackers watch these lists. So should you ▸ I recommend using a service like synk.io that will check your dependency files (Gemfile, requirements.txt, package.json etc…) ▸ You an practice assuming code habits for your code and if you don’t follow this simple step it can matter at all.
of redirecting a user based on a unvalidated param. ▸ This can easily expose restricted pages and/or admin access level pages. ▸ Example: redirect_to params[:url] ▸ Again NEVER TRUST THE USER ▸ Always check permissions for that currently logged in user
current employer where I’m a Full Stack Security Engineer ▸ Thanks to CashStar for sponsoring this meetup. ▸ [email protected] ▸ @jaegerpicker ▸ https://github.com/jaegerpicker ▸ https://github.com/OWASP/railsgoat/wiki/Rails-5-Tutorials