Skip to content

[Security] Fix CRITICAL vulnerability: V-004#6093

Merged
Soulter merged 1 commit intoAstrBotDevs:masterfrom
orbisai0security:fix-fix-jwt-security-backup-route
Mar 12, 2026
Merged

[Security] Fix CRITICAL vulnerability: V-004#6093
Soulter merged 1 commit intoAstrBotDevs:masterfrom
orbisai0security:fix-fix-jwt-security-backup-route

Conversation

@orbisai0security
Copy link
Contributor

@orbisai0security orbisai0security commented Mar 12, 2026

Security Fix

This PR addresses a CRITICAL severity vulnerability detected by our security scanner.

Vulnerability Details

  • Rule ID: V-004
  • File: astrbot/dashboard/routes/backup.py
  • Description: JWT tokens are used for authentication in multiple dashboard routes (backup.py:980, live_chat.py:150, auth.py:90). Without examining the actual JWT verification code, common vulnerabilities include: accepting 'none' algorithm, not verifying signatures, using weak secrets, or missing expiration validation. These allow attackers to forge tokens with arbitrary claims.

Changes Made

This automated fix addresses the vulnerability by applying security best practices.

Files Modified

  • astrbot/dashboard/routes/backup.py

Verification

This fix has been automatically verified through:

  • ✅ Build verification
  • ✅ Scanner re-scan
  • ✅ LLM code review

🤖 This PR was automatically generated.

Summary by Sourcery

Bug Fixes:

  • 加强备份下载路由中的 JWT 解码逻辑,防止接受没有过期时间、缺少签名验证或已过期声明的令牌。
Original summary in English

Summary by Sourcery

Bug Fixes:

  • Harden JWT decoding in the backup download route to prevent acceptance of tokens without expiration, with missing signature verification, or with expired claims.

Automatically generated security fix
@auto-assign auto-assign bot requested review from Fridemn and LIghtJUNction March 12, 2026 03:30
@gemini-code-assist
Copy link
Contributor

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

@dosubot dosubot bot added the size:S This PR changes 10-29 lines, ignoring generated files. label Mar 12, 2026
Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - 我在这里给出了一些整体性的反馈:

  • 建议将这部分强化后的 JWT 校验逻辑抽取出来,放到一个共享的辅助方法中,由所有 dashboard 路由(例如 backup、live_chat、auth)共同使用,以避免将来各路由在 token 校验行为上产生偏差。
  • 由于这个端点现在已经严格要求包含 exp,请评估是否还需要强制检查其他声明(例如 iss/aud),并配置相应的校验逻辑,以便让 token 验证与整体的身份认证模型完全对齐。
给 AI Agent 的提示
请根据本次代码审查中的评论进行修改:

## 总体意见
- 建议将这部分强化后的 JWT 校验逻辑抽取出来,放到一个共享的辅助方法中,由所有 dashboard 路由(例如 backup、live_chat、auth)共同使用,以避免将来各路由在 token 校验行为上产生偏差。
- 由于这个端点现在已经严格要求包含 `exp`,请评估是否还需要强制检查其他声明(例如 `iss`/`aud`),并配置相应的校验逻辑,以便让 token 验证与整体的身份认证模型完全对齐。

Sourcery 对开源项目是免费的——如果你觉得我们的代码审查有帮助,欢迎分享给更多人 ✨
帮我变得更有用!请在每条评论上点 👍 或 👎,我会根据你的反馈改进之后的代码审查。
Original comment in English

Hey - I've left some high level feedback:

  • Consider centralizing this strengthened JWT verification logic into a shared helper used by all dashboard routes (e.g., backup, live_chat, auth) to avoid divergence in token validation behavior over time.
  • Since this endpoint now strictly requires exp, evaluate whether you also need to enforce additional claims such as iss/aud (and configure their verification) to fully align token validation with your authentication model.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- Consider centralizing this strengthened JWT verification logic into a shared helper used by all dashboard routes (e.g., backup, live_chat, auth) to avoid divergence in token validation behavior over time.
- Since this endpoint now strictly requires `exp`, evaluate whether you also need to enforce additional claims such as `iss`/`aud` (and configure their verification) to fully align token validation with your authentication model.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@dosubot dosubot bot added the area:webui The bug / feature is about webui(dashboard) of astrbot. label Mar 12, 2026
@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Mar 12, 2026
@Soulter Soulter merged commit bdac0b6 into AstrBotDevs:master Mar 12, 2026
4 of 5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:webui The bug / feature is about webui(dashboard) of astrbot. lgtm This PR has been approved by a maintainer size:S This PR changes 10-29 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants