Cyber Security
Frontend
Frontend
Frontend = everything the user sees and uses, communicating with the backend (server & database) behind the scenes.
It may be:
Desktop Frontend
The graphical user interface (GUI) of applications installed on desktop operating systems (Windows, macOS, Linux). Built with frameworks like Electron, WPF, JavaFX, .NET MAUI.
Web Frontend
The client-side interface of web applications accessed via browsers. Uses HTML, CSS, JavaScript (and frameworks like React, Angular, Vue). Runs cross-platform without installation.
Mobile Frontend
The user-facing part of apps on smartphones/tablets (iOS, Android). Built natively (Swift, Kotlin) or cross-platform (Flutter, React Native). Optimized for touch, small screens, and mobility.
Smart TV Frontend
The interface of applications on Smart TVs (Samsung Tizen, LG webOS, Android TV, Roku). Focuses on large-screen UX, remote-control navigation, and streaming services.
Kiosk Machine Frontend
Touchscreen interfaces for public/retail self-service machines (ATMs, ticketing, ordering systems). Designed for simplicity, accessibility, and durability, often running in locked-down environments.
Cross-Site Scripting (XSS)
Escape user input; use Content Security Policy (CSP)
element.textContent = userInput;
Cross-Site Request Forgery (CSRF)
Use SameSite cookies, CSRF tokens
Set-Cookie: token=abc; SameSite=Strict
Clickjacking
Use X-Frame-Options or CSP frame-ancestors
X-Frame-Options: DENY
[ X-Frame-Options - X-Content-Type-Options - X-XSS-Protection - Content-Security-Policy ]
Insecure Data Storage
Avoid localStorage/sessionStorage for sensitive data
Use HTTP-only cookies
Sensitive Data Exposure
Use HTTPS, encrypt data
fetch('https://example.com')
DOM-based XSS
Sanitize dynamic DOM manipulation
Use DOMPurify
Disable autocomplete on sensitive fields
Insecure Redirects
Validate redirect URLs
Check with the whitelist before redirecting
Information Leakage via Comments
Remove comments before production
<!-- remove before release -->
Source Code Exposure
Use obfuscation and minification
UglifyJS or Terser
Hardcoded Secrets
Store in secure backend, not frontend
Use environment variables server-side
DDoS
Validate file uploads: type, size, content
Apply DomPurify on the HTML content, as it protect from user code injection
Use innerText not innerHTML when possible
Authentication hardening:
Authentication levels:
What you know(User name and password): Simple
What you have(Access card): Med
What you are(Face detection/finger print (Called biometric): Hard
MFA: using multiple options to make sure of who is performing the action
CAPTCHA: using it to make sure of what performing the action, human or machine.
Obfuscation
Obfuscation is the process of deliberately making code, data, or communication harder to understand, while keeping functionality intact.
Goal: Prevent reverse engineering, intellectual property theft, and exploitation by attackers.
Techniques:
Code renaming & control-flow flattening
String/data encryption
Dead-code insertion
Binary packing
Use Cases: Protect source code (Java, JavaScript, .NET), secure APIs, hide algorithms in proprietary software, and harden malware (dual-use).
CSP:
Definition: CSP is a web security standard (W3C) that controls which resources (scripts, styles, images, etc.) a browser is allowed to load and execute.
Goal: Mitigate Cross-Site Scripting (XSS), data injection, and clickjacking attacks by restricting untrusted content sources.
Use Cases:
Allow scripts only from trusted CDNs
Block inline/eval JavaScript
Prevent loading of mixed (HTTP) content
Control if site can be embedded in iframes
Sample for strong CSP:
Content-Security-Policy:
default-src 'self';
script-src 'self' cdn.example.com;
style-src 'self' fonts.googleapis.com;
font-src fonts.gstatic.com;
img-src 'self' data:;
object-src 'none';
CORS
Definition: CORS is a browser security mechanism that controls how web applications request resources from a different domain (cross-origin).
Goal: Protect users from malicious websites trying to access sensitive data from another origin (e.g., banking sessions).
Mechanism:
Server responds with headers like Access-Control-Allow-Origin, Access-Control-Allow-Methods, Access-Control-Allow-Headers.
Browsers enforce rules; preflight requests (OPTIONS) check permissions before sensitive calls.
Use Cases:
Allow specific frontend domains to call backend APIs.
Secure public APIs with controlled exposure.
Restrict admin APIs to same-origin only.
Caching
use HTTPOnly to prevent accessing by JS
Encrypt cached data
Do not cache sensitive data on the frontend
Store secrets on BE, not FE
CAPTCHA (Completely Automated Public Turing test to tell Computers and Humans Apart) is a security measure used to distinguish between human and automated users (bots) on the internet.
How does it work?
The server generates a test and sends it with the web page.
The client (you) solves it and submits the solution.
The server verifies the answer and decides:
✅ Pass → Continue (human).
❌ Fail → Block/suspicious (likely bot)
CAPTCHA Governance
Here are additional CAPTCHA insertion points to enhance protection against bots:
Bot Mitigation – To prevent automated abuse (credential stuffing, spam, fake registrations, scraping).
Public-Facing Forms – Login, registration, password reset, comment sections.
Rate-Limited Services – Before throttling kicks in, add CAPTCHA to discourage bots.
Anonymous User Access – When the user is not yet authenticated (pre-login).
Password or Email Change – prevent unauthorized credential updates.
Account Deletion or Data Export (GDPR) – block malicious automated actions.
Checkout Process (Submitting) or Adding New Payment Methods – prevent fraud attempts.
Sensitive Actions in Dashboard – e.g., changing user roles or permissions.
Bulk Content Publishing – avoid mass spam uploads or auto-generated content.
High-Frequency Search Requests – throttle scraping or brute-force lookups.
Resending Activation Codes or OTP – stop abuse of verification endpoints.
Username Recovery Flows – prevent brute-force discovery of usernames.
Public API Access Without Authentication – add CAPTCHA before processing.
Inserting External Links in Comments/Chats – reduce link spam.
localStorage: Persists after browser close / device restart
sessionStorage: Cleared when tab or browser closes
localStorage: 🚨 Higher XSS risk (data stays longer)
sessionStorage: ⚠️ Lower XSS risk, but still vulnerable
localStorage: 🌐 Shared across all tabs of same domain
sessionStorage: 📄 Tab-specific only
localStorage: ❌ Unsafe for JWT or tokens
sessionStorage: ⚠️ Safer but still not recommended
Don’t store sensitive data (tokens, passwords)
Use for temporary or non-sensitive UI state
Apply CSP + input sanitization to reduce XSS
Prefer HttpOnly Secure Cookies for authentication
Definition: OTP (One-Time Password) is a temporary, single-use code used to authenticate a user for a specific action or session.
Purpose: Adds an extra security layer beyond username/password (part of MFA).
Validity: Typically valid for a short time (e.g., 30–300 seconds) or a single transaction.
Delivery Methods: SMS, email, authenticator apps (like Google Authenticator), hardware tokens.
Use Cases: Login verification, financial transactions, password resets, sensitive data access.
Security Advantage: Reduces risk of credential theft because the code expires quickly and cannot be reused.
When to use it?
Public-Facing Forms: Login, registration, password reset, and comment sections.
Payment: Protects financial transactions (PCI DSS, PSD2 compliance). Mitigates fraud and unauthorized payments.
Journey execution: Create a transaction on behalf of another
Dynamic Definition: Customer to define sensitivity for the journey step, which should have MFA, and MFA method (OTP/email/WhatsApp)
Document Downloads: Secure customer documents
Access Sensitive Data: By F2F employees: Customer profiles
Access Sensitive Data: By Customer: Customer profiles
Assets Transfer: change ownership between customers
ESLint doesn’t actually stand for anything (it’s not an acronym).
The name comes from:
“Lint” → a term from the Unix world (the original lint tool scanned C code for errors). It means static analysis tool that finds problems in code.
“ES” → short for ECMAScript (the standard behind JavaScript).
👉 So ESLint = Linter for ECMAScript (JavaScript).
Best ESLint Plugins for Security in React
eslint-plugin-security
Detects common security issues like eval(), RegEx DoS, unsafe object property access, etc.
Not React-specific, but protects JS code you write in React apps.
eslint-plugin-no-secrets
Prevents hardcoding API keys, secrets, and credentials in React code.
eslint-plugin-jsx-no-script-url (sometimes included in React rules)
Blocks dangerous patterns like href="javascript:void(0)".
eslint-plugin-sonarjs
Flags suspicious or vulnerable coding patterns (e.g., complexity, hidden bugs).
eslint-plugin-unicorn
Has some security-related rules (like avoiding deprecated/dangerous APIs).
Dr. Ghoniem Lawaty
Tech Evangelist @TechHuB Egypt