T09 · Insecure Skill Coding Practices
- Location
scripts/feishu_voice_sender.py:24- Finding
Arbitrary Readable File Upload Due to Missing Audio Validation
- Content
View full analysis
str: """Upload a file and return its file_key.""" filename = os.path.basename(file_path) url = "https://open.feishu.cn/open-apis/im/v1/files" boundary = "----FeishuBoundary" with open(file_path, "rb") as f: content = f.read() ``` The caller-controlled path reaches the upload operation without content or path validation: ```python parser.add_argument("--file", "-f", required=True, help="Audio file path") parser.add_argument( "--receive-id", "-r", default=get_receive_id_from_env(), help="Recipient open_id" ) args = parser.parse_args() if not args.receive_id: print( "Error: specify --receive-id or set OPENCLAW_CHAT_ID", file=sys.stderr ) sys.exit(1) if not os.path.exists(args.file): print(f"Error: file does not exist: {args.file}", file=sys.stderr) sys.exit(1) print("Reading Feishu configuration...") feishu_config = read_openclaw_config() print("Obtaining access token...") token = get_tenant_token( feishu_config["app_id"], feishu_config["app_secret"] ) print(f"Uploading audio file: {args.file}") file_key = upload_file(token, args.file) print("Sending voice message...") message_id = send_audio_message(token, args.receive_id, file_key) ``` ### Technical Analysis The Skill is declared as an audio-message sender, but it accepts any existing filesystem path. It does not verify that the path: - Resolves to a regular file. - Is located in an approved directory. - Has an allowed size. - Contains valid audio data. - Uses an allowed audio codec or container. - Does not resolve through a symbolic link into a sensitive location. The existence check does not provide a security boundary. `open(file_path, "rb")` ...[truncated 2278 chars]- Remediation
View remediation
