#Why this matters
Online banking portals, university gradebooks, and cloud dashboards run as web applications over TCP ports 80 and 443. Because they accept untrusted input directly from the public internet, web services are among the first targets attackers probe.
Building on TCP streams from the transport layer lesson, this lesson explains how HTTP requests, TLS 1.3, security headers, cookies, and OWASP Top 10 risks interact so you can spot misconfigurations before they lead to account takeover.
#HTTP request-response lifecycle and methods
HTTP is a stateless request-response protocol. A browser sends a request containing a method, path, headers, and optional body; the web server processes it, often queries a database such as PostgreSQL or MySQL, and returns a status code, headers, and body.
Common HTTP methods carry distinct security considerations:
| Method | Purpose | Security consideration |
|---|---|---|
GET |
Retrieve data | Parameters appear in URLs and logs; never place secrets in query strings |
POST |
Submit data in body | Moves data out of URLs, but remains cleartext without HTTPS |
PUT |
Update a resource | Needs strict server-side authorization to block unauthorized edits |
DELETE |
Remove a resource | Requires access control and CSRF protection |
OPTIONS |
Query allowed methods | Can disclose endpoints and CORS settings if overly permissive |
Responses begin with a three-digit status code: 200 (OK), 301 (Moved Permanently), 403 (Forbidden, server understood the request but refuses access), 404 (Not Found), and 500 (Internal Server Error, which can leak stack traces when debug mode is active).
#HTTPS, TLS 1.3, and security headers
Plain HTTP sends headers, form fields, and cookies in cleartext. HTTPS wraps HTTP in Transport Layer Security (TLS). SSLv3, TLS 1.0, and TLS 1.1 are deprecated; modern deployments use TLS 1.3, providing three guarantees:
- Encryption protects data in transit from eavesdropping.
- Authentication verifies via X.509 certificates that the server is genuine.
- Integrity detects any tampering with messages in transit.
TLS secures only the network channel; it never fixes backend SQL injection, broken access control, or weak password hashing.
- Headers, bodies, and cookies travel in cleartext
- No cryptographic proof of server identity
- Network attackers can alter responses
- Application data is encrypted in transit
- Server verified by digital certificate
- Integrity checks detect tampering
Servers also send HTTP security headers that restrict risky browser behavior. Inspect them with curl -I:
$ curl -I https://example.test/login
HTTP/2 200
content-type: text/html; charset=utf-8
strict-transport-security: max-age=31536000
content-security-policy: default-src 'self'; frame-ancestors 'none'
x-frame-options: DENY
x-content-type-options: nosniff
set-cookie: sess=9f8e7d6c; Path=/; HttpOnly; Secure; SameSite=StrictStrict-Transport-Security(HSTS): Forces browsers to use HTTPS.Content-Security-Policy(CSP): Restricts script and frame origins, reducing XSS impact.X-Frame-Options: DENY: Blocks framing to prevent clickjacking (complemented by CSPframe-ancestors 'none').X-Content-Type-Options: nosniff: Prevents MIME sniffing.
#Cookies, sessions, and OWASP Top 10 risks
After login, servers issue a session token via Set-Cookie. Weak session handling enables Session Hijacking (stealing cookies), Session Fixation (forcing a known session ID before login), and CSRF (forging cross-site requests from a logged-in browser).
Harden session cookies with four attributes:
HttpOnly: Blocks JavaScript (document.cookie) from reading the cookie, limiting XSS session theft.Secure: Sends the cookie only over HTTPS.SameSite=Strict(orLax): Restricts cross-site cookie transmission to defend against CSRF.ExpiresorMax-Age: Bounds session lifetime.
The OWASP Top 10 (2021) categorizes critical web flaws:
- A1 - Broken Access Control: Acting beyond permissions, such as user
101callingGET /api/users/123and receiving200 OKwith user123's profile (horizontal privilege escalation). - A2 - Cryptographic Failures: Weak or missing cryptography, such as hashing passwords with obsolete
MD5orSHA-1instead of Argon2id or bcrypt, or using plain HTTP. - A3 - Injection: Untrusted input executed as commands by SQL, OS, or LDAP (for example,
admin'--in an unparameterized query). - A4 - Insecure Design: Missing architectural controls such as rate limiting.
- A5 - Security Misconfiguration: Debug mode in production, default passwords, or unnecessary open endpoints.
- A6 - Vulnerable Components: Unpatched libraries or frameworks (for example, Log4Shell).
- A7 - Authentication Failures: Weak passwords, brute-force exposure, or unrotated session IDs.
- A8 - Software Integrity Failures: Unsigned updates or compromised CI/CD pipelines.
- A9 - Logging and Monitoring Failures: Missing alerts or audit trails for attacks.
- A10 - Server-Side Request Forgery (SSRF): Forcing the server to fetch internal addresses or cloud metadata (
http://169.254.169.254/latest/meta-data/).
#Defending against common web mistakes
Relying on POST alone or enabling HTTPS without server-side access checks leaves apps exposed. Combine transport encryption, security headers, hardened cookies, and parameterized queries on every endpoint.
#Summary
- HTTP is a stateless request-response protocol governed by methods (
GET,POST,PUT,DELETE,OPTIONS) and status codes (200,301,403,404,500). - HTTPS (TLS 1.3) provides encryption, server authentication, and integrity, while security headers (
HSTS,CSP,X-Frame-Options,X-Content-Type-Options) harden browser behavior. - Session cookies require
HttpOnly,Secure,SameSite, and a bounded lifetime against hijacking, XSS, and CSRF. - The OWASP Top 10 (2021) spans Broken Access Control (A1) through SSRF (A10), showing why TLS alone cannot fix application-layer bugs.