Commit Graph

25 Commits

Author SHA1 Message Date
Flody.lee
59a357f76f fix(security): harden command injection, path traversal, auth surfaces
Audit of the backend attack surface and fixes for the web-reachable
CRITICAL/HIGH issues. Adds back/shared/security.ts with centralized
hardening helpers (shellEscape, assertSafeDependenceName,
SUBSCRIPTION_PATTERNS, safeCompare, isSafeSshConfigValue).

- Subscription fields (url/branch/whitelist/blacklist/extensions/proxy)
  are now shell-escaped before reaching spawn() and validated with strict
  Joi patterns at the API, closing OS command injection and the
  downstream shell eval/git-arg-injection paths.
- Dependency names are validated before interpolation into
  pnpm/pip/apk/apt commands (incl. the embedded Python source).
- SSH config generation rejects newline/metachar injection in host/proxy
  (prevents injected ProxyCommand execution).
- ConfigService.getFile resolves the real path before containment check,
  fixing data/scripts/../db traversal that leaked the SQLite DB.
- /configs/save containment check fixed (sibling-dir write bypass).
- Script/env uploads use path.basename, preventing arbitrary file write
  (crontab.list/env.sh overwrite -> RCE) via multer originalname.
- JWT secret is generated and persisted per-install instead of the public
  default 'whyour-secret'; production refuses to boot without one.
- Token comparison is now constant-time (safeCompare).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-22 11:22:15 +08:00
whyour
7d8feadc78 修复获取定时任务参数 2026-06-13 00:09:31 +08:00
Copilot
d473c3ae88
Fix SSH global private key matching before subscription-specific keys (#2845)
* Initial plan

* Fix SSH global private key loading order by using zzz_ prefix

Co-authored-by: whyour <22700758+whyour@users.noreply.github.com>

* Use tilde (~) prefix for global SSH config to ensure it loads last

Co-authored-by: whyour <22700758+whyour@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: whyour <22700758+whyour@users.noreply.github.com>
2025-11-21 01:53:58 +08:00
Copilot
ee2fbe5335
Add global SSH key configuration in system settings (#2840)
* Initial plan

* Add backend support for global SSH keys

Co-authored-by: whyour <22700758+whyour@users.noreply.github.com>

* Add frontend UI for global SSH keys management

Co-authored-by: whyour <22700758+whyour@users.noreply.github.com>

* Add SshKeyModel to database initialization

Co-authored-by: whyour <22700758+whyour@users.noreply.github.com>

* Add SSH config generation for global SSH keys

Co-authored-by: whyour <22700758+whyour@users.noreply.github.com>

* Add internationalization support for SSH key management UI

Co-authored-by: whyour <22700758+whyour@users.noreply.github.com>

* Simplify to single global SSH key in system settings

Co-authored-by: whyour <22700758+whyour@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: whyour <22700758+whyour@users.noreply.github.com>
2025-11-20 10:09:01 +08:00
whyour
07951964a1 修复模块注入 2025-10-26 22:32:03 +08:00
whyour
05f8bbd26e 写入文件增加文件锁,避免竞争条件引起文件内容异常 2025-01-04 01:22:29 +08:00
whyour
20f615eadf fs 文件操作替换为 fs.promise 2023-11-01 16:44:34 +08:00
whyour
4d5fa320ea 修改私有仓库 ssh 配置 2023-08-23 18:06:28 +08:00
whyour
ca150dc6a6 修复 docker-compose 配置 2023-05-22 20:20:46 +08:00
whyour
4a0c66bcc0 修复初始化 ssh 配置文件不存在 2023-04-15 12:14:56 +08:00
whyour
1d2df860e8 修复 ssh 配置文件目录 2023-04-06 14:23:02 +08:00
whyour
b27ee23cc3 重构私有仓库ssh配置逻辑 2023-04-06 13:38:55 +08:00
whyour
7bce5c4f6a 任务增加关联订阅 2023-02-13 23:50:01 +08:00
whyour
1f7f2c8971 修复订阅生成 ssh 配置逻辑,自动添加/删除任务 2023-02-13 23:12:55 +08:00
whyour
a9cc1cb4b9 修改token获取逻辑 2022-12-10 17:12:45 +08:00
whyour
91dbb7770d 修改订阅github ssh生成逻辑 2022-11-14 22:00:16 +08:00
whyour
0a6166c557 订阅增加代理参数 2022-11-13 23:58:42 +08:00
whyour
ff2b4e0b2f 订阅支持添加代理 2022-11-12 22:45:46 +08:00
whyour
5a01c41bbb 修复私钥配置文件匹配 2022-06-01 00:03:58 +08:00
whyour
460a1750f4 增加初始化订阅任务 2022-05-18 23:30:59 +08:00
whyour
d2c2ea8d3b 修改生成ssh配置 2022-05-18 20:10:28 +08:00
whyour
cb12d8ffec 修复删除私钥 2022-05-18 20:06:46 +08:00
whyour
5bb1afe5c6 修复私钥权限 2022-05-18 19:23:32 +08:00
whyour
fb6a80e306 支持更换头像 2022-05-09 15:31:41 +08:00
whyour
2c9b283b75 增加ssh key操作service 2022-05-08 22:41:56 +08:00