T06 · System Persistence
Error
- Location
- package.json:6
- Finding
- Package Installation Automatically Registers a Persistent Scheduled Agent Task<![CDATA[ ## Vulnerability Details **File Location**: `package.json:6-8`; `scripts/install.sh:353-393` **Vulnerability Type**: Persistent scheduled execution without a separate enablement decision **Risk Level**: High ### Vulnerable Code ```json "scripts": { "test": "./test/run-tests.sh", "install": "./scripts/install.sh", "start": "./scripts/enable.sh", "stop": "./scripts/disable.sh", "status": "./scripts/status.sh", "health": "./scripts/health.sh" } ``` ```bash # Set up cron job setup_cron_job() { log "Setting up cron job..." # Check if openclaw command is available if command -v openclaw &> /dev/null; then log "Creating OpenClaw cron job..." # Create cron job via OpenClaw API cron_job=$(cat << 'EOF' { "name": "Memory Compression System", "schedule": { "kind": "every", "everyMs": 21600000 }, "sessionTarget": "isolated", "payload": { "kind": "agentTurn", "message": "Run Memory Compression System: cd /home/node/.openclaw/workspace/skills/memory-compression-system && ./scripts/compress.sh --auto", "timeoutSeconds": 300 }, "delivery": { "mode": "announce" } } EOF ) # Try to create the cron job if openclaw cron add --json "$cron_job" &> /dev/null; then success "OpenClaw cron job created" else warning "Failed to create OpenClaw cron job (may need manual setup)" fi else warning "openclaw command not found, skipping cron setup" log "Manual cron setup required. Add to crontab:" log "0 */6 * * * cd $SKILL_DIR && ./scripts/compress.sh --auto" fi success "Cron setup completed" } ``` ### Technical Analysis The package defines `scripts/install.sh` as its npm `install` lifecycle command. Consequently, an ordinary `npm install` can execute the full installation script. That script invokes `setup_cron_job`, which registers an OpenClaw scheduled task that laun ...[truncated 2481 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Remove the npm `install` lifecycle entry or replace it with a non-mutating validation step: ```json "scripts": { "setup": "./scripts/install.sh", "start": "./scripts/enable.sh" } ``` 2. Remove `setup_cron_job` from the installation workflow. Installation should only create necessary local files and directories. 3. Register the scheduled task exclusively through an explicit `scripts/enable.sh` command. 4. Before registration, display: - The exact command that will execute. - The six-hour execution frequency. - The memory directory that will be read. - The data, backup, and log directories that will be written. - The cleanup and retention behavior. 5. Require explicit interactive confirmation, with a separate documented non-interactive flag for controlled deployments. 6. Capture and securely store the exact job ID returned by `openclaw cron add`, so later removal does not depend on text matching. 7. Make installation idempotent and verify that no duplicate tasks exist before adding a new one. ]]>
