Skip to content

[security] 查询参数覆盖路径 scope_id,导致跨 Scope 越权读取(已复现) #2081

Closed

Description

@dobet

问题描述

查询类操作的鉴权载荷构造为 {**path_values, **request.query_params}(src/powercontext/server/app.py:4704 _authorization_payload)。当查询参数与路径参数同名时,查询参数会覆盖路径参数。鉴权使用被覆盖后的值判定权限,而 handler 仍然使用原始路径值执行查询,导致越权。

受影响操作

  • LIST_ARTIFACTS(handler 位于 app.py:2516-2552)
  • LIST_ARTIFACT_REVISIONS(app.py:2615-2635),可通过 ?family=、?artifact_id= 替换被鉴权的资源
  • LIST_DREAM_RUNS(app.py:3473-3496)

这些操作的查询解析不拒绝未知参数,FastAPI 也会静默忽略多余参数。

不受影响:LIST_SOURCES(_list_sources_query(app.py:2261)拒绝未知参数);带请求体的路由(请求体模型使用 extra=forbid)。

复现步骤(已复现)

用户 Bob 仅在 scope-a 上拥有 scope_viewer 角色,访问控制开启:

请求 结果
GET /v1/scopes/scope-b/artifacts/memory 403
GET /v1/scopes/scope-b/artifacts/memory?scope_id=scope-a 200,运行时实际以 for_scope('scope-b') 查询

期望行为

鉴权必须以路径参数为准;与路径参数同名或未声明的查询参数应被拒绝。

环境信息

  • 评审对象:master 分支,提交 e4efb39b(ci: scope PR validation to changed areas (#2072))
  • 仅在开启访问控制(远程或团队部署)时生效

Activity

  1. DongYao0 commented on Oct 20, 2026

    @DongYao0
    Contributor

    Hi, I'd like to claim this security issue.

  2. AlexStocks commented on Oct 20, 2026

    @AlexStocks
    Contributor

    3. Hi, I'd like to claim this security issue.

    done.

  3. guamiao commented on Oct 20, 2026

    @guamiao
    Contributor

    Hi, I’d like to work on this issue. Could you please assign it to me? I’ll share updates here as I make progress. Thanks!

  4. moved this from Todo to In progress in PowerContexton Oct 20, 2026
  5. moved this from In progress to Done in PowerContexton Oct 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions