T09 · Insecure Skill Coding Practices
- Location
scripts/main.py:9- Finding
HIPC API Secret Exposed Through Command-Line Arguments and Plaintext Storage
- Content
View full analysis
Vulnerability Details
File Location:
SKILL.md:73;scripts/main.py:9-10, 21-23, 66, 84-96
Vulnerability Type: Plaintext sensitive-data storage and insecure credential input
Risk Level: MediumThe skill accepts an HIPC API secret as a command-line argument and stores it unencrypted in
~/hipc_config.json. The implementation does not explicitly enforce owner-only permissions on that file.Relevant code from
SKILL.md:73:bash python scripts/main.py --action={{action}}{{#if secret}} --secret={{secret}}{{/if}}{{#if env}} --env={{env}}{{/if}}Relevant code from
scripts/main.py:9-10:python BASE_DIR = os.path.expanduser("~") CONFIG_FILE = os.path.join(BASE_DIR, "hipc_config.json")Relevant code from
scripts/main.py:21-23:python def write_config(data): with open(CONFIG_FILE, 'w', encoding='utf-8') as f: json.dump(data, f, indent=4, ensure_ascii=False)Relevant code from
scripts/main.py:66:python config['hipc_secret'] = secretRelevant code from
scripts/main.py:84-96:python parser = argparse.ArgumentParser() parser.add_argument('--action', type=str, required=True, choices=['check', 'set']) parser.add_argument('--secret', type=str, required=False) parser.add_argument('--env', type=str, required=False,default='prod', choices=['dev', 'prod']) args = parser.parse_args() if args.action == 'check': check_action() elif args.action == 'set': if not args.secret: print(json.dumps({"status": "error", "message": "缺少 secret 参数"})) sys.exit(1) set_action(args.secret,args.env)Technical Analysis
Secrets supplied through command-line arguments can become visible through process inspection facilities, command histories, orchestration metadata, diagnostic tooling, and process-execution logs. Although operating-system controls may restrict access to process arguments, ...[truncated 1999 chars]
- Remediation
View remediation
Remediation Suggestions
- Do not accept secrets through command-line arguments. Read the secret from protected standard input using
getpass.getpass(), a restricted file descriptor, or an operating-system credential API. - Prefer an OS-managed keychain or secret manager rather than storing the credential in a JSON file.
- If file storage is unavoidable, create the file with owner-only permissions such as
0600, and verify its owner and mode before every read and write. - Write configuration atomically by creating a protected temporary file in the same directory, flushing and synchronizing it, setting the correct permissions, and atomically replacing the destination.
- Reject symbolic links and unexpected file types when reading or replacing the configuration file.
- Separate non-sensitive settings such as the API hostname from the secret so ordinary configuration backups do not automatically contain credentials.
- Ensure logs and error reports never include the supplied secret, and advise users to rotate any credential previously passed through exposed command histories or logging systems.
- Do not accept secrets through command-line arguments. Read the secret from protected standard input using
