Date:
16 May 2023
Author:
Salsa Digital Security Team

Defense in depth and the application layer

This whitepaper focuses on Layer 3 of Salsa's Defense in Depth Drupal 7 Security Hosting Framework: the application layerExternal Link . The application layer, consisting of Drupal core itself and any installed modules and themes, plays a critical role in the overall security of your website. Addressing security risks and challenges at the application layer is crucial for protecting the integrity of your Drupal website, safeguarding sensitive data and maintaining user trust. Failure to address these risks and challenges may lead to compromised functionality, data breaches, and a damaged reputation.

By implementing these best practices and recommendations, you can create a more secure and robust Drupal website, mitigating risks and reducing the potential impact of security threats.

This whitepaper aims to :

  • Provide an understanding of the security risks and challenges associated with the Drupal application layer.

  • Offer an essential list of best practices and recommendations to improve security at the application layer.

  • Demonstrate the benefits and outcomes of implementing these best practices.

  • Encourage further exploration of resources and reading materials to deepen your knowledge and expertise in Drupal application security.

While this whitepaper focuses specifically on Drupal 7, many of the recommendations and best practices can be applied to other versions of Drupal as well. The content is aimed at Drupal developers, administrators and other stakeholders involved in the maintenance and management of Drupal websites. This whitepaper is part of a broader series covering all seven layers of Salsa's Defense in Depth Drupal 7 Security Hosting Framework, which should be considered holistically to ensure comprehensive security across your entire Drupal ecosystem.

Security risks and challenges

The Drupal application layer faces many unique security risks and challenges that must be addressed to ensure a secure and reliable website.

There are 9 main security risks and challenges at the application layer, broken into either common security risks or challenges in application security:

  1. Insecure coding practices
  2. Insufficient input validation and sanitisation
  3. Weak user authentication and authorisation
  4. Insecure file and data handling
  5. Outdated software and components
  6. Keeping up with evolving threats
  7. Balancing usability and security
  8. Ensuring consistent security practices
  9. Integrating security into the development lifecycle

1. Insecure coding practices

The application layer is vulnerable to insecure coding practices, which can lead to vulnerabilities such as SQL injectionExternal Link , cross-site scripting (XSS)External Link and cross-site request forgery (CSRF)External Link .

2. Insufficient input validation and sanitisation

Failing to validate and sanitise user inputs can expose the application to attacks like injection and XSS, potentially compromising user data and site functionality.

3. Weak user authentication and authorisation

Weak authentication and authorisation mechanisms may allow unauthorised access to sensitive data, leading to data breaches or the takeover of administrative privileges.

4. Insecure file and data handling

Insecure handling of files and data can expose sensitive information, potentially leading to data breaches or unauthorised access to resources.

5. Outdated software and components

Running outdated versions of Drupal core, modules, themes or third-party components may expose the application to known vulnerabilities, placing the entire system at risk.

6. Keeping up with evolving threats

Application layer security requires continuous monitoring and updating to stay ahead of the latest security threats and vulnerabilities.

7. Balancing usability and security

Implementing strong security measures at the application layer may sometimes impact usability or performance, necessitating a careful balance between security and user experience.

8. Ensuring consistent security practices

Ensuring consistent security practices across the application can be challenging, particularly when working with a large team of developers or integrating third-party components.

9. Integrating security into the development lifecycle

Integrating security best practices throughout the software development lifecycle requires a proactive approach and an organisational culture that values security.

Top 10 best practices and recommendations

Below we’ve put together our top 10 best practices/recommendations for securing the application layer.

  1. Secure coding practices
  2. Input validation and sanitisation
  3. Strong user authentication and authorisation
  4. Secure file and data handling
  5. Keeping software and components up-to-date
  6. Implementing security-focused modules and monitor logs
  7. Regular security audits and testing
  8. Developer security training
  9. Secure software development lifecycle (SSDLC) integration
  10. Incident response planning

1. Secure coding practices

Secure coding practices help prevent vulnerabilities such as SQL injection, XSS and CSRF, protecting the Drupal application against attacks and breaches.

Security benefits: Secure coding practices include input validationExternal Link , output encodingExternal Link , and using prepared statementsExternal Link in database queries.

