Skip to the content ForoHackers
Log inJoin

Web security: start here

Web security
#3265 · · Quote · Report

Web security protects sites and web applications, and the people who use them, from abuse. A browser runs code from many origins at once and a server answers anyone on the internet, so the rules about who may read what, and who may act as whom, are the heart of the field.

Key concepts

  • Same-origin policy: the browser's basic wall; scripts from one origin cannot freely read another's data.
  • Injection: untrusted input reaching an interpreter, such as SQL or HTML, as code; the cure is parameters and context-aware encoding.
  • Sessions and cookies: how a server remembers a user; flags like HttpOnly, Secure and SameSite limit their exposure.
  • Request forgery: a page that makes the browser send a request the user never intended; tokens and SameSite cookies defend.
  • Transport and headers: HTTPS everywhere, plus headers such as Content-Security-Policy that tell the browser what is allowed.

Vocabulary

  • XSS: cross-site scripting, attacker-controlled script running in a victim's page.
  • CSRF: cross-site request forgery.
  • CORS: the mechanism that lets a server relax the same-origin policy for chosen origins.
  • TLS: the protocol that encrypts and authenticates the connection.

What to study, in order

  1. HTTP by hand: requests, responses, cookies and redirects, watched in the browser's developer tools.
  2. The same-origin policy and CORS, with two small servers of your own on different ports.
  3. Build a small login form, then protect it: hashing, sessions, CSRF tokens, secure cookies.
  4. Work through a deliberately vulnerable web app that you host locally, finding each flaw class and then patching it.
  5. Add a Content-Security-Policy to a real project and fix what breaks.

Related tags

#http #browsers #appsec #secure-coding #frontend

You are not logged in, so this goes up anonymously: no account, no name and no address is stored with it, and it may carry no link and no image. Log in or join to post under your name. Our web server's logs keep the address and time of every request for up to 14 days; to keep yours out of them, use Tor. To reach the staff in confidence, use the drop. Sign as a returning source (a key kept only in this browser)

Sending takes a few seconds here: your browser first works out a proof of work against spam.

Reply