Core Concept

Vulnerability Assessment involves identifying weaknesses in a system, while Hardening refers to reducing its attack surface by remediating those weaknesses. Together, they form a critical defense and recon step in ethical hacking.

NIST NVD VulDB OWASP Top 10

🕵️‍♂️ Vulnerability Assessment

The goal is to scan systems, services, and configurations to detect known vulnerabilities that an attacker might exploit.

🔧 Common Tools

ToolDescription
OpenVAS / GVMFull-featured open-source scanner with regular CVE database updates.
Nessus EssentialsFree for up to 16 IPs; widely used in professional environments.
LynisLightweight auditing and hardening tool for Unix-based systems.
NiktoScans web servers for outdated versions, risky files, and misconfigurations.
Nmap + NSEPowerful port scanner with scripting engine for basic vuln detection.

Helpful Tip

Run scans both authenticated (logged in) and unauthenticated for deeper insight.


🛡️ System Hardening

Once vulnerabilities are identified, hardening aims to remove or mitigate them through configuration changes and security practices.

📋 Techniques

  • Disable unused services and ports.
  • Apply all system and package updates.
  • Enforce strong password and authentication policies.
  • Configure firewalls (e.g., ufw, iptables).
  • Set proper file and directory permissions.
  • Enable logging and auditing (e.g., auditd).

🧰 Hardening Tools

  • Lynis – also provides hardening recommendations.
  • Debsecan – shows known vulnerabilities for installed Debian packages.
  • chkrootkit / rkhunter – check for rootkits.
  • CIS Benchmarks – security best practices per OS.

🔁 Workflow Example (Mermaid)

flowchart TD
    A[Recon & Enumeration] --> B[Run Vulnerability Scanner]
    B --> C[Analyze CVE Results]
    C --> D[Prioritize Fixes]
    D --> E[Apply Hardening Steps]
    E --> F[Re-scan & Validate]

Did You Know?

Continuous hardening is a key part of defense-in-depth, especially when paired with Command & Control detection and Defense Evasion mitigation.


🔐 Security Checklist for Web Applications

Introduction to CWE and MITRE

The Common Weakness Enumeration (CWE) is a community-developed list of software and hardware weakness types maintained by MITRE, a not-for-profit organization that operates Federally Funded Research and Development Centers (FFRDCs) in the U.S.

  • CWE provides a common language for describing software security weaknesses.
  • It helps developers, testers, and security professionals identify and mitigate vulnerabilities early in the software development lifecycle.
  • MITRE supports this effort by curating and updating the CWE list, ensuring it reflects current threats and industry practices.

SANS Institute and the SWAT Checklist

The SANS Institute is a trusted authority in cybersecurity training and certification. One of their key contributions to web application security is the SWAT (Securing Web Application Technologies) Checklist https://www.sans.org/cloud-security/securing-web-application-technologies/

  • The SWAT Checklist is a practical guide for developers and security teams.
  • It outlines best practices across critical areas such as:
    • Authentication
    • Session Management
    • Input Validation
    • Access Control
    • Logging and Monitoring
    • Error Handling
    • Data Protection

You can explore the full checklist here.


Summary of SWAT Checklist Categories

🛠️ Error Handling and Logging

📊 Mermaid Diagram

graph TD
    A[Error Handling and Logging] --> B[Display Generic Error Messages]
    A --> C[No Unhandled Exceptions]
    A --> D[Suppress Framework Generated Errors]
    A --> E[Log All Authentication Activities]
    A --> F[Log All Privilege Changes]
    A --> G[Log Administrative Activities]
    A --> H[Log Access to Sensitive Data]
    A --> I[Do Not Log Inappropriate Data]
    A --> J[Active Security Monitoring]
    A --> K[Store Logs Securely]

📋 Table Summary

Best PracticeDescriptionCWE ID
Display Generic Error MessagesAvoid exposing internal application details like file paths or stack traces in error messages.CWE-209
No Unhandled ExceptionsEnsure all exceptions are caught and handled gracefully to prevent application crashes and information leakage.CWE-391
Suppress Framework ErrorsReplace default framework error messages with custom ones to avoid leaking sensitive information.CWE-209
Log All Authentication ActivitiesRecord login attempts, token events, and failed authentications with metadata like IP and device info.CWE-778
Log All Privilege ChangesTrack any changes in user privilege levels.CWE-778
Log Administrative ActivitiesLog all administrative actions across the application and its components.CWE-778
Log Access to Sensitive DataRecord access to sensitive data, especially for compliance with regulations like HIPAA, PCI, or SOX.CWE-778
Do Not Log Inappropriate DataAvoid logging sensitive data in plaintext; encrypt logs if necessary to meet compliance and reduce risk.CWE-532
Active Security MonitoringUse centralized logging (e.g., SIEM), cryptographic validation, and automated threat detection with alerting and response protocols.CWE-778
Store Logs SecurelyProtect logs from tampering or loss, and follow retention policies for forensic and compliance purposes.CWE-533

🔒 Data Protection

📊 Mermaid Diagram

