HTTP Basics: Status Codes, Headers and What They Reveal About a Website
Open a website and it feels instant: click, page appears. Underneath, your browser and the server just had a fast, structured conversation in a language called HTTP. Learning to read that conversation is the first real skill of web security — and it is easier than it sounds.
Requests and Responses
Every web interaction is a request followed by a response. Your browser sends a request: “GET me this page,” plus headers (extra metadata) like what browser you use and what formats you accept. The server replies with a status code, its own headers, and the page content.
You can watch this live: open your browser’s developer tools (F12), go to the Network tab, and reload any page. Every line is one HTTP exchange.
Status Codes: The Server’s Short Answers
Status codes are three-digit numbers grouped by their first digit:
- 2xx — Success. 200 OK means “here is what you asked for.” 204 means success with no content to return.
- 3xx — Redirection. 301 means “this page moved permanently,” 302 means “moved temporarily.” Attackers abuse open redirects here — a link that looks safe but bounces you to a malicious site.
- 4xx — Client errors. 404 Not Found, 403 Forbidden, 401 Unauthorized. A 403 on an admin page tells you the page exists but you are not allowed in — useful information for both defenders and attackers.
- 5xx — Server errors. 500 means the server broke while handling your request. Repeated 500s during testing can hint at injection points worth investigating — on systems you own or have permission to test.
Headers: The Metadata That Matters
Headers carry the security story of a site. A few to know:
- Server / X-Powered-By: Reveals the server software and version. Good for attackers building a target profile; good reason for defenders to hide or minimize these headers.
- Set-Cookie: How sessions work. If a cookie lacks the HttpOnly flag, JavaScript can read it — which is exactly what cross-site scripting attacks exploit. If it lacks Secure, it can travel over plain HTTP.
- Content-Security-Policy (CSP): Tells the browser which sources of scripts and content are allowed. A strong CSP is one of the best defenses against XSS.
- Strict-Transport-Security (HSTS): Forces the browser to use HTTPS only, blocking downgrade attacks.
- X-Frame-Options / frame-ancestors: Stops your site being embedded in an attacker’s iframe (clickjacking defense).
Try It Yourself (On Your Own Sites)
Pick a site you own or a practice lab and check its headers two ways:
- Browser dev tools: F12 → Network tab → click any request → Headers section.
- Command line: curl -I https://example.com shows just the response headers.
Ask yourself: does it send a CSP? HSTS? Are cookies flagged HttpOnly and Secure? Is the Server header leaking version details? We built a Python security headers checker in an earlier post — run it against your own site and fix what it flags.
Why This Matters for Security
Most web attacks start with reading, not breaking. Before testing anything, a security professional maps the target: what software it runs, what headers it sends, which pages return 403 versus 404, where redirects go. All of that comes from HTTP basics. Learn to read the conversation first — the attacks make sense afterwards.
And remember the golden rule that applies to everything on this blog: only test systems you own or have written permission to test.



Comments
Post a Comment