🔒 增强安全防护:防止 SSRF 攻击和 Token 泄露
后端安全增强: - 新增 SSRF 防护机制,验证 SFTP 目标地址 - 添加 isPrivateIp() 函数,检测并阻止连接内网地址 - 添加 validateSftpDestination() 函数,验证主机名和端口 - 支持 DNS 解析和 IP 地址验证 - 添加 SFTP 连接超时配置(默认8秒) - 移除 URL 参数中的 token 认证,只接受 Header 或 HttpOnly Cookie 前端安全改进: - 移除下载链接中的 token 参数 - 改为依赖同域 Cookie 进行身份验证 - 避免 token 在 URL 中暴露,防止日志泄露 环境变量配置: - ALLOW_PRIVATE_SFTP=true 可允许连接内网(测试环境) - SFTP_CONNECT_TIMEOUT 可配置连接超时时间 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -921,9 +921,9 @@ handleDragLeave(e) {
|
||||
? `/${file.name}`
|
||||
: `${this.currentPath}/${file.name}`;
|
||||
|
||||
// 使用<a>标签下载,通过URL参数传递token
|
||||
// 使用<a>标签下载,依赖同域 Cookie/凭证
|
||||
const link = document.createElement('a');
|
||||
link.href = `${this.apiBase}/api/files/download?path=${encodeURIComponent(filePath)}&token=${this.token}`;
|
||||
link.href = `${this.apiBase}/api/files/download?path=${encodeURIComponent(filePath)}`;
|
||||
link.setAttribute('download', file.name);
|
||||
document.body.appendChild(link);
|
||||
link.click();
|
||||
@@ -1143,8 +1143,8 @@ handleDragLeave(e) {
|
||||
return file.httpDownloadUrl;
|
||||
}
|
||||
|
||||
// 本地存储或未配置HTTP URL,使用API下载
|
||||
return `${this.apiBase}/api/files/download?path=${encodeURIComponent(filePath)}&token=${this.token}`;
|
||||
// 本地存储或未配置HTTP URL,使用API下载(同域 Cookie 验证)
|
||||
return `${this.apiBase}/api/files/download?path=${encodeURIComponent(filePath)}`;
|
||||
},
|
||||
|
||||
// 获取文件缩略图URL
|
||||
@@ -1242,7 +1242,7 @@ handleDragLeave(e) {
|
||||
|
||||
// 使用<a>标签下载,通过URL参数传递token,浏览器会显示下载进度
|
||||
const link = document.createElement('a');
|
||||
link.href = `${this.apiBase}/api/upload/download-tool?token=${this.token}`;
|
||||
link.href = `${this.apiBase}/api/upload/download-tool`;
|
||||
link.setAttribute('download', `玩玩云上传工具_${this.user.username}.zip`);
|
||||
document.body.appendChild(link);
|
||||
link.click();
|
||||
|
||||
Reference in New Issue
Block a user