Secure Coding

Alicia Sykes
The defender must be right every time.
The attacker only needs to be right once.
Source: cybermap.kaspersky.com

Threat Modelling

Common Attacks

Injection

String query = "SELECT \* FROM accounts WHERE custID='" + request.getParameter("id") + "'";
thing

Insecure Design

Broken Access Control

CORS

(I'm sorry)

So how does CORS help us secure our site?

Access Control Design Principles

  1. Design Access Control Thoroughly Up Front
  2. Force All Requests to Go Through Access Control Checks
  3. Deny by Default
  4. Principle of Least Privilege
  5. Don't Hardcode Roles
  6. Log All Access Control Events

Cryptographic Failures

Failure to handle data properly and securely leads to sensitive data being exposed. The selling of this data has grown to a multi-billion dollar industry, with the effects of the breached companies and their clients being very significant.

As developers, we need to take a step back, and think about what data we're storing, how it's stored, accessed, transmitted and updated.

  1. Don't store sensitive data that isn't 100% necessary
  2. Encrypt all sensitive data both at rest, and in transit
  3. Ensure up-to-date and strong standard algorithms, protocols, and keys are in place; use proper key management
  4. Apply the correct access controls, as per the datas clasification
  5. Disable caching for response that contain sensitive data
  6. Always use authenticated encryption instead of just encryption.

Security Misconfiguration

Vulnerable and Outdated Components

Components typically run with the same privileges as the application itself, so flaws in any component can result in serious impact. Such flaws can be accidental (e.g., coding error) or intentional (e.g., a backdoor in a component).
NPM Security Best Practices

Identification and Authentication Failures

Software and Data Integrity Failures

Logging & Monitoring Failures

Server Side Request Forgery