Use this when securing web applications against XSS, injection, CSRF, SSRF and session attacks.
Web Security
Web security protects web applications and their users from attacks such as XSS, SQL injection, CSRF and SSRF, using secure coding, HTTPS, secure cookies, security headers and strong authentication.
1. Web security: HTTPS, authentication, session management, input handling, access control, headers.
2. OWASP Top 10 as baseline.
3. Test with SAST/DAST.
4. Fix root causes.
5. WAF as an extra layer.
request → TLS → auth/session → validation → access control → response
Context & applicabilityCommon mistakes · platform/version boundaries
- Testing security only before launch, not continuously.
- Relying on a WAF instead of fixing the application.
- Front-end checks without server-side validation.
- Dependencies never updated (check with
npm audit,pip-audit,composer audit).
Operational reference
Fast context before you go deeper.
Verification & Troubleshooting
Start with the observed symptom, prove the nearest boundary, and move outward only when the current state is understood.
Use the operational verification above to establish the expected state.
Capture the concrete output, symptom, packet, log or counter before changing anything.
Step 1 Testing tools Verify boundary
| Tool | Use |
|---|---|
| OWASP ZAP | Proxy and automated scanning |
| Burp Suite | Manual testing proxy |
| securityheaders.com / Mozilla Observatory | Header checks |
| SSL Labs | TLS configuration grade |
| Semgrep, CodeQL | Static analysis in CI |
Evidence · 1 on this Topic
Expected observations and documentation recipes are reference material. Record actual output, device identity, scope and time before claiming a verified result.
Subtopics
Go one level deeper into this subject.
HTTP security covers protecting web traffic and responses: HTTPS everywhere, security headers, secure cookies, correct methods and status codes, and limiting what error pages reveal.
Subtopic HTTPSHTTPS is HTTP over TLS, encrypting and authenticating web traffic with a certificate for the site's domain.
Subtopic AuthenticationWeb authentication verifies users with passwords plus MFA, passkeys or SSO, with rate limiting, secure password storage, generic error messages and protection against credential stuffing.
Subtopic Session SecuritySession security protects the link between a user and their login: random, long session IDs, regenerated at login, sent only in secure cookies, with idle and absolute timeouts and server-side logout.
Subtopic CookiesCookies store session and state data in the browser. Mark session cookies Secure, HttpOnly and SameSite, scope them to the right domain and path, and give them sensible lifetimes.
Subtopic SameSiteSameSite is a cookie attribute that controls cross-site sending: Strict, Lax (the browser default) or None, which requires Secure.
Subtopic CORSCORS (Cross-Origin Resource Sharing) uses response headers like Access-Control-Allow-Origin to let browsers allow specific other origins to read responses.
Subtopic CSRFCSRF (cross-site request forgery) makes a logged-in user's browser send unwanted requests to a site.
Subtopic XSSXSS (cross-site scripting) injects malicious script into pages viewed by other users, stealing sessions or acting as them.
Subtopic SQL InjectionSQL injection inserts SQL through user input to read, change or delete database data.
Subtopic Command InjectionCommand injection happens when user input reaches an operating system shell, letting attackers run commands.
Subtopic Path TraversalPath traversal uses sequences like ./ in file names to read or write files outside the intended folder.
Subtopic SSRFSSRF (server-side request forgery) tricks a web server into making requests to internal services or cloud metadata, such as 169.254.169.254.
Subtopic Insecure DeserializationInsecure deserialization turns untrusted serialized data back into objects in a way that lets attackers run code or change logic.
Subtopic Security HeadersSecurity headers instruct browsers to apply protections: Content-Security-Policy, Strict-Transport-Security, X-Content-Type-Options: nosniff, Referrer-Policy, Permissions-Policy and frame-ancestors or X-Frame-Options.
Subtopic Content Security PolicyContent Security Policy (CSP) is a response header that restricts where scripts, styles, images and frames may load from, such as script-src 'self', which greatly limits the impact of XSS.
Subtopic HSTSHSTS (HTTP Strict Transport Security) tells browsers to always use HTTPS for a domain for a set time, such as max-age=31536000; includeSubDomains, preventing SSL stripping attacks.
Subtopic Web Security TroubleshootingTroubleshoot web security by inspecting response headers and cookies in browser developer tools, reading CSP violation reports, testing with a proxy like Burp or ZAP, and checking server and WAF logs.
- Validate input; encode output.
- Authorization must be checked server-side on every request.
- Security headers reduce impact of bugs.
curl -sI https://<site>— headers- DAST scan (OWASP ZAP) — findings
- SAST/dependency scan — code issues
ReferenceWhy it matters1 section · depth on demand
What this area covers
| Topic | Answers |
|---|---|
| HTTPS, HSTS, security headers, CSP | Transport and browser protections |
| Authentication, sessions, cookies, SameSite | Keeping logins safe |
| CORS, CSRF | Cross-origin rules |
| XSS, SQL/command injection, path traversal, deserialization, SSRF | Input-handling flaws |
Use the OWASP ASVS as a checklist and test with OWASP ZAP or Burp Suite.
ReferenceImportant terms & boundaries1 section · depth on demand
In depth
Web security protects web applications and their users from attacks such as injection, cross-site scripting, request forgery and session hijacking. Web apps are exposed to the internet and handle authentication and data, making them one of the most attacked surfaces.
Defences work at several layers:
| Layer | Controls |
|---|---|
| Transport | HTTPS everywhere, HSTS |
| Application code | Input validation, output encoding, parameterised queries |
| Browser policies | Content Security Policy, SameSite cookies |
| Sessions | Secure cookie flags, timeouts, rotation |
| Perimeter | WAF, rate limiting, bot protection |
| Process | Secure development, code review, testing |
The topics in this group explain each major vulnerability class and the specific controls that prevent it.
Additional reference context Scope · expected state · examples · history · terminology Open only when you need the supporting context
Verification history & basis
When and against what this Topic was checked. Later text edits do not count as a new check.
Authoritative/upstream documentation reviewed for bounded claims in Web Security. Documentation verification only; this is not observed lab or production Evidence.
Basis: https://owasp.org/www-project-application-security-verification-standard/ · confidence 94%