T09 · Insecure Skill Coding Practices
Warning
- Location
- scripts/coda_cli.py:403
- Finding
- API Token Exposure Through Command-Line Arguments<![CDATA[ ## Vulnerability Details **File Location**: `scripts/coda_cli.py`, lines 50–60, 403, and 544 **Vulnerability Type**: Sensitive credential exposure through process arguments **Risk Level**: Medium ### Vulnerable Code ```python def __init__(self, token: Optional[str] = None): self.token = token or os.environ.get("CODA_API_TOKEN") if not self.token: raise CodaAPIError( "Coda API token required. Set CODA_API_TOKEN environment variable " "or pass --token." ) if HAS_REQUESTS: self.session = requests.Session() self.session.headers.update({ "Authorization": f"Bearer {self.token}", "Content-Type": "application/json" }) ``` ```python parser.add_argument("--token", help="Coda API token") ``` ```python client = CodaClient(token=args.token) ``` ### Technical Analysis The CLI explicitly permits a Coda API token to be supplied using the `--token` command-line option. Command-line arguments are commonly exposed through: - Shell history files - Process inspection tools such as `ps` - Process accounting and operating-system audit logs - CI/CD execution logs - Terminal recordings and support diagnostics - Parent-process telemetry or endpoint-monitoring products The token is subsequently used as a Bearer credential for the Coda API. Although transmitting that credential to the fixed official HTTPS endpoint is necessary for the declared functionality, accepting it through a command-line argument creates unnecessary local exposure. The documented `CODA_API_TOKEN` environment-variable mechanism already provides an alternative, so the command-line credential path exceeds the minimum interface required. ### Attack Path 1. A user invokes the tool with a command such as: ```bash python scripts/coda_cli.py --token SECRET docs list ``` 2. The complete command is retained in shell history, captured in automation logs, or temporarily exposed through the process ...[truncated 963 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Remove the `--token` argument and accept credentials only through `CODA_API_TOKEN` or a protected credential provider. 2. For interactive use, retrieve the token with `getpass.getpass()` so it is not echoed or recorded in shell history. 3. Consider operating-system credential stores or a configuration file with owner-only permissions. 4. If backward compatibility requires `--token`, display a prominent security warning and deprecate the option. 5. Ensure CI/CD systems inject the token through masked secret variables and do not print the environment. 6. Recommend narrowly scoped or dedicated Coda credentials where the platform supports them. 7. Document immediate token revocation and rotation procedures for suspected exposure. ]]>
