Client-Server
Trust Boundaries
Understand where client responsibilities end and server responsibilities begin: the invisible lines that determine how secure your application really is.
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.
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.
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.
Client Responsibilities
Server Responsibilities
The Golden Rule of Trust Boundaries
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
How to Apply Trust Boundaries
Example 1: Login Form
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?
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.
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.
Common Mistakes
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: