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
Web frontend
Mobile Frontend
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
Insecure Redirects
Validate redirect URLs
Check with 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
Obfuscation
CSP
CORS
HTTPOnly Cache
Store secrets on BE not FE
Dr. Ghoniem Lawaty
Tech Evangelist @TechHuB Egypt