T09 · Insecure Skill Coding Practices
- Location
scripts/social_matrix.py:529- Finding
API Key Exposed Through Command-Line Arguments
- Content
View full analysis
Vulnerability Details
File Location:
scripts/social_matrix.py:529-533
Additional Location:SKILL.md:142
Vulnerability Type: API credential exposure through process arguments and shell history
Risk Level: MediumVulnerable Code
python save = commands.add_parser("auth", help="保存 AI Hive API Key") save.add_argument("--api-key", required=True) save.set_defaults(handler=auth)The documented invocation explicitly places the credential in a command-line argument:
bash python3 "$SKILL_PATH/scripts/social_matrix.py" auth --api-key sk-api-你的密钥Technical Analysis
The authentication command requires users to provide the complete AI Hive API key through
--api-key. Command-line arguments are not an appropriate secret-entry mechanism because they may be exposed through:- Shell history files.
- Process inspection utilities while the command is running.
- Terminal session recording.
- Endpoint monitoring and command telemetry.
- Wrapper scripts or job logs that capture complete command lines.
Although the program subsequently writes the key to a file with mode
0600, that protection does not prevent exposure before or during command execution. The issue affects the documented first-use workflow and the implementedauthparser.Attack Path
- A user follows the documented setup command and supplies a valid API key using
--api-key. - The shell records the complete command in its history, or a local monitoring mechanism captures the process arguments.
- An attacker with access to the same account, shell-history backup, process telemetry, or applicable local process information retrieves the key.
- The attacker submits requests to AI Hive using the stolen bearer credential.
- The requests consume the victim's API quota and access any API capabilities authorized for that key.
Impact Assessment
Successful exploitation exposes the AI Hive API credential. The attacker obtains the same API-level privileges gra ...[truncated 326 chars]
- Remediation
View remediation
Remediation Suggestions
- Replace command-line secret entry with an interactive hidden prompt using
getpass.getpass():
python from getpass import getpass save = commands.add_parser("auth", help="Save the AI Hive API key") save.set_defaults(handler=auth) def auth(args): api_key = getpass("AI Hive API key: ") # Validate and store api_key securely.- If non-interactive automation is required, accept the key through standard input or a protected secret file rather than a command-line argument.
- Continue enforcing file permissions of
0600and create the configuration file atomically with restrictive permissions from the outset. - Remove the literal
--api-keyworkflow fromSKILL.mdand document the hidden-input method. - Advise existing users to remove affected commands from shell history and rotate any key previously entered on the command line.
- Avoid printing, logging, or including the credential in exception messages and diagnostic telemetry.
- Replace command-line secret entry with an interactive hidden prompt using
