fix: fix tag export/import routes bypassing JWT auth (CWE-306)#162
Open
saaa99999999 wants to merge 1 commit into
Open
fix: fix tag export/import routes bypassing JWT auth (CWE-306)#162saaa99999999 wants to merge 1 commit into
saaa99999999 wants to merge 1 commit into
Conversation
Tag export and import routes used r.POST() instead of apiv1.POST(), placing them outside the JWT-protected /api/v1 group. Fix by using apiv1.POST() to enforce authentication on these endpoints.
Author
|
Hi maintainer, this PR fixes CWE-306 (Missing Authentication for Critical Function) — tag export/import routes were registered with r.POST() instead of apiv1.POST(), bypassing JWT authentication. The Swagger annotations already expected /api/v1 prefix, confirming the bug. Could you please review? Thank you! |
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.
Summary
routers/router.go 中标签导出/导入路由使用 r.POST() 而非 apiv1.POST(),导致这两个端点绕过 JWT 认证,无需 token 即可访问。
Root Cause
r.POST() 将路由注册到根 Engine,跳过 apiv1 的 JWT 中间件。同时 Swagger 注释已标注为 @router /api/v1/tags/export,说明原意应属于 /api/v1 组。
Fix
r.POST → apiv1.POST,路由现在受 JWT 中间件保护,且路径前缀为 /api/v1:
Impact