Repository navigation
Conversation
/authorize 接受任意 redirect_uri 且 /token 不校验客户端。攻击者可把授权码 引到自己站点,再用该 code 换 new-api 会话,以点开链接的员工身份登录。 改为精确白名单(默认 nginx 日志里两个真实客户端),新增纯函数模块与 6 例单测。 同批轮换生产 SESSION_SECRET(原值为可猜字面量,只失效浏览器会话,不影响 API 令牌)。 Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
v0.5.0 的回调白名单只登记了 new-api 与 pb-orders,漏了 /sellfox/admin/oidc-callback,导致赛狐 API 代理的钉钉登录从加固上线起 一直返回 400「登录回调地址不合法」,新同事拿不到 SK。 - redirect_policy.py 默认值补第三个真实客户端,测试覆盖放行与近似域名拒绝 - README / log 记录「服务器 compose 与仓库默认值必须一起改」 - 新增 solutions 复盘 + AGENTS.md 篇数同步 生产侧已同步:compose 白名单追加该回调并重建 bridge,探针由 400 恢复 307。 Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
背景
同事打开 https://api.vilavi.cn/sellfox/admin 点钉钉登录,报「无法登录 / 登录回调地址不合法」。
实测赛狐 API 代理本身健康(
/sellfox/health→sellfox_reachable: true),问题在上游 OIDC 桥:
/authorize的回调白名单里没有/sellfox/admin/oidc-callback,桥日志连续出现
拒绝登录:redirect_uri 不在白名单 … client_id=sellfox-api-proxy(400)。白名单是 10-29 的安全加固(提交 562c598),当时只在分支上、未合 main,却被手工部署到生产;
生成白名单时按 nginx 日志取了两个客户端,漏掉赛狐这一条 → 所有赛狐登录 100% 失败。
改动
修复(提交 2)
redirect_policy.py:默认白名单补https://api.vilavi.cn/sellfox/admin/oidc-callbacktests/test_redirect_policy.py:新增放行 + 近似域名/协议变体拒绝用例(7 例)README.md/docs/log.md(v0.5.1):写明「服务器 compose 的ALLOWED_REDIRECT_URIS与仓库默认值必须一起改」docs/solutions/integration-issues/oidc-redirect-allowlist-missing-client.md复盘AGENTS.md经验库篇数同步同时把加固本身合入 main(提交 1,cherry-pick 562c598)
main 此前没有这套 redirect_uri 校验,属既存安全风险。冲突仅
index.md(已重新生成)与new-api-deployment/AGENT_HANDOFF.md(手工合并,并补「问题 11」记录本次故障)。生产侧(已执行)
/opt/new-api/docker-compose.yml→.bak-allowlist-<ts>ALLOWED_REDIRECT_URIS追加赛狐回调 →docker compose up -d bridge/authorize探针 400 → 307(跳 login.dingtalk.com);5 分钟内无新「拒绝登录」日志验证
api_keys出现其记录(待其本人重试)🤖 Generated with Claude Code