Summary
In src/media-understanding/apply.ts, the sanitizeMimeType function's regex is not anchored at the end, which could allow malicious suffixes. Additionally, MIME types are case-insensitive per RFC standards.
Impact
Severity: Medium (8/10)
Type: Security - Input validation
Current Behavior
const trimmed = value.trim().toLowerCase();
const match = trimmed.match(/^([a-z0-9!#$&^_.+-]+\/[a-z0-9!#$&^_.+-]+)/);
return match?.[1];
Suggested Fix
const trimmed = value.trim();
const match = trimmed.match(/^([a-z0-9!#$&^_.+-]+\/[a-z0-9!#$&^_.+-]+)(?:;.*)?$/i);
return match?.[1].toLowerCase();
This:
- Anchors the regex at the end (
$)
- Makes it case-insensitive (
/i)
- Handles optional parameters (
(?:;.*)?)
Source
Identified by Qodo AI code review.
Files Affected
src/media-understanding/apply.ts (lines 96-106)
Summary
In
src/media-understanding/apply.ts, thesanitizeMimeTypefunction's regex is not anchored at the end, which could allow malicious suffixes. Additionally, MIME types are case-insensitive per RFC standards.Impact
Severity: Medium (8/10)
Type: Security - Input validation
Current Behavior
Suggested Fix
This:
$)/i)(?:;.*)?)Source
Identified by Qodo AI code review.
Files Affected
src/media-understanding/apply.ts(lines 96-106)