T09 · Insecure Skill Coding Practices
- Location
scripts/sync.py:521- Finding
API Token Can Be Exposed Through Command-Line Arguments
- Content
View full analysis
Vulnerability Details
File Location:
scripts/sync.py:521-534; insecure usage is also documented atSKILL.md:43-44
Vulnerability Type: Secret exposure through process arguments and shell history
Risk Level: MediumVulnerable Code:
python parser.add_argument("--token", "-t", help="WaniKani API token (or set WANIKANI_API_TOKEN env var)") parser.add_argument("--data-dir", "-d", help="Directory to store data (default: current directory)") parser.add_argument("--full", "-f", action="store_true", help="Force full sync (ignore last sync time)") parser.add_argument("--user-only", action="store_true", help="Sync only user data") parser.add_argument("--assignments-only", action="store_true", help="Sync only assignments") parser.add_argument("--reviews-only", action="store_true", help="Sync only reviews") parser.add_argument("--subjects-only", action="store_true", help="Sync only subjects") parser.add_argument("--with-subjects", action="store_true", help="Include subjects in full sync") parser.add_argument("--subject-levels", help="Comma-separated levels to sync subjects (e.g., 1,2,3)") parser.add_argument("--stats", "-s", action="store_true", help="Show stats after sync") args = parser.parse_args() token = args.token or os.environ.get("WANIKANI_API_TOKEN")The documented invocation is:
bash python3 scripts/sync.py --token "your-token-here"Technical Analysis
Secrets supplied as command-line arguments may be recorded in interactive shell history, terminal logs, process-accounting systems, diagnostic reports, or automation logs. Depending on operating-system configuration, another local user may also be able to inspect process arguments while the command is running.
The token is legitimately required to authenticate to the WaniKani API, and the implementation sends it only to the fixed official HTTPS endpoint. However, accepting the token through a command-line option is not n ...[truncated 1092 chars]
- Remediation
View remediation
Remediation Suggestions
- Remove the
--tokenand-tcommand-line options. - Continue supporting
WANIKANI_API_TOKENfor controlled execution environments. - For interactive use, obtain the token with
getpass.getpass()so it is not echoed or stored in shell history. - Consider integration with an operating-system credential store or keyring for recurring use.
- Update
SKILL.mdto remove the literal command-line token example. - Avoid printing, logging, serializing, or including the token in exception messages.
- Recommend narrowly scoped, read-only WaniKani tokens where supported, and advise users to revoke tokens suspected of exposure.
- Remove the
