Security Fundamentals

lock

Cryptography Basics

Symmetric Encryption

Same key for encryption and decryption, fast performance with algorithms like AES and ChaCha20.

Key Features
  • Block vs stream ciphers
  • Cipher modes (CBC, GCM, CTR)
  • Key management and rotation
  • High performance for bulk data
Use Cases
  • File encryption at rest
  • Full disk encryption
  • VPN tunnel encryption
  • Database encryption
Asymmetric Encryption

Public/private key pairs using RSA or ECC, slower but enables secure key exchange and digital signatures.

Key Features
  • Key exchange protocols
  • Digital signature support
  • Certificate-based authentication
  • No shared secret required
Use Cases
  • TLS/SSL handshakes
  • SSH authentication
  • PGP email encryption
  • Code signing certificates
Hashing

One-way function for data integrity and password storage using SHA-256, bcrypt, or Argon2.

Key Features
  • Collision resistance
  • Avalanche effect property
  • Salt for password hashing
  • Configurable work factor
Use Cases
  • Password storage (bcrypt, Argon2)
  • Data integrity verification
  • Blockchain proof-of-work
  • Git commit hashing
Digital Signatures

Message authenticity and non-repudiation using RSA or ECDSA algorithms with public key verification.

Key Features
  • Sign with private key
  • Verify with public key
  • Integrity guarantee
  • Non-repudiation property
Use Cases
  • Code signing for software
  • Document signing (PDF)
  • JWT token signatures
  • Blockchain transactions
badge

Authentication & Authorization

Password Security

Secure password handling with strong hashing (bcrypt, Argon2), salting, and multi-factor authentication.

Key Features
  • Slow hashing algorithms
  • Unique salts per password
  • Password complexity policies
  • Multi-factor authentication (MFA)
Use Cases
  • User account systems
  • Admin access control
  • API key management
  • Service account credentials
OAuth 2.0

Authorization framework for delegated access with access tokens, refresh tokens, and scoped permissions.

Key Features
  • Authorization code flow
  • Client credentials flow
  • PKCE for mobile apps
  • Token refresh mechanism
Use Cases
  • Social login (Google, GitHub)
  • API authorization
  • Third-party app access
  • Single Sign-On (SSO)
JWT (JSON Web Tokens)

Self-contained tokens for stateless authentication with signature verification and claims-based authorization.

Key Features
  • Header, payload, signature structure
  • Expiration and claims
  • Stateless authentication
  • Token-based authorization
Use Cases
  • API authentication
  • Microservices communication
  • Mobile app authentication
  • Distributed system auth
RBAC/ABAC

Role-based and attribute-based access control for fine-grained permissions and policy management.

Key Features
  • Role hierarchies
  • Permission assignments
  • Attribute-based policies
  • Dynamic access control
Use Cases
  • Admin panel permissions
  • Multi-tenant applications
  • Document access control
  • Resource-level permissions
bug_report

Common Vulnerabilities (OWASP Top 10)

SQL Injection

Malicious SQL code injection through user inputs, prevented with parameterized queries and ORMs.

Key Features
  • Detection techniques
  • Prepared statements
  • Input validation
  • ORM usage for safety
Use Cases
  • Login bypass attacks
  • Data exfiltration
  • Database manipulation
  • Privilege escalation
XSS (Cross-Site Scripting)

Injected malicious scripts (reflected, stored, DOM-based) prevented with input sanitization and CSP headers.

Key Features
  • Input sanitization
  • Output encoding
  • Content Security Policy (CSP)
  • HTTPOnly cookies
Use Cases
  • Cookie theft
  • Session hijacking
  • Website defacement
  • Phishing attacks
CSRF (Cross-Site Request Forgery)

Unauthorized actions using victim's credentials, prevented with CSRF tokens and SameSite cookies.

Key Features
  • CSRF token validation
  • Referer header checking
  • SameSite cookie attribute
  • Double submit cookie pattern
Use Cases
  • Unwanted fund transfers
  • Account setting changes
  • Data modification
  • Email address changes
Authentication Failures

Broken authentication mechanisms including weak passwords, poor session management, and missing MFA.

Key Features
  • Multi-factor authentication
  • Session timeout policies
  • Secure password storage
  • Account lockout mechanisms
Use Cases
  • Credential stuffing attacks
  • Brute force attempts
  • Session fixation
  • Password reset vulnerabilities
verified_user

Secure Coding Practices

Input Validation

Whitelist approach with type checking, length limits, and proper encoding for all user inputs.

Key Features
  • Client and server validation
  • Regex pattern matching
  • Data sanitization
  • Type enforcement
Use Cases
  • Form input validation
  • API parameter checking
  • File upload validation
  • Search query sanitization
Secure Communication

TLS/SSL encryption for data in transit with certificate validation and HSTS headers.

Key Features
  • Encryption in transit
  • Certificate validation
  • Forward secrecy (PFS)
  • HSTS enforcement
Use Cases
  • HTTPS web traffic
  • API communication
  • Database connections
  • File transfers
Secrets Management

Secure storage and handling of secrets using environment variables, vaults, and key rotation policies.

Key Features
  • Encryption at rest
  • Access control policies
  • Audit logging
  • Automatic rotation
Use Cases
  • API keys and tokens
  • Database passwords
  • TLS certificates
  • Encryption keys
Related Practices
HashiCorp VaultAWS Secrets ManagerAzure Key VaultGoogle Secret Manager
Logging & Monitoring

Security event logging with anomaly detection, audit trails, and SIEM integration for threat detection.

Key Features
  • Log aggregation
  • Real-time alerting
  • Retention policies
  • Compliance reporting
Use Cases
  • Failed login attempts
  • Access logs
  • Error tracking
  • Intrusion detection
Related Practices
SplunkELK StackDatadogNew Relic