mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-02-04 15:10:06 +00:00
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:
@@ -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}`)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user