Actionable steps:

  1. Adhere to Drupal's coding standardsExternal Link and best practices for developmentExternal Link , site buildingExternal Link and themingExternal Link .
  2. Use Drupal's built-in APIsExternal Link for handling user inputsExternal Link , database queriesExternal Link and form handlingExternal Link .
  3. Regularly reviewExternal Link and update your code to maintain security.

2. Input validation and sanitisation

Security benefits: Input validation and sanitisation ensure user inputs are safe, preventing attacks such as injection and XSS.

Actionable steps:

  1. Validate user inputsExternal Link against a whitelist of allowed values or formats.
  2. Sanitise user inputs using Drupal's built-in sanitisation functionsExternal Link .
  3. Use Drupal's Form APIExternal Link for building forms and handling user inputs.

3. Strong user authentication and authorisation

Security benefits: Implementing strong authentication and authorisation mechanisms prevents unauthorised access and ensures the integrity of user data and the application.

Actionable steps:

  1. Implement two-factor authentication (2FA)External Link for administrative accounts.
  2. Enforce strong password policiesExternal Link for all user accounts.
  3. Limit user permissionsExternal Link based on the principle of least privilege and review accounts regularly for removal or role changes.

4. Secure file and data handling

Security benefits: Properly handling files and data prevents unauthorised access and ensures data integrity.

Actionable steps:

  1. Use Drupal's file management APIsExternal Link for secure file handling.
  2. Configure proper access controls and permissions for file directoriesExternal Link .
  3. Regularly backupExternal Link and encrypt sensitive dataExternal Link and use secure connections ( SSL/TLSExternal Link ).

5. Keep software and components up-to-date

Security benefits: Keeping Drupal, modules and third-party components updated prevents exploitation of known vulnerabilities.

Actionable steps:

  1. Regularly check for and apply Drupal coreExternal Link and module updatesExternal Link .
  2. Subscribe to Drupal security announcementsExternal Link and vulnerability alerts.
  3. AuditExternal Link and update third-party components regularly, and check if modules are covered by the security advisory policyExternal Link .

6. Implement security-focused modules and monitor logs

Security benefits: Security-focused Drupal modules and monitoring logs for suspicious behaviour can provide additional protections and enhance the security of your application.

Actionable steps:

  1. Research and install security-focused Drupal modules such as CaptchaExternal Link , Login SecurityExternal Link , Password policyExternal Link , Security KitExternal Link , Security ReviewExternal Link , Two-factor Authentication (TFA)External Link and Username Enumeration PreventionExternal Link .
  2. Configure modules according to Drupal best practices and recommendationsExternal Link .
  3. Regularly review Drupal logsExternal Link for suspicious activity.

7. Regular security audits and testing

Security benefits: Conducting regular security audits and testing helps identify vulnerabilities and ensure the ongoing security of your Drupal application.

Actionable steps:

  1. Conduct regular vulnerability scansExternal Link using tools like OWASP ZAPExternal Link or Burp SuiteExternal Link .
  2. Perform manual security assessmentsExternal Link , including penetration testingExternal Link .
  3. Address vulnerabilities and update security practicesExternal Link as needed.

8. Developer and site administrator security training

Security benefits: Educating developers and website administrators on security best practices helps ensure the consistent implementation of secure coding practices and web administration.

Actionable steps:

  1. Provide ongoing security trainingExternal Link for developers and site admins.
  2. Promote a security-focused cultureExternal Link within the web development team.
  3. Share security resourcesExternal Link and updates regularly.

9. Secure software development lifecycle (SSDLC) integration

Security benefits: Integrating security best practices throughout the development lifecycle ensures proactive security management and mitigates risk.

Actionable steps:

  1. Incorporate security considerationsExternal Link in project planning and requirements gathering.
  2. Perform security reviews and testing throughout a secure development processExternal Link .
  3. Continuously monitor and improve securityExternal Link practices after deployment.

10. Incident response planning

Security benefits: Having a well-defined incident response plan helps minimise damage and ensures a timely and effective response in case of a security breach.

Actionable steps:

  1. Develop a comprehensive incident response planExternal Link .
  2. Assign roles and responsibilities for incident response teamExternal Link members.
  3. Conduct regular incident response drillsExternal Link and update the plan as needed.