graph TD
    A[Data Protection] --> B[Use HTTPS Everywhere]
    A --> C[Encrypt Sensitive Data at Rest]
    A --> D[Secure Data in Transit]
    A --> E[Implement Proper Key Management]
    A --> F[Avoid Storing Sensitive Data Unless Necessary]
    A --> G[Field-Level Access Controls]

📋 Table Summary

Best PracticeDescriptionCWE ID(s)
Use HTTPS EverywhereUse HTTPS across the entire application, especially for authentication and sensitive data transmission.CWE-311, CWE-319, CWE-523
Encrypt Sensitive Data at RestEncrypt stored sensitive data using strong algorithms to prevent unauthorized access.CWE-311
Secure Data in TransitUse TLS or similar protocols to encrypt sensitive data during transmission.CWE-319
Implement Proper Key ManagementSecurely manage encryption keys with rotation, access control, and separation by environment or data type.CWE-320
Avoid Storing Sensitive DataMinimize storage of sensitive data; encrypt and restrict access when storage is necessary.CWE-312
Field-Level Access ControlsEnforce access controls at the field level in APIs, using attribute-based policies and server-side filtering to prevent unauthorized data exposure.CWE-213, CWE-285

⚙️ Configuration and Operations

📊 Mermaid Diagram

graph TD
    A[Configuration and Operations] --> B[Automate Secure App Deployment]
    A --> C[Change Management Process]
    A --> D[Define Security Requirements]
    A --> E[Design Review & Threat Modeling]
    A --> F[Perform Code Reviews]
    A --> G[Security Testing]
    A --> H[Secure CI/CD Pipeline]
    A --> I[Harden Infrastructure]
    A --> J[Incident Handling Plan]
    A --> K[Security Education]
    A --> L[Minimal Privileges for Apps]
    A --> M[Rate Limiting]
    A --> N[API Inventory & Documentation]

📋 Table Summary

Best PracticeDescriptionCWE ID(s)
Automate Secure App DeploymentUse CI/CD pipelines with integrated security checks (SAST, DAST, SCA, secrets scanning, etc.) for consistent and secure deployments.
Change Management ProcessEnforce a rigorous process for managing and approving changes before deployment.CWE-439
Define Security RequirementsCollaborate with stakeholders to define functional and non-functional security requirements early in the development lifecycle.
Design Review & Threat ModelingConduct threat modeling and design reviews to identify and mitigate risks before development begins.CWE-701, CWE-656
Perform Code ReviewsRegularly review code for security flaws such as injection and XSS vulnerabilities.CWE-702
Security TestingPerform security testing during and after development, especially after major updates.
Secure CI/CD PipelineProtect the CI/CD pipeline with access controls, secrets management, and integrity checks to prevent tampering.CWE-94, CWE-284
Harden InfrastructureApply hardening guidelines to all infrastructure components and use tools like WAFs and API gateways.CWE-15, CWE-656
Incident Handling PlanDevelop and regularly test a plan for responding to security incidents, with clear roles and contacts.
Security EducationProvide ongoing security training for all roles involved in the development process.
Minimal Privileges for AppsRun applications and middleware with the least privileges necessary to reduce impact if compromised.CWE-250
Rate LimitingImplement tiered rate limits, progressive throttling, and circuit breakers to protect backend services.CWE-770, CWE-307, CWE-400
API Inventory & DocumentationMaintain a complete, documented inventory of APIs with ownership, classification, and security requirements.CWE-1059

🔐 Authentication

📊 Mermaid Diagram

