T06 · System Persistence
Error
- Location
- SYSTEMD_SETUP.md:45
- Finding
- Persistent Autonomous Trading Service and Scheduled Restart<![CDATA[ ## Vulnerability Details **File Location**: `SYSTEMD_SETUP.md:45-87`, `SYSTEMD_SETUP.md:108-117`, `SYSTEMD_SETUP.md:523-542` **Vulnerability Type**: Boot-time service registration, automatic process recovery, and privileged scheduled execution **Risk Level**: High ### Vulnerable Code ```ini [Unit] Description=Crypto Executor v2.3 PRODUCTION READY - Autonomous Trading Bot Documentation=https://github.com/georges91560/crypto-executor After=network-online.target Wants=network-online.target [Service] Type=simple User=your_username Group=your_username WorkingDirectory=/workspace/skills/crypto-executor EnvironmentFile=/etc/crypto-executor/credentials.env ExecStart=/usr/bin/python3 /workspace/skills/crypto-executor/executor.py Restart=on-failure RestartSec=10 StartLimitInterval=200 StartLimitBurst=5 NoNewPrivileges=true PrivateTmp=true StandardOutput=journal StandardError=journal SyslogIdentifier=crypto-executor MemoryMax=2G CPUQuota=200% [Install] WantedBy=multi-user.target ``` ```bash sudo systemctl daemon-reload sudo systemctl enable crypto-executor ``` ```bash sudo cp /etc/systemd/system/crypto-executor.service \ /etc/systemd/system/crypto-executor-conservative.service sudo systemctl daemon-reload sudo systemctl enable crypto-executor-conservative sudo systemctl start crypto-executor-conservative sudo crontab -e 0 2 * * 0 systemctl restart crypto-executor ``` ### Technical Analysis The instructions establish cross-session persistence through three mechanisms: 1. `WantedBy=multi-user.target` and `systemctl enable` start the trading program automatically after reboot. 2. `Restart=on-failure` repeatedly relaunches it after crashes. 3. A root crontab periodically restarts the service. Continuous execution is consistent with the declared 24/7 autonomous-trading purpose, and the persistence is disclosed rather than covert. Nevertheless, it substantially increases security impact because the persistent process receives Binance trading cr ...[truncated 1840 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Do not enable boot persistence automatically; require explicit, informed operator approval. 2. Remove the redundant root cron restart. Use systemd supervision alone. 3. Run the bot under a dedicated unprivileged account with no login shell and no membership in privileged groups. 4. Ensure only root can modify the executable, dependency, service unit, and credential file. 5. Pin and verify the exact executor and oracle versions before enabling the service. 6. Add stronger systemd restrictions, for example: ```ini NoNewPrivileges=true ProtectSystem=strict ProtectHome=true PrivateDevices=true ProtectKernelTunables=true ProtectKernelModules=true ProtectControlGroups=true RestrictSUIDSGID=true LockPersonality=true ReadWritePaths=/workspace/reports /workspace/config_history RestrictAddressFamilies=AF_INET AF_INET6 ``` 7. Avoid multiple instances sharing the same credentials and state files. If multiple instances are required, give each separate API keys, limits, working directories, and state files. 8. Document complete removal procedures: ```bash sudo systemctl disable --now crypto-executor sudo systemctl disable --now crypto-executor-conservative sudo rm /etc/systemd/system/crypto-executor*.service sudo systemctl daemon-reload sudo crontab -e # remove the scheduled restart ``` 9. Configure Binance keys with withdrawals disabled, strict IP allowlisting, and the narrowest available trading permissions. ]]>
