T09 · Insecure Skill Coding Practices
Warning
- Location
- scripts/imap_scan.py:167
- Finding
- Mailbox Credentials Exposed Through Command-Line Arguments<![CDATA[ ## Vulnerability Details **File Location**: `scripts/imap_scan.py:167-177`; invocation documented at `SKILL.md:70-76` **Vulnerability Type**: Credential exposure through process arguments **Risk Level**: Medium ### Vulnerable Code ```python def main(): parser = argparse.ArgumentParser(description="IMAP Registration Scanner") parser.add_argument("--host", required=True) parser.add_argument("--port", type=int, default=993) parser.add_argument("--user", required=True) parser.add_argument("--password", required=True) parser.add_argument("--output", required=True) parser.add_argument("--no-ssl", action="store_true") ``` The documented invocation explicitly places the secret in the command line: ```bash python3 "{baseDir}/scripts/imap_scan.py" \ --host "imap.mail.me.com" \ --port 993 \ --user "user@icloud.com" \ --password "app-specific-password" \ --output "/tmp/registration_scan_results.json" ``` ### Technical Analysis The script requires the mailbox password to be supplied through `--password`. Command-line arguments can be exposed through process inspection facilities, local monitoring or telemetry tools, shell history, debugging output, and orchestration logs. Although the script does not explicitly print the password, placing it in the process argument vector conflicts with the documented assertion that credentials are never logged or stored. The risk is especially significant where the provider guide permits use of a regular mailbox password instead of a narrowly scoped app password. ### Attack Path 1. A user or Agent launches the scanner using the documented command. 2. The mailbox password becomes part of the process argument vector. 3. A same-user monitoring process, privileged local process, execution wrapper, or logging system records or inspects the command. 4. The observer extracts the password before the process terminates or retrieves it from retained logs or shell history. 5. The attacker authen ...[truncated 604 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions - Remove the `--password` command-line option. - Retrieve credentials directly from OpenClaw’s Secret Store where available. - For interactive use, read the password with `getpass.getpass()` so it is neither echoed nor placed in the argument vector. - For automated use, accept the secret through a protected inherited file descriptor or another platform-supported secret channel. - Avoid ordinary environment variables where possible because they may also be exposed through process inspection and diagnostic dumps. - Update `SKILL.md` so examples never contain a password argument. - Require app-specific, revocable, least-privilege credentials and clearly warn against regular account passwords. - Clear in-memory references to credentials as soon as authentication is complete, acknowledging that Python cannot guarantee secure memory erasure. ]]>
