Compare commits

..
Author SHA1 Message Date
qaiu d57c708869 fix: isolate server-side donation credentials and rotate auth defaults 2026-12-04 02:51:14 +08:00
4 changed files with 2 additions and 145 deletions

No files matched your search

-1
View File
@@ -1,6 +1,5 @@
## v0.4.15
- 浏览器与服务端以相同的 UTF-8 密钥字节处理临时认证,兼容 16、24 和 32 字节的密钥。
- 临时认证不再使用发行包里的公共密钥。未手动配置的服务实例每次启动生成随机密钥,只记录来源和指纹。保留旧发行包配置的实例也会自动迁移。
- 捐赠池默认关闭。显式启用后,受支持的网盘使用服务端选号,不再向前端提供捐赠账号。已保存的捐赠记录不会删除。
- 清理网页和文档中的公共密钥。需要网页个人认证、外部客户端或多实例共享密钥的自建站,须显式配置和安全分发 `server.authEncryptKey`。
-107
View File
@@ -1,107 +0,0 @@
[English](#security-policy) | [简体中文](#安全政策)
# Security Policy
Thank you for helping keep netdisk-fast-download (NFD) and its users safe.
## Supported Versions
Security fixes are provided for the latest stable release. Older releases are not actively maintained and generally do not receive security backports. Users are strongly encouraged to upgrade to the latest stable release.
| Version | Supported |
| --- | --- |
| Latest stable release | ✅ |
| Older releases | ❌ |
## Reporting a Vulnerability
Please report suspected security vulnerabilities privately through [GitHub Private Vulnerability Reporting](https://github.com/qaiu/netdisk-fast-download/security/advisories/new). Do not disclose unpatched vulnerabilities in public Issues, Pull Requests, Discussions, or other public channels.
Please include the following information where possible:
- Affected version or commit
- Vulnerability description, affected component, and potential impact
- Reproduction steps or a minimal proof of concept
- Relevant configuration, logs, and deployment details, with sensitive information redacted
Do not include real credentials, authentication keys, API tokens, or personal data in your report. Test only systems you own or are authorized to test.
## Scope
This policy applies to security vulnerabilities in the official NFD project, including authentication, authorization, credential handling, and other security-sensitive functionality.
Ordinary bugs, upstream API changes, and compatibility issues without a security impact should be reported through [GitHub Issues](https://github.com/qaiu/netdisk-fast-download/issues). Issues caused solely by third-party services, unofficial modifications, or unsafe deployment configurations are generally outside the scope of this policy. However, vulnerabilities in NFD's default configuration or its handling of third-party services remain in scope.
## Security Response and Disclosure
Security reports are handled on a best-effort basis, taking into account severity, impact, and maintainer availability. We aim to assess reports, develop appropriate fixes or mitigations, and coordinate public disclosure with reporters where possible. No fixed response or remediation timeframe is guaranteed.
## Security Best Practices
- Keep NFD and its dependencies up to date.
- Use HTTPS and restrict access to sensitive administrative interfaces.
- Protect authentication keys, API tokens, and cloud-drive credentials; never expose them in public logs, frontend bundles, or diagnostic reports.
- Enable only the services and optional features you need.
- Revoke or rotate potentially compromised credentials promptly.
## Security Advisories
For published vulnerabilities, affected versions, fixes, and mitigation guidance, see [GitHub Security Advisories](https://github.com/qaiu/netdisk-fast-download/security/advisories) and [Release Notes](https://github.com/qaiu/netdisk-fast-download/releases).
## Acknowledgments
We appreciate everyone who responsibly reports vulnerabilities and helps improve the security of NFD.
---
# 安全政策
感谢你帮助维护 netdisk-fast-download(NFD)及其用户的安全。
## 支持的版本
安全修复面向最新稳定版本。历史版本不再主动维护,原则上不提供安全补丁回移。强烈建议用户及时升级至最新稳定版本。
| 版本 | 是否支持 |
| --- | --- |
| 最新稳定版 | ✅ |
| 历史版本 | ❌ |
## 漏洞报告
请通过 [GitHub 私密漏洞报告](https://github.com/qaiu/netdisk-fast-download/security/advisories/new) 渠道提交疑似安全漏洞。请勿在公开 Issue、Pull Request、Discussion 或其他公开渠道披露尚未修复的漏洞。
请尽可能提供以下信息:
- 受影响的版本或提交
- 漏洞描述、受影响组件及潜在影响
- 复现步骤或最小概念验证
- 相关配置、日志及部署信息(请先脱敏)
请勿在报告中包含真实账号凭据、认证密钥、API 令牌或个人数据。请仅在自己拥有或已获得授权的环境中进行安全测试。
## 适用范围
本政策适用于 NFD 官方项目中的安全漏洞,包括身份认证、访问控制、凭据处理及其他涉及安全的功能。
不涉及安全影响的普通缺陷、上游接口变更及兼容性问题,请通过 [GitHub Issues](https://github.com/qaiu/netdisk-fast-download/issues) 反馈。仅由第三方服务、非官方修改或不安全部署配置引起的问题,原则上不属于本政策的适用范围。但 NFD 默认配置或第三方服务处理逻辑中存在的安全漏洞仍在适用范围内。
## 安全响应与披露
维护者将根据漏洞严重程度、影响范围及可用时间尽力处理安全报告,包括漏洞评估、制定修复或缓解措施,并尽可能与报告人协调公开披露。不承诺固定的响应或修复时限。
## 安全最佳实践
- 及时更新 NFD 及其依赖组件。
- 使用 HTTPS,并限制敏感管理接口的访问权限。
- 妥善保管认证密钥、API 令牌及网盘凭据,切勿通过公开日志、前端构建产物或诊断报告泄露。
- 仅启用实际需要的服务及可选功能。
- 及时撤销或轮换可能泄露的凭据。
## 安全公告
已公开的漏洞、影响版本、修复及缓解措施,请参阅 [GitHub 安全公告](https://github.com/qaiu/netdisk-fast-download/security/advisories) 和 [版本发布说明](https://github.com/qaiu/netdisk-fast-download/releases)。
## 致谢
感谢所有负责任地报告漏洞并帮助提升 NFD 安全性的研究人员与社区成员。
@@ -7,7 +7,6 @@ import io.vertx.core.json.JsonObject;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import javax.crypto.spec.SecretKeySpec;
import java.net.URLDecoder;
import java.nio.charset.StandardCharsets;
import java.security.MessageDigest;
@@ -72,11 +71,6 @@ public class AuthParamCodec {
}
}
private static SecretKeySpec asAesKey(String key) {
// Match CryptoJS: AES key lengths and values are defined by the full UTF-8 bytes.
return new SecretKeySpec(key.getBytes(StandardCharsets.UTF_8), "AES");
}
public static String getEncryptKey() {
return encryptKey;
}
@@ -118,7 +112,7 @@ public class AuthParamCodec {
log.debug("Base64解码成功,长度: {}", base64Decoded.length);
// Step 3: AES解密
String jsonStr = AESUtils.decryptByAES(base64Decoded, asAesKey(key));
String jsonStr = AESUtils.decryptByAES(base64Decoded, key);
// Step 4: JSON解析
JsonObject json = new JsonObject(jsonStr);
@@ -162,7 +156,7 @@ public class AuthParamCodec {
String jsonStr = authParam.toJsonObject().encode();
// Step 2: AES加密 + Base64编码
String base64Encoded = AESUtils.encryptBase64ByAES(jsonStr, asAesKey(key));
String base64Encoded = AESUtils.encryptBase64ByAES(jsonStr, key);
// Step 3: URL编码
String urlEncoded = java.net.URLEncoder.encode(base64Encoded, StandardCharsets.UTF_8);
@@ -5,8 +5,6 @@ import cn.qaiu.util.AESUtils;
import io.vertx.core.json.JsonObject;
import org.junit.Test;
import javax.crypto.Cipher;
import javax.crypto.spec.SecretKeySpec;
import java.net.URLDecoder;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
@@ -44,33 +42,6 @@ public class AuthParamCodecTest {
AuthParamCodec.decode(AuthParamCodec.encode(auth, key), key).getToken());
}
@Test
public void interoperatesWithBrowserCryptoJsUsingFullUtf8Key() throws Exception {
// CryptoJS 4.2.0: AES-ECB/PKCS7, Utf8.parse(key),
// plaintext {"authType":"token","token":"synthetic-认证"}.
String[][] browserVectors = {
{"0123456789abcdef", "VxQ8JVsWso0Fhf76r82AjtWhuqKaDUtBWPUJcD+Oc1lGwDq001J2N8LJH3RSFBcA"},
{"0123456789abcdefghijklmn", "kCYuDyekW7KZf8rlLqIR0Rcwp7QWcFYn5X6tsGd6XUqlGf9RoJyFzogOgU26JJNS"},
{"0123456789abcdefghijklmnopqrstuv", "FB94nNibPhLIh+oMcnJW0Iuu3O3xSPK0WVHXCiwnvbblwSfe++oPk3RZmw6/7OqX"},
{"密钥测试甲乙丙丁", "cg0YzgNOQxws0chQxDOnepm1Ht+Pkgo7Am9McLXjkUcC35QcRiyHELm0/g4WQm2e"}
};
for (String[] vector : browserVectors) {
String key = vector[0];
AuthParam decoded = AuthParamCodec.decode(URLEncoder.encode(vector[1], StandardCharsets.UTF_8), key);
assertNotNull("browser ciphertext should decode with " + key.getBytes(StandardCharsets.UTF_8).length + "-byte key", decoded);
assertEquals("token", decoded.getAuthType());
assertEquals("synthetic-认证", decoded.getToken());
String encoded = AuthParamCodec.encode(decoded, key);
assertNotNull(encoded);
Cipher peer = Cipher.getInstance("AES/ECB/PKCS5Padding");
peer.init(Cipher.DECRYPT_MODE, new SecretKeySpec(key.getBytes(StandardCharsets.UTF_8), "AES"));
String base64 = URLDecoder.decode(encoded, StandardCharsets.UTF_8);
JsonObject plaintext = new JsonObject(new String(peer.doFinal(Base64.getDecoder().decode(base64)), StandardCharsets.UTF_8));
assertEquals("synthetic-认证", plaintext.getString("token"));
}
}
@Test
public void donatedAccountsRequireExplicitOptInAndDatabase() {
JsonObject server = new JsonObject().put("enableDatabase", true);