Skip to content

[bug] HTTP 服务缺少 Origin/Host 边界校验,Basic 认证下存在 CSRF 与 DNS rebinding 风险 #504

Description

@liujuanjuan1984

背景

#499 审计拆解项。HTTP 服务缺少 Origin/Host 边界校验。Basic 认证下浏览器会自动携带凭据,恶意网页可跨站触发任务提交/取消/订阅;绑定非 loopback 时无 Host 校验,存在 DNS rebinding 风险。

证据(main @ adf2a9b

  • src/opencode_a2a/server/middleware.py:90 bearer_auth:仅校验 Authorization,放行 OPTIONS 与 agent card well-known 路径,无 Origin/Referer/Host 校验。
  • src/opencode_a2a/config.py:231A2A_HOST 默认 127.0.0.1,可配置 0.0.0.0。

暴露面与后果

  • Basic 认证 + 浏览器 → CSRF(SendMessage/CancelTask/subscribe);
  • 非 loopback 绑定 → DNS rebinding 绕过浏览器同源模型;
  • 可被跨站触发的任务操作面。

验收标准

  • 带 Origin 头的请求校验与 A2A_PUBLIC_URL 同源,不匹配返回 4xx
  • 非 loopback 绑定时提供 Host allowlist 校验或启动告警
  • 新增 CSRF/rebinding 回归测试
  • 文档说明 Basic 认证的浏览器使用风险

基线快照

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions