Web Application Security

OWASP

  • Top Ten (opens in a new tab)

    1. Injection
    2. Broken Authentication
    3. Sensitive Data Exposure
    4. XML External Entities (XXE)
    5. Broken Access Control
    6. Security Misconfiguration
    7. Cross-Site Scripting (XSS)
    8. Insecure Deserialization
    9. Using Components with Known Vulnerabilities
    10. Insufficient Logging & Monitoring

Cross-Site Scripting (XSS)

CSRF

SSRF

Session Management

URL Rewriting

  • Pros

    • Always work regardless of cookies settings
  • Cons

    • not secure, as session ID is exposed in URL
    • Only works for textual information

Cookies

Java

HTTP Authentication

HTTP Basic

  • A request contains a header field in the form of Authorization: Basic <credentials>, where credentials is the Base64 encoding of ID and password joined by a single colon :

    1. Get encoded credentials

      CREDENTIALS=$(echo -n <ID>:<Password> | base64)

    2. Include in HTTP request with Authorization header:

      Authorization: Basic ${CREDENTIALS}

HTTP Digest Authentication

  • Similar to HTTP Basic, but use MD5 instead of Base64.

Web

Permissions API

Content Security Policy (CSP)

HTTP Strict Transport Security (HSTS)

HTTP Public Key Pinning (HPKP), Deprecated

  • Key points

    • Deprecated, with all major browsers support removed due to complex implementation
    • Declare that a website's HTTPS certificate should only be treated as valid if the public key is contained in a list specified over HTTP to prevent MITM attacks that use valid CA-issued certificates.
    • Prevents Man-in-the-Middle attacks by ensuring the browser only accepts a specific certificate for a domain
    • Ensure trust on the first interaction

X-Frame-Options

  • Key points

    • Replaced by Content-Security-Policy Level 2 frame-ancestors directive

Feature Policy

  • Key points

    • Defines a mechanism that allows developers to selectively enable and disable use of various browser features and APIs.
    • Replaced by Permissions Policy and Document Policy

Referrer Policy

  • Key points

    • Control the referrer header sent by the browser to the server

      • no-referrer - No referrer information is sent
      • no-referrer-when-downgrade - The referrer is sent only when the protocol security level stays the same (HTTP -> HTTP, HTTPS -> HTTPS)
      • same-origin - The referrer is sent only when the referring page is from the same origin as the request
      • origin - The referrer is sent only when the referring page is from the same origin as the request, without its path
      • strict-origin - The referrer is sent only when the referring page is from the same origin as the request, without its query string
      • origin-when-cross-origin - The referrer is sent only when the referring page is from the same origin as the request, without its path, but sent in full when the referring page is from a different origin
      • strict-origin-when-cross-origin - The referrer is sent only when the referring page is from the same origin as the request, without its query string, but sent in full when the referring page is from a different origin
      • unsafe-url - The referrer is sent in full
  • Resources

Web - Tools