This domain management application uses a secure file-based approach that eliminates the need for exec() permissions or subprocess calls on production servers.
- Zero subprocess calls - No use of
subprocess
,os.system()
, orexec()
- File operations only - All domain management through direct file manipulation
- No shell access - Application cannot execute system commands
- Domain name validation - Strict regex patterns prevent injection
- Path traversal protection - Blocks
../
and invalid path components - Character filtering - Only allows valid domain characters
- Sandboxed operations - Only operates within designated nginx directories
- Symlink validation - Safe creation of nginx site links
- Permission checks - Validates file access before operations
- Validate domain name - Check format and security rules
- Generate nginx config - Create configuration file content
- Write configuration - Save to
/etc/nginx/sites-available/
- Create symlink - Link to
/etc/nginx/sites-enabled/
- Return manual steps - Provide commands for admin to run
- Prepare configuration - Add
.well-known
location blocks - Update nginx files - File-based configuration updates
- Return manual steps - Provide SSL installation commands
- Read certificate info - Parse existing certificate files
Since we don't execute commands for security, certain operations require manual execution:
sudo nginx -t
sudo systemctl reload nginx
sudo certbot --nginx -d domain.com -d www.domain.com
# OR
sudo ~/.acme.sh/acme.sh --issue -d domain.com -d www.domain.com --webroot /var/www/letsencrypt
sudo nginx -t
sudo systemctl reload nginx
- No privilege escalation - Application runs with minimal permissions
- No command injection - Impossible since no commands are executed
- Audit trail - All operations are file-based and logged
- Fail-safe - Cannot break system even if exploited
- Compliance - Meets strict security requirements
- Read access to
/etc/nginx/sites-available/
- Write access to
/etc/nginx/sites-available/
- Read/write access to
/etc/nginx/sites-enabled/
- Read access to SSL certificate directories
- sudo permissions
- exec() capabilities
- shell access
- process spawning
The application provides the exact commands needed but requires manual execution for:
- Nginx configuration testing
- Nginx service reloading
- SSL certificate installation
- Certificate renewal
This design ensures maximum security while providing a user-friendly interface for domain management.