Benefits and outcomes

There are many benefits of using defense in depth strategies to secure Drupal at the application layer. These include:

  1. Enhanced security
  2. Improved performance and stability
  3. Increased user trust and brand reputation
  4. Compliance with industry standards and regulations
  5. Cost-effective security
  6. Better developer collaboration
  7. Easier troubleshooting and maintenance

1. Enhanced security

Implementing the top 10 best practices and recommendations significantly reduces the likelihood of security breaches, protecting sensitive data and preserving the integrity of your Drupal application.

2. Improved performance and stability

By applying secure coding practices, optimising configurations and keeping software up-to-date, you can achieve better performance and stability for your application.

3. Increased user trust and brand reputation

A secure application instils confidence in users, resulting in higher user satisfaction and retention, and improved brand reputation.

4. Compliance with industry standards and regulations

Adhering to these best practices will help ensure your Drupal application complies with relevant security standards and regulations, such as IRAPExternal Link (Australia), PCI Data Security StandardsExternal Link (global), GDPRExternal Link (Europe), and HIPAAExternal Link (US), reducing the risk of fines and penalties.

5. Cost-effective security

By proactively implementing these best practices, you can prevent costly security incidents and potential damage to your business.

6. Better developer collaboration

Establishing clear security guidelines and processes creates a shared understanding of security responsibilities among developers, leading to more secure code and efficient collaboration.

7. Easier troubleshooting and maintenance

When security is built into your application from the ground up, troubleshooting and maintenance become more manageable, saving both time and resources.

Conclusion

The top 10 best practices for Drupal application security have been presented to help you enhance the security posture of your Drupal application, from secure coding and configuration to continuous monitoring and vulnerability management.

A proactive approach to security enables you to identify and address potential vulnerabilities before they can be exploited, saving time, resources and potential damage to your reputation.

It's important to remember that security is an ongoing process that requires constant attention and dedication. Regularly reviewing and updating your security measures in line with industry best practices will ensure that your Drupal application remains secure and compliant.

By implementing the top 10 best practices outlined in this whitepaper, you can effectively strengthen your Drupal application's security, protect your valuable data and ensure a better user experience for your audience.

National Institute of Standards and Technology (NIST) Cybersecurity Framework and the application layer

NIST is a US-based agency that provides critical measurement solutions to promote equitable standards such as the NIST Cybersecurity FrameworkExternal Link (NIST CSF). NIST CSF is recognised globally as one of the leading standards for organisational cybersecurity management.

The NIST CSF can be applied to application security to help organisations effectively manage and mitigate cybersecurity risks associated with their applications. Here are some of the NIST CSF activities that can apply to this layer:

Identify:

  1. Asset inventory: Identify all applications and relevant components within your organisation, including their versions and dependencies.

  2. Risk assessment: Evaluate the cybersecurity risks associated with each application and relevant components considering factors like data sensitivity and potential vulnerabilities.

Protect:

  1. Secure development practices: Implement secure coding standards and best practices during the application development process to prevent vulnerabilities from being introduced.

  2. Authentication and authorisation: Ensure that proper authentication and authorisation mechanisms are in place to control access to applications and their data.

  3. Encryption: Use encryption to protect data in transit and at rest within applications.

  4. Security testing: Conduct regular security testing, such as penetration testing and code reviews, to identify and remediate vulnerabilities in applications.

Detect:

  1. Security monitoring: Deploy monitoring and logging mechanisms within applications to detect suspicious or malicious activities.

  2. Intrusion detection: Implement intrusion detection systems (IDS) or intrusion prevention systems (IPS) to identify and respond to unauthorised access or attacks.

Respond:

  1. Incident response plan: Develop an incident response plan specific to application security incidents.

  2. Patch management: Quickly respond to and apply patches for known vulnerabilities in applications to mitigate potential threats.

Recover:

  1. Backup and recovery: Regularly backup application data and configurations to ensure data recovery in case of an incident.

  2. Business continuity: Develop and test business continuity plans to minimise downtime and ensure the availability of critical applications.

More about NIST

Resources and further reading

Drupal security documentation

OWASP resources

Security testing and tools

Continuous integration and deployment

Relevant industry articles

Security conferences and training