01 / 20

Client-Server
Trust Boundaries

Understand where client responsibilities end and server responsibilities begin: the invisible lines that determine how secure your application really is.

Cyber Security

What Is Client-Server Architecture?

Every time you open a website or use an app, two systems are talking to each other. The client is the software on your device: your browser, your phone app, or your game launcher. The server is a remote computer that stores data, runs business logic, and sends responses back.

CLIENT Browser / App User's Device SERVER Backend Logic Remote Machine Request Response

What Is a Trust Boundary?

A trust boundary is the conceptual line between components that operate at different levels of trust. Anything on the client side is controlled by the user and therefore untrusted by the server. Anything on the server side is under the developer's control and treated as trusted.

UNTRUSTED ZONE User's Browser JavaScript / HTML TRUST BOUNDARY TRUSTED ZONE Server Logic Database

Why Trust Boundaries Matter

If the server trusts data that arrives from the client without verifying it, an attacker can manipulate that data to bypass security controls, steal information, or damage the system.

✕ Trusting Client Input
An attacker changes a hidden form field from "price=9.99" to "price=0.01" before submitting.
✓ Validating on Server
The server looks up the real price in its own database and ignores the client-supplied value entirely.

Client Responsibilities

1
Render the user interface: display pages, forms, buttons, and feedback to the user.
2
Collect user input: gather form data, clicks, and interactions before sending to the server.
3
Provide UX validation: show instant feedback (e.g., "password too short") for a smoother experience: this is a convenience, not a security control.
4
Handle presentation logic: animations, themes, local caching, and offline views.

Server Responsibilities

1
Authenticate users: verify identity through credentials, tokens, or certificates.
2
Authorize actions: check that the authenticated user has permission for the requested operation.
3
Validate all input: reject malformed, out-of-range, or malicious data regardless of what the client already checked.
4
Enforce business rules: pricing, rate limits, access controls, and data integrity live here.
5
Store and protect data: encrypt sensitive data, manage the database, and generate audit logs.

The Golden Rule of Trust Boundaries

ALL DATA FROM THE CLIENT must be treated as potentially MALICIOUS

This is the single most important concept in application security. No matter how well-designed your client-side code is, an attacker controls the client environment. The server is the last line of defense.

Client vs Server: Key Distinction

Client Server
Controlled by User / Attacker Developer
Code visibility Fully visible (View Source) Hidden from end users
Validation role UX convenience only Security enforcement
Data storage Cookies, localStorage (exposed) Database, encrypted stores
Can be modified? Yes, always No, by external users

Data Flow Across the Boundary

User Input Client-Side Validation CLIENT TRUST BOUNDARY HTTP Request SERVER Server-Side Validation Authorization Database

How to Apply Trust Boundaries

1
Identify every input source: forms, URL parameters, cookies, HTTP headers, and API payloads.
2
Classify trust level: mark each source as untrusted (client) or trusted (server-generated).
3
Validate on the server: check type, length, range, and format. Reject anything that fails.
4
Sanitize before use: escape or encode data before inserting it into HTML, SQL, or shell commands.
5
Authorize the action: verify the user has the correct permissions for what they're requesting.

Example 1: Login Form

CLIENT username: admin password: ******** JS: "Fields not empty" UX check only POST SERVER Validate input format Hash + compare password Check account lockout Issue session token

Example 2: Price Manipulation

An online store displays a product at $49.99. The checkout form includes a hidden field: <input type="hidden" name="price" value="49.99">. What happens if the server uses this client-supplied price?

✕ Insecure Approach
Server reads price from the form submission and charges the user that amount. Attacker changes value to "0.01" using browser dev tools.
✓ Secure Approach
Server looks up the product by ID in its database, retrieves the real price, and charges that amount. Client-sent price is ignored.

Example 3: Authorization Bypass

A web app hides the "Admin Panel" link from regular users using client-side JavaScript. An attacker discovers the URL /admin/dashboard by reading the JavaScript source code.

Attacker Regular User GET /admin Server 200 OK Admin data No auth check 403 Forbidden Access denied Auth check passes

Example 4: Cross-Site Scripting (XSS)

An attacker submits a comment containing malicious code: <script>steal(cookies)</script>. If the server stores and displays this without sanitizing it, the script runs in other users' browsers.

Attack Vector
The trust boundary is crossed when the server accepts client input and echoes it back to other clients without encoding.
Defense
The server must sanitize output: encode special characters like < and > into their HTML entities before rendering.

Common Mistakes

✕ Client-Only Validation
Relying on JavaScript to enforce rules like "age must be over 18" without checking on the server. Attackers disable JS easily.
✕ Security by Obscurity
Hiding admin URLs or API endpoints in client code instead of enforcing proper server-side authentication and authorization.
✕ Trusting Hidden Fields
Using hidden form fields for sensitive data like user IDs, roles, or prices. These are trivially editable by anyone with dev tools.

Summary: Where Does Each Responsibility Live?

Responsibility Client Server
Input validation UX convenience Security enforcement
Authentication Collects credentials Verifies identity
Authorization Hides UI elements Checks permissions
Data storage Temporary cache Encrypted database
Business logic Display logic only Pricing, rules, limits
Output encoding Cannot self-protect Sanitizes before rendering

Question 1 of 5

A web application validates that an email address is properly formatted using JavaScript in the browser. Which statement is most accurate?

Question 2 of 5

An online store sends the product price in a hidden HTML form field. The server uses this value to charge the customer. What is the vulnerability?

Question 3 of 5

A developer hides the "Delete User" button from non-admin users by setting display: none in CSS. An attacker sends a direct HTTP request to the delete endpoint. What should the developer have done?

Question 4 of 5

Which of the following best describes a trust boundary in a client-server application?

Question 5 of 5

A user submits a comment containing <script>alert('hacked')</script>. The server stores it and displays it on the page without modification. This is an example of: