T09 · Insecure Skill Coding Practices
- Location
prompts/feishu_private_chat.md:18- Finding
Insecure OAuth Redirect and Plaintext Credential Storage
- Content
View full analysis
Vulnerability Details
File Location:
prompts/feishu_private_chat.md:18-33;tools/feishu_auto_collector.py:34-58,67-82
Vulnerability Type: Insecure OAuth configuration and sensitive credential handling
Risk Level: HighVulnerable Code
prompts/feishu_private_chat.md:text https://open.feishu.cn/open-apis/authen/v1/authorize?app_id={APP_ID}&redirect_uri=http://www.example.com&scope=im:message%20im:chattools/feishu_auto_collector.py:python def setup_credentials(): """Setup Feishu credentials interactively.""" config_dir = os.path.expanduser('~/.create-leader') os.makedirs(config_dir, exist_ok=True) config_path = os.path.join(config_dir, 'feishu_config.json') print("=== Feishu Credential Setup ===\n") print("Please enter your Feishu app credentials:") print("(Get these from Feishu Open Platform: https://open.feishu.cn)") app_id = input("App ID: ").strip() app_secret = input("App Secret: ").strip() redirect_uri = input("Redirect URI (default: http://www.example.com): ").strip() if not redirect_uri: redirect_uri = 'http://www.example.com' config = { 'app_id': app_id, 'app_secret': app_secret, 'redirect_uri': redirect_uri, 'created_at': datetime.utcnow().isoformat() + 'Z' } with open(config_path, 'w') as f: json.dump(config, f, indent=2)python def exchange_code_for_token(code): """Exchange OAuth code for user access token.""" config_dir = os.path.expanduser('~/.create-leader') config_path = os.path.join(config_dir, 'feishu_config.json') if not os.path.exists(config_path): print("Error: Config not found. Run with --setup first.", file=sys.stderr) sys.exit(1) with open(config_path, 'r') as f: config = json.load(f) print("=== OAuth Token Exchange ===\n") print("No ...[truncated 2054 chars]- Remediation
View remediation
Remediation Suggestions
- Replace the external HTTP callback with a user-controlled HTTPS endpoint or a loopback callback such as
http://127.0.0.1where supported. - Require an exact, pre-registered redirect URI and validate it before constructing an authorization URL.
- Use OAuth state and PKCE where supported to reduce authorization-code interception risk.
- Read secrets with
getpass.getpass()instead of visible terminal input. - Create the credential directory with mode
0700and the configuration file atomically with mode0600. - Prefer an operating-system keyring or dedicated secret manager over plaintext JSON storage.
- Never print authorization codes, access tokens, refresh tokens, or application secrets.
- Avoid accepting tokens and authorization codes as command-line arguments because process listings and shell history may expose them.
- Document credential rotation and secure cleanup procedures.
- Replace the external HTTP callback with a user-controlled HTTPS endpoint or a loopback callback such as
