← All lessons Stage 0 · Lesson 8
15 min

Client-side vs server-side (and why it matters)

Stage 0 · Lesson 8 · 15 minutes · Requires Lessons 1–7


The one-line answer

The client is the attacker's computer. Anything that happens there can be changed. Only the server can enforce anything.


Why you should care

This is the single most important idea in Stage 0.

It explains why hidden fields don't hide, why disabled buttons don't disable, why JavaScript validation doesn't validate, and why "you can't do that in the UI" is never a defence.

Once this clicks, half of web security becomes obvious. Every bug class in Stage 3 — IDOR, broken authentication, mass assignment, price manipulation — is a variation of a developer forgetting this lesson.


How it actually works

Every web application is split across two places.

Client-side — runs in the user's browser:

  • HTML, CSS, JavaScript
  • Anything in localStorage or a readable cookie
  • Form validation written in JavaScript
  • Which buttons and menus are displayed

Server-side — runs on the company's machine:

  • Business logic
  • Database queries
  • Authentication and authorisation
  • Price calculation, permission checks, data access

The critical distinction: you control the client completely. You control nothing on the server.

The server's only view of you is the HTTP requests that arrive. It cannot tell whether a request came from a browser, a script, curl, or a proxy. It cannot verify that its JavaScript ran. It receives text and must decide what to do with it.

The trust boundary

Draw a line between the two. Everything on your side of that line is untrusted input, no matter how it looks.

That includes:

  • Form fields — visible, hidden, disabled, all of them
  • URL parameters and paths
  • Cookies and tokens
  • HTTP headers — User-Agent, Referer, X-Forwarded-For
  • The request method
  • JSON bodies
  • File uploads and their declared types

If it arrived in a request, a user could have written it by hand.

Three worked examples

Example 1 — the price

<input type="hidden" name="price" value="4999">

The developer's reasoning: the user never sees this field, so they can't change it.

Reality: it's in the page source. Change it in devtools, or replay the request with curl using price=1.

Secure version: the client sends only product_id=88. The server looks up the price in its own database. The client never gets to state the price at all.

Example 2 — the admin menu

if (user.role === 'admin') {
  showAdminPanel();
}

The developer's reasoning: non-admins don't see the button, so they can't reach the admin area.

Reality: the button controls display, not access. Anyone can request /admin/users directly. If the server doesn't check the role on that endpoint, they're in.

Secure version: the server checks the role on every admin request. Hiding the button is a UI nicety, not a control.

Example 3 — form validation

if (email.includes('@')) {
  form.submit();
}

The developer's reasoning: invalid emails can't be submitted.

Reality: disable JavaScript, or send the request directly. No validation runs.

Secure version: validate in the browser for a good user experience, and validate again on the server for security. Client-side validation is a convenience; server-side validation is the actual check.

The rule that follows

Never trust the client.

It's the most repeated phrase in web security because it's the most frequently ignored one. Every input must be validated, sanitised and authorised on the server, every time, regardless of what the front end already checked.

The corollary: nothing in the browser is secret

If the browser received it, the user has it. That means:

  • API keys in JavaScript are public
  • "Encrypted" values decoded by client-side JS are decodable by anyone
  • Feature flags in the front end reveal unreleased functionality
  • Source maps expose original code
  • Anything in localStorage is readable

There is no way to ship a secret to a browser and keep it secret. If a design requires that, the design is wrong.


See it yourself

1. Disable JavaScript entirely. In Chrome: F12 → Ctrl+Shift+P → type "Disable JavaScript" → Enter. Reload a site with a validated form. Watch client-side checks disappear. (Re-enable it afterwards.)

2. Re-enable a disabled button. Find a greyed-out button, inspect it, and delete the disabled attribute in Elements. It becomes clickable. Now ask the important question: does the server accept the resulting request? That's the real test.

3. Replay a request without a browser. Take any request from the Network tab, Copy as cURL, and run it in a terminal. The server responded — and no HTML, CSS or JavaScript was involved. That's what the server actually sees.

4. Read what the client knows. Console → localStorage. Look at what applications have stored on your machine. Tokens, user IDs, sometimes far more.

Boundary: all of the above is inspecting your own browser and your own session. Submitting manipulated requests to systems you don't own — to change prices, access other accounts, or reach admin functions — is unauthorised access and a criminal offence in India under the IT Act. Practise on our labs. Lesson 9 next.


How attackers abuse this

Price manipulation. Change a client-supplied price or quantity. Negative quantities are a classic — some systems credit the account.

Forced browsing. Request /admin, /dashboard, /api/v1/users directly, without any link pointing there. If authorisation is only enforced in the UI, access is granted.

Mass assignment. A profile update form sends name and email. The attacker adds "role": "admin" to the JSON body. If the server blindly maps request fields onto the user object, privileges are escalated. You'll do this properly in Stage 4.

Parameter pollution and type confusion. Sending id=1&id=2, or an array where a string was expected, produces unpredictable server behaviour. Some frameworks take the first value, some the last, some crash informatively.

Header spoofing. X-Forwarded-For: 127.0.0.1 to bypass IP restrictions. Referer spoofing to defeat weak CSRF checks. Both are trivially set by any client.

Skipping steps in a flow. A three-step checkout enforced only by the UI. Request step three directly and payment verification never happens. This class of bug — business logic flaws — is invisible to automated scanners and is where thoughtful testers find high-severity issues.


Common mistakes

