🛡️ Secure Full-Stack Development
From Code to Infrastructure
Instructor: Yafet Tesfaye
Date: March 2026
1. Executive Brief
Security is not a feature—it is the foundation of modern systems.
A single vulnerability can compromise an entire application or infrastructure.
Key Principle: Every line of code is a potential attack surface.
2. Zero Trust Development
Never trust:
• User input
• Client-side validation
• External APIs
Always validate, sanitize, and verify data on the server.
3. Attack Surface
Layers:
• Frontend → XSS, token exposure
• Backend → Logic flaws, authentication issues
• Database → SQL Injection, data leaks
• Network → MITM attacks
Entry Points:
• Forms, URLs, Cookies, APIs
4. Core Vulnerabilities & Fixes
SQL Injection (SQLi)
Risk: Database manipulation or bypass login
Fix: Prepared statements, parameterized queries
Cross-Site Scripting (XSS)
Risk: Script injection, session theft
Fix: Output encoding, avoid unsafe DOM rendering
CSRF (Cross-Site Request Forgery)
Risk: Unauthorized actions via user session
Fix: CSRF tokens, SameSite cookies
Broken Authentication
Risk: Account takeover
Fix: Strong hashing, secure session management
5. Authentication & Identity Security
Password Storage:
• Use Bcrypt or Argon2
• Never use MD5 or SHA-1
Session Security:
• HttpOnly → prevents JavaScript access
• Secure → HTTPS only
• SameSite → CSRF protection
Best Practice:
• Regenerate session ID after login
6. Data Protection
In Transit:
• Enforce HTTPS (TLS 1.2+)
At Rest:
• Hash passwords
• Encrypt sensitive data
7. Infrastructure Hardening
File Permissions:
• 755 → Directories
• 644 → Files
• 777 → Never use
Server Security:
• Disable directory listing
• Protect .env and config files
8. API Security
• Require authentication
• Validate all inputs
• Implement rate limiting
9. DevSecOps Workflow
1. Develop securely
2. Scan code (SAST)
3. Test system (DAST)
4. Patch continuously
10. Security Checklist
• Validate all server-side input
• Use prepared statements
• Hash passwords securely
• Enable HTTPS
• Secure cookies
• Protect sensitive files
• Limit login attempts