T09 · Insecure Skill Coding Practices
- Location
scripts/tesla-smart-charge.py:184- Finding
Shell Command Injection in the Automatic Charging Path
- Content
View full analysis
- Remediation
View remediation
Security audit
Security checks for vulnerabilities and agentic risk
The skill has a coherent Tesla charging purpose, but it needs review because it automates live Tesla account actions and contains a real shell-command injection issue despite claiming that risk is absent.
Review this before installing. Only use it if you are comfortable with unattended Tesla account commands changing charge limits or starting charging. Pin and verify the tesla dependency, fix the shell=True auto-start command, pass only required environment variables, and avoid enabling cron or --auto-start until those issues are addressed.
scripts/tesla-smart-charge.py:184Shell Command Injection in the Automatic Charging Path
README.txt:14Unpinned Executable Tesla Skill Dependency
scripts/tesla-smart-charge.py:102Insufficient Validation of Schedule and Numeric Inputs
Code enumerates, copies, or searches environment variables for secrets. Bulk environment access can collect credentials unrelated to the skill's stated purpose.
return None
# Use Tesla skill to get status - use list args to avoid shell injection
env = os.environ.copy()
env['TESLA_EMAIL'] = self.tesla_email
output = subprocess.check_output(
['python3', str(self.tesla_skill_dir / 'scripts' / 'tesla.py'), 'status'],
Code enumerates, copies, or searches environment variables for secrets. Bulk environment access can collect credentials unrelated to the skill's stated purpose.
return None
# Use Tesla skill to get status - use list args to avoid shell injection
env = os.environ.copy()
env['TESLA_EMAIL'] = self.tesla_email
output = subprocess.check_output(
['python3', str(self.tesla_skill_dir / 'scripts' / 'tesla.py'), 'status'],
This is a concrete tool-parameter abuse vector because the script passes attacker-influenced data into a shell command that invokes a privileged external tool capable of controlling charging. In this skill context, successful exploitation could lead both to arbitrary command execution on the host and unauthorized execution of a vehicle action.
def start_charging(self):
"""Trigger charging on the vehicle"""
try:
subprocess.run(
f'TESLA_EMAIL="{self.tesla_email}" python3 {self.tesla_skill_dir}/scripts/tesla.py charge start',
shell=True,
check=True,
The README instructs users to set up unattended cron jobs that will automatically modify Tesla charging behavior and charge limits, but it does not clearly warn that these actions change live vehicle settings on a recurring basis. In a vehicle-control context, missing disclosure increases the chance of unintended operational changes, battery wear, unexpected charging costs, or charging at the wrong times if the schedule or environment is misconfigured.
The skill clearly automates live changes to a Tesla vehicle's charging behavior, including scheduled charge initiation logic and charge-limit changes, but the documentation does not prominently warn users that these actions affect a real vehicle account on an ongoing cron basis. This can lead to unintended or poorly understood vehicle state changes, especially if users copy-paste the cron setup without appreciating that the automation will continue making account-backed changes after initial setup.
The document instructs users to set up unattended scheduled execution that can trigger real-world Tesla charging actions, but it does not include a clear warning or consent boundary about autonomous device control. In the context of a vehicle-control skill, normalizing silent daily execution increases the chance of unintended charging behavior, cost impacts, or unsafe automation if configuration is wrong or the environment is shared.
The cron setup creates persistent background automation that continues running after initial user interaction, which is a form of session persistence. In a skill that can affect a physical device, persistence is more sensitive because the action may recur without fresh user intent, and the task string embeds account-identifying context that may be reused indefinitely.
Create a cron job that runs at midnight and checks if a charge is scheduled:
clawdbot cron add \
The top-level description frames the tool as a scheduler/optimizer, but the implementation can directly start charging. This mismatch can mislead a reviewer or operator into granting the skill more trust or autonomy than intended, increasing the chance of unsafe execution of real-world actions.
subprocess module calls execute external commands. Without careful input validation, this enables command injection.
# Use Tesla skill to get status - use list args to avoid shell injection
env = os.environ.copy()
env['TESLA_EMAIL'] = self.tesla_email
output = subprocess.check_output(
['python3', str(self.tesla_skill_dir / 'scripts' / 'tesla.py'), 'status'],
stderr=subprocess.DEVNULL,
text=True,
subprocess module calls execute external commands. Without careful input validation, this enables command injection.
# Use Tesla skill - use list args to avoid shell injection
env = os.environ.copy()
env['TESLA_EMAIL'] = self.tesla_email
result = subprocess.run(
['python3', str(self.tesla_skill_dir / 'scripts' / 'tesla.py'),
'charge-limit', str(limit_percent)],
capture_output=True,
This call constructs a shell command with an f-string and executes it with shell=True while interpolating self.tesla_email and a filesystem path directly into the command line. An attacker who can influence TESLA_EMAIL or the path could break out of quoting and execute arbitrary commands, making this a real command injection issue in a script that can also control a vehicle-related action.
def start_charging(self):
"""Trigger charging on the vehicle"""
try:
subprocess.run(
f'TESLA_EMAIL="{self.tesla_email}" python3 {self.tesla_skill_dir}/scripts/tesla.py charge start',
shell=True,
check=True,
The script can trigger charging automatically when --auto-start is supplied and timing conditions are met, without an additional runtime confirmation or prominent warning. In a vehicle-control context, that creates a real safety and operational risk because an automated run may perform a physical-world action the user did not intend at that moment.
No suspicious patterns detected.