Repository navigation
修改数据看板文字 - #51
Merged
Merged
修改数据看板文字#51
Conversation
Member
|
谢谢😘 |
sususu98
pushed a commit
to sususu98/new-api
that referenced
this pull request
Dec 1, 2025
* fix: 修复 Session 数据越权访问漏洞, close QuantumNous#51 ## 问题描述 普通用户(非管理员令牌)登录 Web UI 后,可以通过"仪表盘" → "活跃 Session" 查看到其他用户 5 分钟内的请求内容和响应内容,造成严重的数据泄露。 ## 安全影响 - **数据泄露风险**: 用户可以查看其他用户的敏感请求和响应 - **隐私侵犯**: 违反用户数据隔离原则 - **合规风险**: 可能违反数据保护法规(如 GDPR) ## 修复方案 在所有 Session 相关 API 中添加用户权限检查: 1. **getActiveSessions()** - 列表过滤 - 管理员:可查看所有用户的 Session - 普通用户:只能查看自己的 Session 2. **getAllSessions()** - 列表过滤 - 同上,支持活跃和非活跃 Session 3. **getSessionDetails()** - 详情访问控制 - 检查 Session 所有权 - 非所有者尝试访问时记录安全日志并拒绝 4. **getSessionMessages()** - 消息访问控制 - 检查 Session 所有权 - 记录越权访问尝试 5. **getSessionResponse()** - 响应体访问控制 - 检查 Session 所有权 - 记录越权访问尝试 ## 技术实现 - 使用 `getSession()` 获取当前登录用户 - 通过 `aggregateSessionStats()` 查询 Session 的 userId - 比对 `sessionStats.userId` 与 `currentUserId` - 所有越权访问尝试都会记录安全日志 ## 测试建议 1. 创建两个普通用户(user1, user2) 2. user1 发起 API 请求产生 Session 3. user2 登录 Web UI 尝试查看 user1 的 Session 4. 预期结果:user2 只能看到自己的 Session,无法看到 user1 的 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]> --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: Claude Code Bot <[email protected]> Co-authored-by: Claude <[email protected]>
x22x22
pushed a commit
to x22x22/new-api
that referenced
this pull request
Apr 24, 2026
…'s quota correctly (close QuantumNous#51)
x22x22
pushed a commit
to x22x22/new-api
that referenced
this pull request
Apr 24, 2026
x22x22
pushed a commit
to x22x22/new-api
that referenced
this pull request
Apr 24, 2026
lingozhi
referenced
this pull request
in lingozhi/new-api
Jul 17, 2026
Measured over 262 prod requests, all six channels serving the SAME model at the SAME reasoning effort — so the spread is the channel, not the request: #41 1275ms (n=90) #51 1328ms (n=66) #42 2337ms (n=17) #33 3388ms (n=24) #45 3537ms (n=52) #57 8133ms (n=8) Bucketing by uncached prompt tokens holds p50 flat (1612/1934/2073/1802 for 0-2k/2-6k/6-20k/20k+), which rules out prefill volume as the cause. Meanwhile ~100% of requests are affinity-pinned, so the health-weighted selection that was supposed to steer around slow channels almost never runs — the only exit is IsChannelFastEnoughForAffinity, and `score > 0.1` with `score = 1/(1+latency)` only fires past 9s. #45 and #57 kept their sticky traffic forever; 33% of requests were pinned to a channel 2.6x+ slower than the one next to it. Release relative to the best peer for the same model+path instead: leave only when the sticky is BOTH slower than 2s absolute and >2x that peer. The absolute floor stops churn over gaps nobody can feel (0.3s vs 0.15s is 2x), the ratio stops churn for gains too small to repay a migration. #42 at 1.83x stays. The reason this could not just be turned on: migration causes a cold prompt cache by construction, and a cold 240k-token prefill measured 23348ms. That one number breaks two mechanisms at once, both of which then punish the channel we just chose *for being the fastest*: - the latency EWMA, which is shared by every affinity key on the channel, so one migration would make the destination look slow to all of them and stampede them off it, each paying its own cold prefill; - cooldownSlowChannelIfNeeded, an entirely separate path that yanks a channel out of rotation for 30 minutes past 30s FRT — 23.3s is 78% of that. So the release is gated three ways. ColdCacheStart marks the attempt and keeps its latency out of both mechanisms (failures still count — a cold start is no excuse for erroring). A per-key cooldown stops one key bouncing. A global minimum interval drains a slow channel one key at a time, because the slow verdict is per-channel: without it every key pinned to #45 leaves on the same tick and their cold prefills land on #41 together, making it genuinely slow — a cascade no latency-exclusion can prevent, since that load is real. Circuit-open releases stay unconditional and never reach AcquireChannelHealth, or a rate-limited key would be parked on a tripped channel and a paying request would become its half-open probe. Accepted: weighted re-selection can hand a released key back to the same slow channel (~12.5% by weight). Not excluded — that risks a 503, and the cache there is still warm, so the only cost is the 10-minute slot. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
lingozhi
referenced
this pull request
in lingozhi/new-api
Jul 17, 2026
Prod, one bad hour: four Codex sessions, one (1ff18e9d) sat on an idle #17 doing 1-2s the whole time, while another (c34a4d35) churned #51 -> #41 -> #56, every request 8-22s, never once landing on #17. The first-token times the user saw (6-11s) were these bounced sessions. When a session is released from a slow channel (affinity migration, or its sticky channel cooling), it re-picks via weighted-random selection. The health score weighting there under-separates fast from slow: score = 1/(1+EWMA), so 12s vs 1.8s is only ~4.6x. With several slow channels their combined weight rivals the one fast channel, and the bounced session is dropped back onto a slow one about as often as not. That is how c34a4d35 stayed slow. Multiply the selection weight of a channel measured fast right now (EWMA < affinityFastLatency) by 8. A single fast channel then takes ~80-90% of re-picks against a handful of slow peers instead of ~59%, so a bounced session lands on it. It self-limits: the boost keys off the live EWMA, so if the fast channel slows under the added load past the threshold it stops being boosted and traffic redistributes; slow channels keep a small share, which probes them for recovery. When nothing is under the threshold (whole fleet slow) no channel is boosted and selection falls back to plain health weighting — the same "only move toward somewhere genuinely fast" rule the affinity migration logic uses. Both selection paths (memory-cache and DB) now share EffectiveSelectionWeight so they weight identically; previously only one would have been changed. Note this composes with the existing slow-circuit trip (a channel past CHANNEL_HEALTH_SLOW_LATENCY, 9s, is dropped from selection outright): the boost governs the still-selectable 2-9s band and whatever remains after trips. Tests fail when the boost is removed: the fast channel's share falls from >0.8 to ~0.59. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
salem-2007
added a commit
to salem-2007/new-api
that referenced
this pull request
Sep 10, 2026
…'s quota correctly (close QuantumNous#51)
salem-2007
added a commit
to salem-2007/new-api
that referenced
this pull request
Sep 10, 2026
salem-2007
added a commit
to salem-2007/new-api
that referenced
this pull request
Sep 10, 2026
jahnli
pushed a commit
to jahnli/new-api
that referenced
this pull request
Oct 17, 2026
Upstream scope: 22 commits / 123 files since the last sync (ef60ef2). 19 conflicted files were resolved one by one with explicit confirmation: 9 manual merges, 3 files taken from upstream (console search refactor plus its new test), and key-set unions in all 7 locale files. Every auto-merged file was reviewed one by one and both sides' changes are preserved (line-level check: no local line and no upstream line lost). No upstream deletions. Local behavior kept: QuantumNous#2 AIGatewayError naming across relaykit and host error paths, QuantumNous#23/QuantumNous#24 LDAP login and LDAP default login, QuantumNous#27 avatar_url, QuantumNous#29/QuantumNous#31 removed OAuth providers, QuantumNous#37 subscription and violation fee flow, QuantumNous#39 user management table, QuantumNous#45/QuantumNous#69/QuantumNous#71 data overview access and BP roles, QuantumNous#49 pricing currency, QuantumNous#51/QuantumNous#56/QuantumNous#65 profile, audit and demo mode, QuantumNous#54/QuantumNous#55/QuantumNous#57 pricing square and dashboard/four-token stats, QuantumNous#58 online image generation, QuantumNous#60 API key interactions, QuantumNous#61 auto subscribe, QuantumNous#62 admin entry permissions, QuantumNous#77 removed frontend update check, seven-locale custom copy, header-removal convention. Upstream adopted: QuantumNous#7822 upstream address masking (upstreamURLs plumbing through relaykit error paths, task errors, WebSocket error events, playground/relay/gemini/chat_via_responses/violation fee), QuantumNous#7317 container cgroup overload sentinel with consecutive and freshness sampling, QuantumNous#7816 Claude explicit zero usage and cache-only billing, QuantumNous#7813 pricing sorts by input/output/per-request price, QuantumNous#7840 provider rules for Cloudflare and NVIDIA, QuantumNous#7814 sensitive word filtering off by default, AWS Mantle Messages API, Vertex multi-region hostnames and API key project_id, Hailuo/Vidu/Veo plugin channel bindings and Vidu billing, per-group rate limits, API key owner quota query, moejs v0.1.0-alpha.7, theme class applied before first paint, console search limited to sidebar pages. Collateral decisions (user approved): removed local test web/src/components/__tests__/command-menu-permissions.test.tsx (superseded by upstream command-menu.test.tsx) and added the newly required allow_user_quota_query field to the web/src/features/keys/components/__tests__/api-key-timestamp-cell.test.tsx fixture. Verification: go build ./... exit 0; GOWORK=off go build ./... in relaykit exit 0; gofmt clean on modified Go files; web bun run typecheck exit 0; oxlint clean on the 49 merged web files; bun run i18n:sync reports missingCount 0 and extrasCount 0 for all seven locales; no conflict markers left; every upstream commit's added lines are present. Not verified: SQLite/MySQL/PostgreSQL migration matrix for the new tokens.allow_user_quota_query column, unit tests (not run per project rule), web production build, runtime manual checks.
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.
修改数据看板文字