graph TD
    A[Authentication] --> B[Don't Hardcode Credentials]
    A --> C[Strong Password Reset System]
    A --> D[Strong Password Policy / Passwordless Auth]
    A --> E[Support Modern MFA]
    A --> F[Account Lockout Mechanisms]
    A --> G[Limit Info in Error Messages]
    A --> H[Secure Storage of DB Credentials & API Keys]

📋 Table Summary

Best PracticeDescriptionCWE ID(s)
Don’t Hardcode CredentialsAvoid embedding credentials in source code. Use secure secrets management solutions instead.CWE-798
Strong Password Reset SystemUse secure, non-guessable reset mechanisms and avoid revealing account existence through reset flows.CWE-640
Strong Password Policy / Passwordless AuthEnforce strong password rules or adopt passwordless methods like FIDO2 or push-based authenticators.CWE-521
Support Modern MFAImplement phishing-resistant MFA (e.g., FIDO-based passkeys) for sensitive or admin accounts.CWE-308
Account Lockout MechanismsPrevent brute force and credential stuffing with lockouts, rate limiting, and behavioral analysis.CWE-307
Limit Info in Error MessagesAvoid revealing whether a username or password is incorrect to prevent account enumeration.
Secure Storage of DB Credentials & API KeysStore credentials in centralized, secure locations (e.g., secrets managers), not in code or config files.CWE-257

🧾 Session Management

📊 Mermaid Diagram

graph TD
    A[Session Management] --> B[Random Session Identifiers]
    A --> C[Regenerate Session Tokens]
    A --> D[Idle Session Timeout]
    A --> E[Absolute Session Timeout]
    A --> F[Destroy Tampered Sessions]
    A --> G[Invalidate on Logout]
    A --> H[Logout Button on Every Page]
    A --> I[Secure Cookie Attributes]
    A --> J[Set Cookie Domain & Path]
    A --> K[Set Cookie Expiration]
    A --> L[API Token Generation]
    A --> M[API Token Validation]
    A --> N[API Token Storage & Transmission]
    A --> O[Secure CORS Configuration]

📋 Table Summary

Best PracticeDescriptionCWE ID(s)
Random Session IdentifiersUse secure random functions to generate unpredictable session tokens.CWE-6
Regenerate Session TokensRegenerate tokens on login, privilege changes, or encryption status changes to prevent fixation.CWE-384
Idle Session TimeoutAutomatically log out users after inactivity to reduce hijacking risk.CWE-613
Absolute Session TimeoutEnforce logout after a fixed time period regardless of activity.CWE-613
Destroy Tampered SessionsDetect and destroy cloned or tampered sessions to force re-authentication.
Invalidate on LogoutFully destroy session data on logout to prevent reuse.CWE-613
Logout Button on Every PageProvide easy access to logout functionality on all authenticated pages.
Secure Cookie AttributesUse HttpOnly, Secure, and SameSite flags to protect session cookies.CWE-79, CWE-614, CWE-1004
Set Cookie Domain & PathRestrict cookie scope to the minimal required domain and path.
Set Cookie ExpirationAvoid non-expiring cookies; set reasonable expiration times.
API Token GenerationUse standards like OAuth2/JWT with secure algorithms and short-lived tokens.CWE-330
API Token ValidationValidate token signatures and claims; implement rotation and revocation.CWE-347
API Token Storage & TransmissionTransmit via Authorization headers; store securely using HttpOnly cookies or platform-specific secure storage.CWE-598
Secure CORS ConfigurationUse strict CORS policies with allowlists and avoid wildcards for sensitive data.CWE-346

🧮 Input and Output Handling

📊 Mermaid Diagram

graph TD
    A[Input and Output Handling] --> B[Contextual Output Encoding]
    A --> C[Prefer Allowlists]
    A --> D[Parameterized SQL Queries]
    A --> E[CSRF Tokens & Cookie Flags]
    A --> F[Set Content Encoding]
    A --> G[Validate Uploaded Files]
    A --> H[Use Nosniff Header]
    A --> I[Validate Input Source]
    A --> J[Secure HTTP Headers]
    A --> K[Safe Deserialization]
    A --> L[Mass Assignment Protection]
    A --> M[HTML Sanitization]

📋 Table Summary

Best PracticeDescriptionCWE ID(s)
Contextual Output EncodingEncode output based on its context (HTML, JS, URL) to prevent XSS.CWE-79
Prefer AllowlistsValidate input using allowlists; blocklists are secondary.CWE-159, CWE-144
Parameterized SQL QueriesUse bind variables to prevent SQL injection; avoid dynamic query construction.CWE-89, CWE-564
CSRF Tokens & Cookie FlagsUse CSRF tokens and secure cookie attributes to prevent forged requests.CWE-352
Set Content EncodingDefine encoding (e.g., UTF-8) via headers or meta tags to prevent XSS.CWE-172
Validate Uploaded FilesCheck file size, type, content, and path to prevent malicious uploads.CWE-434, CWE-616, CWE-22
Use Nosniff HeaderPrevent MIME type sniffing by setting X-Content-Type-Options: nosniff.CWE-430
Validate Input SourceAccept input only from expected sources (e.g., POST vs GET).CWE-20, CWE-346
Secure HTTP HeadersUse headers like X-Frame-Options to prevent clickjacking; add framebusting JS for older browsers.CWE-79, CWE-692
Safe DeserializationAvoid insecure deserialization; use safe formats and restrict object types.CWE-502
Mass Assignment ProtectionPrevent overposting by restricting which fields can be updated.CWE-915
HTML SanitizationSanitize user-generated HTML to prevent XSS in rich content.CWE-79

🛡️ Access Control

📊 Mermaid Diagram

graph TD
    A[Access Control] --> B[Consistent Access Control Checks]
    A --> C[Least Privilege Principle]
    A --> D[No Direct Object References]
    A --> E[No Unvalidated Forwards/Redirects]
    A --> F[Secrets Management for Credentials]
    A --> G[Correct Authorization Checks]

📋 Table Summary

Best PracticeDescriptionCWE ID(s)
Consistent Access Control ChecksEnforce access control on every request through a centralized mechanism.CWE-284
Least Privilege PrincipleGrant only the minimum necessary permissions to users and services.CWE-272, CWE-250
No Direct Object ReferencesAvoid exposing internal references (e.g., file names, IDs) directly to users; validate access server-side.CWE-284
No Unvalidated Forwards/RedirectsValidate all redirects and forwards to prevent unauthorized access or phishing.CWE-601
Secrets Management for CredentialsUse centralized secrets management tools to securely store and manage API keys and credentials.CWE-522
Correct Authorization ChecksEnsure users can only access resources and perform actions they are authorized for, down to the field level.CWE-285

EOF