Tips for improving Drupal security
I had a chance to check out the Talking Drupal: Drupal security podcast. These were my key takeaways.
Top 3 tips
Its stuff we already know about but don't do. Lets educate and remind ourselves and others.
- Patch your modules. Security patches are released every 3rd Tuesday of the month by the Drupal Security team. Sign up to security announcements. You can use RSS feeds to bring updates to your slack, teams, etc. There is also a Discord site.
- Use tools that make your code better. e.g. CI to make it more readable (coding styles, comments). Code reviews. Write the least amount of code as possible. No code is best ie only using Core and Contrib modules. (IMO, as a developer this is impossible 😂)
Contrib modules to help improve Drupal security
- Username enumeration prevention - Prevents anonymous users from finding valid usernames (which can used in an attack)
- Guardr Core - Set of Drupal security modules that can be enabled on your site.
Have a Security plan
Plan for the worst. What will you do “WHEN” you get hacked? Also provide a way for users to report potential security issues to you.
Finding vulnerabilities
Drupal Security team is mostly reactive. They rely on the community or their own experiences to find vulnerabilities, then respond to them and patch as required.
They often patch a core issue and find contrib modules that have the same vulnerability. They identify the code pattern, then use regular expression to search across local repo’s (top contrib modules are available on a hard-drive) and/or Gitlab.
Report potential vulnerabilities
Dependabot does not work with PHP
My experience with Github Depenabot is that its good at finding vulnerable npm packages but not so much PHP. While listening I did some research on tools for scanning PHP apps using Github Actions. I came across a few which I will try when I get some time:
Patches
Things not covered but may be helpful to readers.
- Check patches carefully before applying them. It may be a source of a potential vulnerability.
- Record the issue ID in your composer so you can review the issue from time to time to use the approved patch or patched version.
- Do not use a patch generated by a merge/pull request (PR) as it can change at any time (code poising attack). Download it to your repo and patch.
- In the past I posted on The Pragmatic Guide to Defending Drupal which also has some helpful tips. One I need to revisit is Trivy for scanning CVEs and sensitive information.
The Talk
Have a listen/watch to find more goodies
Comments
Post a Comment