diff --git a/ui/actions/scans/scans.ts b/ui/actions/scans/scans.ts index 80505b3ca1..d6c996fee0 100644 --- a/ui/actions/scans/scans.ts +++ b/ui/actions/scans/scans.ts @@ -278,6 +278,13 @@ export const getComplianceCsv = async ( scanId: string, complianceId: string, ) => { + // Only allow alphanumeric, dash, and underscore for IDs + const idPattern = /^[a-zA-Z0-9_-]+$/; + if (!idPattern.test(scanId) || !idPattern.test(complianceId)) { + return { + error: "Invalid scan or compliance ID format.", + }; + } const headers = await getAuthHeaders({ contentType: false }); const url = new URL(