T09 · Insecure Skill Coding Practices
- Location
scripts/main.py:436- Finding
AppleScript Injection Through Unescaped Message, Recipient, and File Path Parameters
- Content
View full analysis
- Remediation
View remediation
Security audit
Security checks for vulnerabilities and agentic risk
The skill is mostly coherent with its iMessage purpose, but it exposes sensitive Messages access and remote-control/message-sending paths with real safety weaknesses.
Install only if you are comfortable granting a skill access to your local Messages database and the ability to send iMessages. Keep remote control disabled unless you have reviewed the code, avoid adding broad admin contacts, do not rely on force=true, and prefer a version with escaped AppleScript arguments, replay protection, pinned npx usage, and stronger warnings before enabling remote command handling.
scripts/main.py:436AppleScript Injection Through Unescaped Message, Recipient, and File Path Parameters
scripts/main.py:425Caller-Controlled Force Flag Bypasses Message Authorization and Rate Limits
scripts/main.py:586Previously Processed iMessage Commands Are Re-executed on Every Poll
scripts/main.py:390Unpinned Package Execution Through npx Creates Supply-Chain Exposure
Incoming messages can cause local subprocess execution (openclaw status, npx clawhub list) through the control-command path. This gives remote message senders an execution-trigger capability on the host that is not necessary for ordinary messaging and could be abused for reconnaissance, automation, or as a stepping stone if adjacent controls are weak.
The skill processes inbound iMessages and can automatically execute control commands and send replies, which is significantly broader than simple messaging functionality. Even with admin and allowlist checks, this creates a remote command channel into the host application based on message content, increasing the risk of abuse, misconfiguration, or unauthorized control if trust assumptions fail.
The README advertises sending messages, viewing recent messages, and listing contacts, but does not warn users that the skill accesses privacy-sensitive communications and contact data. Without clear disclosure, users may grant Messages/accessibility permissions without understanding the scope of data exposure, increasing the chance of unintended collection, transmission, or misuse of personal information. The context makes this more concerning because iMessage content and contacts are highly sensitive and the skill explicitly enables read/send operations.
The README instructs users to run npx clawhub install imessage without pinning a specific package version. This creates a supply-chain risk because users may fetch a newly published or compromised package version at install time, and npx executes remote package code in the local environment. In a skill that can access Messages and requires accessibility permissions, compromise of the installer path is more dangerous because the resulting code may gain access to sensitive communications.
The file presents all operational and safety instructions in Chinese, including setup, warnings, and usage examples, but does not indicate that language selection is optional or that the skill is intended only for a Chinese-speaking or region-specific audience. This can violate a language/locale policy when users are not given an opt-in or alternative locale.
The installation instruction uses npx clawhub install imessage without pinning an exact package version, so users may fetch whatever version is current at install time. For a skill that can access Messages, send messages, and potentially enable remote control, an unexpected upstream package change or supply-chain compromise could materially change behavior at install or execution time.
The documentation asserts strong remote-control protections via whitelist/blacklist enforcement, but the documented flow does not actually demonstrate that these checks are complete or correctly ordered, and blacklists are especially weak as a security boundary. In a skill whose stated feature is controlling OpenClaw via incoming iMessage, overstated safety guarantees can lead operators to enable a capability that permits unauthorized or overly broad command execution.
The module description presents the skill as a secured messaging integration, but the implementation also supports host control and command execution. This mismatch can mislead users or reviewers about the true capability set, making risky behavior easier to enable without informed consent.
subprocess module calls execute external commands. Without careful input validation, this enables command injection.
def _cmd_status(self) -> dict:
"""获取 OpenClaw 状态"""
try:
result = subprocess.run(
['openclaw', 'status'],
capture_output=True,
text=True,
subprocess module calls execute external commands. Without careful input validation, this enables command injection.
def _cmd_list(self) -> dict:
"""列出 skills"""
try:
result = subprocess.run(
['npx', 'clawhub', 'list'],
capture_output=True,
text=True,
The code interpolates untrusted phone and message values directly into AppleScript source and executes it via osascript. An attacker who can influence those fields can break out of the quoted AppleScript strings and inject arbitrary AppleScript, potentially causing unintended local actions under the user's context.
end tell
'''
result = subprocess.run(
['osascript', '-e', applescript],
capture_output=True,
text=True,
image_path and phone are embedded directly into AppleScript and then executed, creating an injection sink similar to the message-sending path. If a crafted value contains quotes or AppleScript syntax, it can alter script logic and execute unintended actions on the host.
end tell
'''
result = subprocess.run(
['osascript', '-e', applescript],
capture_output=True,
text=True,
Inbound messages can trigger automatic replies, including command results and permission errors, with no interactive warning or approval. This can leak host information to remote senders, confirm the system is active, and create unanticipated message-sending behavior that the local user did not explicitly authorize each time.
Remote control can be enabled programmatically with no strong user-facing warning about the consequences of processing incoming messages as commands. This weak consent model makes it easy for a user or higher-level automation to activate a risky feature without appreciating that message-triggered execution and auto-replies will occur.
The trigger patterns are broad generic phrases such as 'iMessage', '发消息', and 'send message', which are likely to match ordinary conversation or unrelated user requests. Because this skill exposes an exec-capable entry point and can interact with Messages on macOS, accidental invocation could lead to unintended message access or message-sending flows.
The primary descriptive text is presented in Chinese, while the rest of the surrounding ecosystem cues are otherwise generic and do not state that the skill is intended only for Chinese-speaking users or a China-specific deployment. This creates a language/locale constraint without user opt-in or documented justification.
The natural-language metadata presented to users is written in Chinese, including the description and usage note, with no indication that other languages are supported or that the locale is intentionally restricted. This can violate language/locale policy when users are not given a language choice or explicit justification for the constraint.
No suspicious patterns detected.