T09 · Insecure Skill Coding Practices
- Location
SKILL.md:15- Finding
API Token File May Be Created with Overly Permissive Permissions
- Content
View full analysis
Vulnerability Details
File Location:
SKILL.md:15-18;README.md:13-16;scripts/generate_image.py:33,38-41;scripts/edit_image.py:24,45-49
Vulnerability Type: Insecure local credential storage
Risk Level: MediumVulnerable Code
SKILL.md:15-18andREADME.md:13-16instruct users to store the token as follows:bash echo "sk-your-token" > ~/.laozhang_api_tokenscripts/generate_image.py:33,38-41:python DEFAULT_TOKEN_PATH = Path.home() / ".laozhang_api_token" def get_api_token(): """Get API token from file""" if DEFAULT_TOKEN_PATH.exists(): return DEFAULT_TOKEN_PATH.read_text().strip() return Nonescripts/edit_image.py:24,45-49:python DEFAULT_TOKEN_PATH = Path.home() / ".laozhang_api_token" def get_api_token(): """Get API token from file""" if DEFAULT_TOKEN_PATH.exists(): return DEFAULT_TOKEN_PATH.read_text().strip() return NoneTechnical Analysis
Shell redirection creates
~/.laozhang_api_tokenaccording to the user's currentumask. With a commonumaskof022, the file may be created with mode0644, making it readable by other local users. Neither script verifies the file owner or rejects group-readable or world-readable permissions before loading the credential.The alternative
--tokenoption also places the token in the process command line. Depending on the operating system and process-monitoring configuration, command-line arguments may be observable by other users, monitoring agents, shell history, or diagnostic tooling.The token is intentionally transmitted as a bearer credential to
https://api.laozhang.ai/v1/chat/completions; that transmission is required for the declared functionality and occurs over HTTPS. The weakness is the local storage and handling of the credential, not the disclosed API request itself.Attack Path
- A user follows the documented command t ...[truncated 941 chars]
- Remediation
View remediation
Remediation Suggestions
-
Replace the documented redirection command with permission-safe creation:
bash install -m 600 /dev/null "$HOME/.laozhang_api_token" printf '%s\n' "sk-your-token" > "$HOME/.laozhang_api_token" chmod 600 "$HOME/.laozhang_api_token" -
Before reading the file, verify that it is a regular file, is owned by the current user, and has no group or other permission bits:
python import os import stat def get_api_token(): path = DEFAULT_TOKEN_PATH if not path.is_file(): return None info = path.stat() if info.st_uid != os.getuid(): raise PermissionError("Token file is not owned by the current user") if stat.S_IMODE(info.st_mode) & 0o077: raise PermissionError("Token file must have permissions 0600") return path.read_text(encoding="utf-8").strip() -
Prefer an operating-system credential manager or a protected environment-variable injection mechanism.
-
Discourage
--tokenfor routine use because process arguments and shell history can expose credentials. -
Document token rotation and revocation procedures in case the credential is exposed.
-
