T09 · Insecure Skill Coding Practices
- Location
scripts/self-healing-agent.py:235- Finding
Non-Atomic In-Place Repair Can Corrupt the OpenClaw Configuration
- Content
View full analysis
- Remediation
View remediation
Security audit
Security checks for vulnerabilities and agentic risk
This self-healing skill is understandable for its purpose, but it can repeatedly change OpenClaw config, memory, sessions, and cron behavior without enough user control or rollback safeguards.
Install only if you are comfortable with a tool that can automatically modify OpenClaw files and run repair actions. Prefer dry-run/check mode first, avoid continuous monitor mode until paths and repair behavior are reviewed, and keep backups of ~/.openclaw/openclaw.json, memory, and sessions.
scripts/self-healing-agent.py:235Non-Atomic In-Place Repair Can Corrupt the OpenClaw Configuration
scripts/self-healing-agent.py:168Fixed Backup Name and Non-Atomic Truncation Can Cause Irrecoverable Memory Loss
scripts/self-healing-agent.py:288Session Check Captures an Unnecessarily Broad Host Process Listing
The skill advertises operational behaviors that imply shell execution and file read/write capability, but it does not declare any explicit tool scope or permissions boundary. For a self-healing skill that can restart jobs, edit configs, restore files, and monitor continuously, missing scope is dangerous because it obscures the blast radius and could let an agent invoke powerful actions without clear least-privilege constraints or user review.
The skill explicitly describes autonomous repair actions such as restarting cron jobs, fixing config files, restoring files from git history, killing processes, rotating logs, and switching endpoints, yet it does not provide a prominent warning about system-impacting changes or require human approval. In the context of a self-healing agent, this is especially risky because automation is continuous and could amplify mistakes, causing service disruption, data loss, config corruption, or unsafe recovery loops across the host environment.
subprocess module calls execute external commands. Without careful input validation, this enables command injection.
issues = []
try:
result = subprocess.run(
['openclaw', 'cron', 'list', '--json'],
capture_output=True, text=True, timeout=15
)
subprocess module calls execute external commands. Without careful input validation, this enables command injection.
def make_fix(job_id=job.get('id')):
def fix():
try:
r = subprocess.run(
['openclaw', 'cron', 'run', job_id],
capture_output=True, text=True, timeout=30
)
The auto-heal routine silently archives and truncates memory files, changing user data without confirmation. Even though intended as maintenance, unattended modification can destroy context, interfere with other tools, and be abused in a failure scenario to erase forensic evidence or important operational history.
Automatically rewriting a primary configuration file based on a regex heuristic is dangerous because malformed edits can corrupt settings, change behavior unexpectedly, or make recovery harder. Since this runs as a repair action, users may not notice that a critical config was altered until service behavior changes or additional failures occur.
The script automatically moves session files once they cross a size threshold, which can abruptly disrupt active workflows and remove data from expected locations without consent. In a continuous monitor context, this can cause denial of service to legitimate sessions and hamper incident reconstruction.
subprocess module calls execute external commands. Without careful input validation, this enables command injection.
# Check for zombie processes
try:
result = subprocess.run(
['ps', 'aux'], capture_output=True, text=True, timeout=5
)
if result.returncode == 0:
subprocess module calls execute external commands. Without careful input validation, this enables command injection.
if os.path.isdir(scripts_dir):
for py_file in glob.glob(os.path.join(scripts_dir, "*.py")):
try:
result = subprocess.run(
['python3', '-m', 'py_compile', py_file],
capture_output=True, text=True, timeout=10
)
The skill performs outbound network checks to third-party services unrelated to local self-repair, expanding its trust boundary and creating unnecessary external signaling. In some environments this can leak usage patterns, violate network isolation expectations, or trigger unintended egress from a supposedly local maintenance tool.
subprocess module calls execute external commands. Without careful input validation, this enables command injection.
for url, name in endpoints:
try:
result = subprocess.run(
['curl', '-s', '-o', '/dev/null', '-w', '%{http_code}', '--max-time', '5', url],
capture_output=True, text=True, timeout=10
)
Monitor mode continuously performs auto-healing actions, including file rewrites and session moves, without an explicit safety warning or approval step. This turns a diagnostic tool into an autonomous mutator, increasing the blast radius of false positives, logic errors, or adversarially induced states because changes recur repeatedly over time.
The stated purpose is OpenClaw agent health monitoring and repair. Running ps aux inspects the host's global process table, which is a broader system-observation capability not clearly justified by the manifest's agent-scoped failure modes and is not tied to identifying OpenClaw-specific processes.
No suspicious patterns detected.