Possible Security Improvements #18
Replies: 4 comments 1 reply
-
Unique Salt for Each UserWhen user login is enabled consider looking at Valhalla2 which had a Salt class which handled the unique salt for each user: Valhalla2 used PBKDF2. Having a unique salt for each user protects against:
When a user sets or changes their password, you should generate a new random salt. |
Beta Was this translation helpful? Give feedback.
-
Least Privilege PrincipleLeast Privilege Principle: Create separate users for different parts Doogle, each with only the permissions they need. This can limit the potential damage if one part of your application is compromised. In the context of the MySQL database, this means creating separate database users for different parts of Doogle, each with a different set of permissions. Present ConfigurationAt present the configuration focuses on convenience.
Potential Configuration Hardening
It could be argued that users Potential New Management System (Needs more thought/new functionality)Create a separate database user for each of these components, with permissions tailored to their specific needs:
|
Beta Was this translation helpful? Give feedback.
-
Database CredentialsThe database username and password are hard-coded in Why is this bad practice?
To mitigate these risks, there are a few alternatives: Environment VariablesOne common approach is to store sensitive data like database credentials in environment variables. This separates sensitive data from
You would then set these environment variables in your server's configuration. ApacheThe exact method will vary, but for Apache web server. Using the SetEnv directive in your Apache configuration file or in an .htaccess file:This directive sets environment variables that are available to your PHP scripts: Apache configuration file (or
Using the envvars fileApache often uses an
Note that this method sets environment variables that are available to Apache and all of its child processes, but these variables may not be accessible by the PHP scripts depending on the PHP configuration. Using putenv in your PHP scriptsWhile this method doesn't involve Apache directly, environment variables can be set in PHP scripts using the Also, be aware that environment variables set this way are not encrypted, so anyone with access to these files will be able to see the credentials. Make sure to secure these files appropriately. Configuration filesStore the credentials in a separate configuration file. This file should be stored outside the public directory of your web server to prevent it from being accessed directly from the web. Here's an example of a configuration file (
You can then read this file in
Again, make sure the path to Secrets management systemsA little beyond the scope here, but an outline would be Kubernetes secrets vs environment variables. |
Beta Was this translation helpful? Give feedback.
-
SQL User Hardening🔐 Recommended Production User Roles for Doogle
-- Main app (frontend)
CREATE USER 'doogle_app'@'localhost' IDENTIFIED BY 'app_password';
GRANT SELECT, INSERT ON doogle.* TO 'doogle_app'@'localhost';
-- Web crawler
CREATE USER 'doogle_crawl'@'localhost' IDENTIFIED BY 'crawl_password';
GRANT SELECT, INSERT, UPDATE ON doogle.* TO 'doogle_crawl'@'localhost';
-- Read-only user (optional)
CREATE USER 'doogle_read'@'192.168.1.200' IDENTIFIED BY 'readonly_password';
GRANT SELECT ON doogle.* TO 'doogle_read'@'192.168.1.200';
-- Admin user (restricted host/IP)
CREATE USER 'doogle_admin'@'10.0.0.5' IDENTIFIED BY 'admin_password';
GRANT ALL PRIVILEGES ON doogle.* TO 'doogle_admin'@'10.0.0.5';
FLUSH PRIVILEGES; |
Beta Was this translation helpful? Give feedback.
-
A discussion around possible security improvements to Doogle
Beta Was this translation helpful? Give feedback.
All reactions