fix: validate logo index entries before building URLs

Guard against path traversal and unexpected file types by
validating logo paths start with 'logo/', have allowed image
extensions, and contain no '..' or leading '/' segments.

Amp-Thread-ID: https://ampcode.com/threads/T-019c083e-8ba0-7699-a5ff-63fd03e24391
Co-authored-by: Amp <amp@ampcode.com>
This commit is contained in:
Subagent 5
2026-01-28 21:44:15 -08:00
parent 019262bc02
commit 85a7d19769

View File

@@ -515,7 +515,15 @@ export const useWorkflowTemplatesStore = defineStore(
function getLogoUrl(provider: string): string {
const logoPath = logoIndex.value[provider]
if (!logoPath) return ''
if (
!logoPath ||
logoPath.includes('..') ||
logoPath.startsWith('/') ||
!logoPath.startsWith('logo/') ||
!/\.(png|svg|jpg|jpeg)$/i.test(logoPath)
) {
return ''
}
return api.fileURL(`/templates/${logoPath}`)
}