The OWASP Top 10 is a standard awareness document for developers and web application security professionals. It represents a broad consensus about the most critical security risks to web applications.
1. Broken Access Control
Access control enforces policy such that users cannot act outside of their intended permissions. Failures typically lead to unauthorized information disclosure, modification, or destruction of all data or performing a business function outside the user's limits.
Common Examples:
- Violation of the principle of least privilege or deny by default
- Bypassing access control checks by modifying the URL, internal application state, or the HTML page
- Permitting viewing or editing someone else's account by providing its unique identifier (insecure direct object references)
- Accessing API with missing access controls for POST, PUT and DELETE
How to Prevent:
- Implement access control mechanisms and enforce them throughout the application
- Deny by default - except for public resources, deny access by default
- Use a centralized access control mechanism
- Log access control failures and alert admins when appropriate
2. Cryptographic Failures
Previously known as Sensitive Data Exposure, this category focuses on failures related to cryptography (or lack thereof) which often leads to exposure of sensitive data.
Common Examples:
- Transmitting data in clear text (HTTP, SMTP, FTP)
- Using old or weak cryptographic algorithms
- Using default crypto keys, weak keys, or reusing keys
- Not enforcing encryption (e.g., missing security headers)
Prevention Methods:
- Classify data processed, stored, or transmitted by an application
- Don't store sensitive data unnecessarily
- Encrypt all sensitive data at rest and in transit
- Use up-to-date and strong algorithms, protocols, and keys
- Disable caching for responses containing sensitive data
3. Injection
Injection flaws, such as SQL, NoSQL, OS, and LDAP injection, occur when untrusted data is sent to an interpreter as part of a command or query. The attacker's hostile data can trick the interpreter into executing unintended commands or accessing data without proper authorization.
SQL Injection Example:
// Vulnerable Code
String query = "SELECT * FROM users WHERE username = '" + username + "' AND password = '" + password + "'";
// Attacker Input: username = admin'--
// Resulting Query: SELECT * FROM users WHERE username = 'admin'--' AND password = ''
// The -- comments out the rest, bypassing password check
Prevention:
- Use parameterized queries (prepared statements)
- Use ORM frameworks that handle queries securely
- Validate and sanitize all user inputs
- Use allowlist input validation
- Escape special characters using specific escape syntax
4. Insecure Design
Insecure design is a broad category representing different weaknesses, expressed as "missing or ineffective control design." An insecure design cannot be fixed by a perfect implementation as by definition, needed security controls were never created to defend against specific attacks.
How to Prevent:
- Establish and use a secure development lifecycle with security professionals
- Establish and use a library of secure design patterns
- Use threat modeling for critical authentication, access control, business logic, and key flows
- Integrate security language and controls into user stories
5. Security Misconfiguration
Security misconfiguration is the most commonly seen issue. This is commonly a result of insecure default configurations, incomplete or ad hoc configurations, open cloud storage, misconfigured HTTP headers, and verbose error messages containing sensitive information.
Common Issues:
- Missing appropriate security hardening
- Unnecessary features enabled or installed
- Default accounts with unchanged passwords
- Overly informative error messages revealing system details
- Latest security features are disabled or not configured securely
6. Vulnerable and Outdated Components
Components, such as libraries, frameworks, and other software modules, run with the same privileges as the application. If a vulnerable component is exploited, such an attack can facilitate serious data loss or server takeover.
Prevention Steps:
- Remove unused dependencies, unnecessary features, components, files, and documentation
- Continuously inventory versions of both client-side and server-side components
- Only obtain components from official sources over secure links
- Monitor for libraries and components that are unmaintained or do not create security patches
7. Identification and Authentication Failures
Confirmation of the user's identity, authentication, and session management is critical to protect against authentication-related attacks. Application functions related to authentication and session management are often implemented incorrectly.
Common Weaknesses:
- Permits brute force or other automated attacks
- Permits weak or well-known passwords
- Uses weak or ineffective credential recovery processes
- Uses plain text, encrypted, or weakly hashed passwords
- Missing or ineffective multi-factor authentication
8. Software and Data Integrity Failures
Software and data integrity failures relate to code and infrastructure that does not protect against integrity violations. An example is where an application relies upon plugins, libraries, or modules from untrusted sources.
How to Prevent:
- Use digital signatures to verify software or data is from expected source
- Ensure libraries and dependencies are consuming trusted repositories
- Use software supply chain security tools
- Ensure there is a review process for code and configuration changes
9. Security Logging and Monitoring Failures
Without logging and monitoring, breaches cannot be detected. Insufficient logging, detection, monitoring, and active response occurs any time logging and alerting are ineffective or missing.
Best Practices:
- Ensure all login, access control, and server-side input validation failures can be logged
- Ensure logs are generated in a format that log management solutions can easily consume
- Ensure log data is encoded correctly to prevent injections or attacks
- Establish effective monitoring and alerting
- Establish or adopt an incident response and recovery plan
10. Server-Side Request Forgery (SSRF)
SSRF flaws occur whenever a web application is fetching a remote resource without validating the user-supplied URL. It allows an attacker to coerce the application to send a crafted request to an unexpected destination.
Prevention Measures:
- Sanitize and validate all client-supplied input data
- Enforce URL schema, port, and destination with a positive allow list
- Do not send raw responses to clients
- Disable HTTP redirections
- Implement network segmentation to reduce SSRF impact
Conclusion
Understanding and mitigating OWASP Top 10 vulnerabilities is essential for building secure web applications. Regular security assessments, code reviews, and keeping up-to-date with the latest security practices are crucial steps in maintaining application security.
Remember, security is not a one-time effort but a continuous process. Stay informed, stay vigilant, and always prioritize security in your development lifecycle.