# Web Security Reference > Source: ## Overview Web security focuses on protecting sensitive information (customer data, passwords, banking info, internal algorithms) from unauthorized access that could lead to competitive disadvantage, service disruption, or customer privacy violations. ## Security vs. Privacy - **Security**: Protecting private data and systems against unauthorized access (internal and external data). - **Privacy**: Giving users control over data collection, storage, and usage with transparency and consent. ## Security Features Provided by Browsers ### Same-Origin Policy (SOP) and CORS - **Same-Origin Policy**: Restricts documents or scripts from one origin interacting with resources from another origin. - **CORS** (Cross-Origin Resource Sharing): An HTTP-header mechanism allowing servers to permit cross-origin resource requests when needed. ### HTTP Communication Security - **HTTPS/TLS**: Encrypts data during transport, preventing third-party interception. - **Certificate Transparency (CT)**: An open framework protecting against certificate misissuance through public logging. ### Secure Contexts and Feature Permissions Browsers restrict "powerful features" (notifications, webcam, GPU, payments) to: - Secure contexts (HTTPS/TLS delivery via `window` or `worker`). - Explicit user permission via the Permissions API. - User activation (transient activation -- requires user action like clicking). ## High-Level Security Considerations ### 1. Store Client-Side Data Responsibly - Limit third-party cookie usage. - Prepare for removal of cross-site cookies. - Implement alternative persistence methods. ### 2. Protect User Identity and Manage Logins - Use reputable frameworks with built-in security. - Implement **Multi-Factor Authentication (MFA)**. - Use dedicated APIs: - Web Authentication API - Federated Credential Management (FedCM) API **Login Security Tips:** - Enforce strong passwords. - Educate users about **phishing** attacks. - Implement **rate limiting** on login pages. - Use **CAPTCHA** challenges. - Manage sessions with unique session IDs. - Auto-logout after inactivity. ### 3. Do Not Include Sensitive Data in URL Query Strings - Avoid GET requests with sensitive data (can be intercepted via the Referer header). - Use POST requests instead. - Protects against CSRF and replay attacks. ### 4. Enforce Usage Policies - **Content Security Policy (CSP)**: Controls where images and scripts can be loaded from; mitigates XSS and data injection attacks. - **Permissions Policy**: Blocks access to specific "powerful features." ### 5. Maintain Data Integrity - **Subresource Integrity (SRI)**: Crypto hash verification for fetched resources (from CDNs). - **MIME Type Verification**: Use the `X-Content-Type-Options` header to prevent MIME sniffing. - **Access-Control-Allow-Origin**: Manage cross-origin resource sharing. ### 6. Sanitize Form Input - **Client-side validation**: Provide instant feedback using HTML form validation. - **Output encoding**: Safely display user input without executing it as code. - **Server-side validation**: Essential; client-side is easily bypassed. - **Escape special characters**: Prevent executable code injection (SQL injection, JavaScript execution). ### 7. Protect Against Clickjacking - **X-Frame-Options**: HTTP header preventing page rendering in ``, `