mirror of
https://gitee.com/spark-store-project/spark-store
synced 2026-09-20 21:50:11 +08:00
fix: 安全加固——queue-install 路径遍历校验 + 首页远程数据显式字段
针对 PR 安全审查的修复:
1. queue-install 路径遍历(阻断项,真实风险):
install-manager.ts 直接用渲染进程传入的 pkgname 拼装下载目录
/tmp/spark-store/download/ 与 ssinstall 命令参数 /,
此前未做任何校验。复用模块顶部 PKGNAME_PATTERN 对 pkgname 与 filename 做白名单校验,
拦截含 ../、/ 或非法字符的输入,杜绝路径遍历。
2. 首页远程数据展开(阻断项,纵深防御):
App.vue loadHome 此前用 { ...l } 直接展开远程 homelinks.json 到响应式数组,
可能注入未知属性。改为显式提取 name/url/icon/more/imgUrl/type/origin 已知字段构造,
仅保留可信字段(url 仍做必需校验以保首页正常渲染)。
注:check-installed 白名单(审查第1项)此前已在 4f772ba7 通过 parseAppPayload 修复,本次无改动。
vue-tsc --noEmit 通过。
This commit is contained in:
+7
-3
@@ -1380,13 +1380,17 @@ const loadHome = async () => {
|
||||
if (!url) continue;
|
||||
const icon = (l.Icon as string) || (l.icon as string) || "";
|
||||
seenNames.add(name);
|
||||
homeLinks.value.push({
|
||||
...l,
|
||||
// 显式提取已知字段构造,避免通过展开运算符 { ...l } 把远程不可信数据中的未知属性注入响应式状态
|
||||
const safeLink: HomeLink = {
|
||||
name,
|
||||
url,
|
||||
icon,
|
||||
more: (l.more as string) || undefined,
|
||||
imgUrl: (l.imgUrl as string) || undefined,
|
||||
type: (l.type as string) || undefined,
|
||||
origin: mode,
|
||||
} as HomeLink);
|
||||
};
|
||||
homeLinks.value.push(safeLink);
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
|
||||
Reference in New Issue
Block a user