clmBot Runtime Permission Requirements
When performing automatic certificate renewal, clmBot needs read and write access to the target certificate files, and will reload or restart the corresponding middleware service after the update. This document describes the recommended minimum permission configuration for various middleware scenarios.
Middleware reload / restart commands are defined in the servers[].after_script field of config.yaml, and users can adjust them according to the actual environment. clmBot does not require long-term operation under high-privilege accounts such as root or Administrator.
Principle of Least Privilege
It is recommended to use a dedicated system account (such as clmbot) to run clmBot, and follow these principles:
- Only grant this account the permissions required to read clmBot configuration, log directories, and target certificate installation points.
- Only grant write permissions to certificate files, private key files managed by clmBot, and their parent directories.
- Only allow execution of verified middleware reload / restart commands, and do not grant
NOPASSWD: ALLor full root privileges. before_scriptandafter_scriptmust be manually audited, and permissions required in scripts should be granted item by item.
Not recommended practices:
- Allow clmBot to run persistently as the
rootorAdministratoridentity. - Grant clmBot full access to the middleware configuration directory, certificate directory, or system service control permissions.
- Assign unrestricted execution permissions to
bash,powershell.exe, andsystemctl.
Permission Requirements for Each Middleware
nginx
clmBot requires the following permissions:
- Read and write permissions for the certificate directory: Read and write access to the directory where the target certificate file (
.crt), CA chain file (optional), and private key file (.key) are located, to allow writing new certificates and creating.bakbackups. - Execute the reload command:
after_scriptgenerates the following script by default to reload nginx after certificate renewal:
nginx -t && nginx -s reload
Least privilege recommendations:
- Only grant access to the target certificate directory, and do not grant read/write permissions to the entire
/etc/nginx. - Precisely authorize
nginx -tandnginx -s reloadthrough sudoers, and do not grant a full root shell.
Apache HTTP Server
clmBot requires the following permissions:
- Certificate directory read/write permissions: Read and write permissions for the directories where
SSLCertificateFile,SSLCertificateChainFile, andSSLCertificateKeyFileare located. - Permission to execute service restart commands:
after_scriptgenerates one of the following scripts by default (depending on the distribution):
systemctl restart httpd.service
systemctl restart apache2.service
Minimum authorization recommendations:
- Only grant access to the target certificate directory, and do not grant permissions to the entire Apache configuration directory.
- Through sudoers, grant
restartpermission only to the Apache service name actually in use on the current system.
Tomcat
clmBot requires the following permissions:
- Read and write permissions for the certificate directory: Read and write permissions for the directory where PEM certificate/private key files or JKS keystore files are located.
- Permission to execute stop and start scripts:
after_scriptgenerates the following scripts by default:
export JAVA_HOME="<java_home>" && "<catalina_base>/bin/shutdown.sh" && "<catalina_base>/bin/startup.sh"
Least privilege recommendations:
- Prioritize placing clmBot and Tomcat in the same business group, and only grant read/write permissions to the target keystore or certificate directory.
- Only allow execution of
shutdown.shandstartup.shfor the corresponding Tomcat instance; do not grant permissions to the entire/optdirectory. - In multi-instance Tomcat environments, split authorizations by instance.
IIS
IIS scenarios rely on Windows PowerShell scripts to import PFX files and update HTTPS bindings, and require administrator privileges.
clmBot requires the following permissions:
- Run under an administrator account: Execute
powershell.exe -NoProfile -ExecutionPolicy Bypassto import the temporary PFX and update IIS site bindings. - Read/write permissions for the certificate directory: For the creation and cleanup of temporary PFX files.
Least privilege recommendations:
- Use a dedicated Windows service account, and only grant the permissions required to manage target IIS site bindings.
- PowerShell execution policies and module permissions should be audited separately according to the host security baseline.
Linux sudoers Configuration Example
The following examples only demonstrate the authorization granularity; adjust the actual paths according to the target host.
nginx:
clmbot ALL=(root) NOPASSWD: /usr/sbin/nginx -t
clmbot ALL=(root) NOPASSWD: /usr/sbin/nginx -s reload
Apache:
clmbot ALL=(root) NOPASSWD: /bin/systemctl restart apache2.service
Tomcat:
clmbot ALL=(tomcat) NOPASSWD: /opt/apache-tomcat/bin/shutdown.sh
clmbot ALL=(tomcat) NOPASSWD: /opt/apache-tomcat/bin/startup.sh
Example of certificate directory permissions:
chown -R root:clmbot /etc/ssl/example
chmod 0750 /etc/ssl/example
chmod 0640 /etc/ssl/example/site.crt /etc/ssl/example/ca.crt
chmod 0640 /etc/ssl/example/site.key
To allow clmBot to write to and back up the above files, you can grant precise permissions using ACL:
setfacl -m u:clmbot:rwx /etc/ssl/example
setfacl -m u:clmbot:rw- /etc/ssl/example/site.crt
setfacl -m u:clmbot:rw- /etc/ssl/example/ca.crt
setfacl -m u:clmbot:rw- /etc/ssl/example/site.key
Pre-launch Permission Checklist
Before deploying clmBot, it is recommended to verify the following permission configurations one by one.
- Whether clmBot runs under a dedicated account, rather than
rootor an administrator account. - Whether read and write access to
config.yamlis restricted to only necessary accounts. - Whether the certificate files referenced by each
servers[].formathave only the required read and write permissions enabled. - Whether the directory where certificate files are located allows the creation and cleanup of
.bakbackup files. - Whether
before_scriptandafter_scripthave been manually audited. - Verify that sudoers only contains exact commands, rather than
ALL,bashor the fullsystemctl. - Check whether the reload or restart permissions for nginx / Apache / Tomcat only cover the target instance.
- Confirm that the listening address and port for the service mode (
clm-bot server) comply with the host firewall policy.