T09 · Insecure Skill Coding Practices
- Location
sth_video_generator.py:84- Finding
SQL Injection Through Unparameterized Database Queries
- Content
View full analysis
Optional[Dict[str, str]]: """Fetch template data from song_templates table.""" query = f"SELECT image_url, generate_video_prompt, song_type_id FROM song_templates WHERE id = '{template_id}';" result = run_psql(query) ``` ```python def get_audio_mix_url(song_type_id: str) -> Optional[str]: """Fetch audio mix URL from song_types table.""" query = f"SELECT amix_url FROM song_types WHERE id = '{song_type_id}';" result = run_psql(query) return result if result else None ``` ```python def update_template_urls(template_id: str, video_url: str) -> bool: """Update the song_templates table with video URLs.""" query = f"""UPDATE song_templates SET video_url = '{video_url}', video_url_seedream_v4 = '{video_url}' WHERE id = '{template_id}';""" result = run_psql(query) return result is not None ``` Additional confirmed locations include: - `sth_video_generator_parallel.py:167` - `sth_video_generator_parallel.py:190` - `sth_video_generator_parallel.py:436-438` - `scripts/batch_processor.py:53,63` - `scripts/check_csv_over_12s.py:62,71,80` - `scripts/filter_over_12s.py:62,71` - `scripts/filter_templates.py:60,69` - `scripts/rerun_over_12s.py:62,87,96,105,114,137` - `scripts/resume_filtered_12s.py:54,59` ### Technical Analysis The code builds SQL statements by directly interpolating values into quoted SQL literals. The `template_id` value comes from a user-supplied CSV file. Other interpolated values come from database records or the external MCP service. The resulting query is pas ...[truncated 2127 chars]- Remediation
View remediation
