T09 · Insecure Skill Coding Practices
- Location
scripts/lib/auth_mgr.py:49- Finding
TradingView authentication tokens are stored and accepted through insecure channels
- Content
View full analysis
Vulnerability Details
File Location:
scripts/lib/auth_mgr.py:49-65,scripts/lib/auth_mgr.py:132-133
Vulnerability Type: Plaintext credential storage and command-line secret exposure
Risk Level: HighVulnerable Code
python def cmd_set(token: str) -> int: """Save token to ~/.tvfetch/.env""" # Validate first valid, reason = validate_token(token) if not valid: print(f"WARNING: Token validation issue: {reason}") print("Saving anyway — token may still work if TV accepts it.") # Ensure directory exists DEFAULT_TVFETCH_DIR.mkdir(parents=True, exist_ok=True) # Read existing env file, update or add TV_AUTH_TOKEN existing = _load_env_file(DEFAULT_ENV_PATH) existing["TV_AUTH_TOKEN"] = token lines = [f"{k}={v}" for k, v in existing.items()] DEFAULT_ENV_PATH.write_text("\n".join(lines) + "\n", encoding="utf-8") print(f"Token saved to {DEFAULT_ENV_PATH}") print(f"Token preview: {token[:30]}...") print(f"Validation: {reason}") return 0python set_p = sub.add_parser("set", help="Save token") set_p.add_argument("token", help="JWT token string")Technical Analysis
The token manager writes the TradingView JWT to
~/.tvfetch/.envwithout explicitly enforcing restrictive permissions on either the directory or file.Path.mkdir()andPath.write_text()rely on the process umask, so the resulting credential file may be readable by other local users in permissively configured environments.The token is also accepted as a positional command-line argument. Command-line secrets can be exposed through:
- Shell history files
- Process inspection tools while the command is running
- Agent execution logs and terminal transcripts
- Monitoring, telemetry, or audit systems that record process arguments
The command also prints the first 30 characters of the token. Although this is not the complete ...[truncated 1070 chars]
- Remediation
View remediation
Remediation Suggestions
- Prefer system keyring storage rather than plaintext files.
- Accept tokens through hidden interactive input using
getpass.getpass()or standard input, not process arguments. - Create
~/.tvfetchwith mode0700. - Create the credential file atomically with mode
0600, using flags that reject symlink traversal and prevent overwriting unexpected files. - Verify ownership and permissions before reading an existing credential file.
- Remove or substantially shorten token previews; display only a fixed masked suffix if identification is necessary.
- Update documentation to warn users not to place tokens directly in shell commands.
- Provide token deletion and rotation instructions.