"It's server-side because it's in a POST body." The method makes no difference. POST bodies are as editable as URL parameters. Both come from the client.

"HTTPS means the data wasn't tampered with." HTTPS prevents tampering in transit by third parties. It does nothing about the user themselves, who is one endpoint of that encrypted connection and can send whatever they like inside it.

"Our mobile app doesn't allow that." The app is also a client. Anyone can intercept its traffic with a proxy and modify the requests. Mobile apps are frequently less protected because developers assume the app is the only way in.

"Obfuscated JavaScript protects our logic." It slows someone down by minutes. Obfuscation is not a security control.


Check yourself

  1. A site hides the "Delete User" button for non-admins. Is that sufficient? Explain in one sentence.
  2. A developer says input is safe because the mobile app validates it before sending. What's wrong?
  3. An app stores isPremium: true in localStorage and unlocks features based on it. What's the flaw, and what's the fix?
Answers
  1. No — hiding the button only affects what's displayed; the server must independently verify the user's role when the delete request arrives, because anyone can send that request directly.
  2. The mobile app is a client, and clients can be bypassed. Traffic can be intercepted and modified with a proxy, or requests crafted from scratch against the API. Validation must happen on the server.
  3. localStorage is fully editable by the user — anyone can set isPremium to true and unlock paid features. The fix is for the server to determine entitlement from its own records on every request, and never accept a client's claim about its own privileges.

Your lab

Challenge 05 — What's in the page source?

Apply both lessons together: read what the client received, then work out what the server actually enforces.

→ Open Stage 0 labs


Summary in your language

தமிழ் சுருக்கம் (Tamil summary)

Client-side vs Server-side — Stage 0-ன் மிக முக்கியமான பாடம்

ஒவ்வொரு website-ம் இரண்டு இடங்களில் இயங்குகிறது:

Client-side — உங்கள் browser-ல்

  • HTML, CSS, JavaScript
  • cookies, localStorage
  • JavaScript validation
  • எந்த button தெரிய வேண்டும் என்பது

Server-side — நிறுவனத்தின் கணினியில்

  • விலை கணக்கீடு
  • அனுமதி சரிபார்ப்பு (permission check)
  • database

முக்கியமான உண்மை:

Client உங்கள் கட்டுப்பாட்டில் உள்ளது. அதில் உள்ள எதையும் நீங்கள் மாற்றலாம்.

Server-க்கு தெரிவது request மட்டும் தான். அது browser-ல் இருந்து வந்ததா, curl-ல் இருந்து வந்ததா என்று அதனால் கண்டுபிடிக்க முடியாது.

மூன்று உதாரணங்கள்:

  1. மறைக்கப்பட்ட விலை — <input type="hidden" value="4999"> — இதை 1 என்று மாற்ற முடியும். Server தன் database-ல் இருந்து விலையைப் பார்க்க வேண்டும்.
  1. Admin button-ஐ மறைப்பது — button தெரியவில்லை என்றாலும், /admin URL-ஐ நேரடியாக அணுக முடியும். Server ஒவ்வொரு முறையும் role-ஐ சரிபார்க்க வேண்டும்.
  1. JavaScript validation — JavaScript-ஐ off செய்தால் அந்த சரிபார்ப்பு நடக்காது. Server-லும் சரிபார்க்க வேண்டும்.

தங்க விதி: Client-ஐ ஒருபோதும் நம்பாதே.

browser-க்கு அனுப்பப்பட்ட எதுவும் ரகசியம் அல்ல. JavaScript-ல் உள்ள API key-கள் அனைவருக்கும் தெரியும்.

हिंदी सारांश (Hindi summary)

Client-side vs Server-side — Stage 0 का सबसे ज़रूरी सबक़

हर website दो जगह चलती है:

Client-side — आपके browser में

  • HTML, CSS, JavaScript
  • cookies, localStorage
  • JavaScript validation
  • कौन सा button दिखेगा

Server-side — कंपनी के कंप्यूटर पर

  • क़ीमत की गणना
  • अनुमति की जाँच (permission check)
  • database

सबसे ज़रूरी सच्चाई:

Client आपके नियंत्रण में है। वहाँ की हर चीज़ आप बदल सकते हैं।

Server को सिर्फ़ request दिखती है। वह यह नहीं जान सकता कि request browser से आई या curl से।

तीन उदाहरण:

  1. छिपी हुई क़ीमत — <input type="hidden" value="4999"> को 1 कर सकते हैं। Server को अपने database से क़ीमत लेनी चाहिए।
  1. Admin button छिपाना — button न दिखे तब भी /admin URL सीधे खोला जा सकता है। Server को हर बार role जाँचना चाहिए।
  1. JavaScript validation — JavaScript बंद कर दें तो जाँच होती ही नहीं। Server पर भी जाँच ज़रूरी है।

सुनहरा नियम: Client पर कभी भरोसा मत करो।

जो browser को भेज दिया गया, वह गुप्त नहीं रहा। JavaScript में रखी API key सबको दिखती है।

याद रखें: Mobile app भी एक client है — उसकी traffic भी बदली जा सकती है।

Want this summary in Malayalam, Telugu, Kannada or another language? Tell us — the most requested languages get added next.


What's next

You now know how to look, and you know why applications break. Before you point any of this at anything real, you need to know exactly where the legal line is — because in India, crossing it is a criminal matter, not a grey area.

→ Lesson 9: Legal, ethics and permission