T09 · Insecure Skill Coding Practices
Warning
- Location
- scripts/batch_create.py:153
- Finding
- Notion API Token Can Be Exposed Through Command-Line Arguments<![CDATA[ ## Vulnerability Details **File Location**: `scripts/batch_create.py`, lines 153-171 **Vulnerability Type**: Sensitive credential exposure through process arguments and shell history **Risk Level**: Medium ### Complete Code Snippet ```python def main(): parser = argparse.ArgumentParser(description='Batch create Notion database entries from CSV.') parser.add_argument('--api-token', help='Notion API token') parser.add_argument('--database-id', required=True, help='Notion database ID') parser.add_argument('--csv', required=True, help='CSV file to import') parser.add_argument('--title-column', required=True, help='Column name for page title') parser.add_argument('--title-property', default='Name', help='Property name for title in Notion') # Schema mapping should be in a separate JSON file parser.add_argument('--schema', required=True, help='JSON file with CSV column -> Notion property mapping') args = parser.parse_args() with open(args.schema, 'r') as f: schema = json.load(f) api_token = args.api_token or os.environ.get('NOTION_API_TOKEN') if not api_token: raise ValueError("API token required via --api-token or NOTION_API_TOKEN environment variable") ``` ### Technical Analysis The CLI accepts a Notion bearer token through `--api-token`. Command-line arguments can be exposed through: - Process inspection facilities such as `ps`, `/proc/<pid>/cmdline`, or system monitoring software. - Shell history files when a user enters the token directly in a command. - CI/CD job logs, command tracing, terminal recordings, and process audit logs. - Diagnostic output collected by orchestration or endpoint-management systems. The token is subsequently placed in the `Authorization` header by `NotionDBClient`. Sending it to the fixed HTTPS endpoint `https://api.notion.com/v1` is necessary for the declared functionality; the security issue is the optional command-line credential transpo ...[truncated 1328 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Remove the `--api-token` argument from both `scripts/batch_create.py` and `scripts/export_csv.py`. 2. Prefer a dedicated secret manager or the documented OpenClaw secret facility. 3. If environment variables remain supported, document that they should be injected by the runtime rather than placed inline in a shell command. 4. Optionally support interactive entry through `getpass.getpass()` for local use. 5. Never print, serialize, or include the token in exception messages. 6. Configure the Notion integration with access only to the specific databases required by the workflow. 7. Rotate any token that has previously been passed through command-line arguments or exposed in CI logs. 8. Add credential-redaction rules to CI/CD and process-monitoring systems. ]]>
