cubeapi: forward X-Request-Method to auth callback#315
Open
ls-ggg wants to merge 1 commit into
Open
Conversation
The auth callback only received X-Request-Path, not the HTTP method. Routes like /templates/:id and /sandboxes/:id multiplex multiple methods (GET/POST/DELETE/PATCH) on the same path, so a callback that whitelists by path alone cannot distinguish read from write/delete operations -- a caller with read-only credentials could escalate to delete/rebuild. Fix: add X-Request-Method header to every outgoing callback POST so the callback implementation can enforce fine-grained (path + method) authz. Changes: - middleware/auth.rs: forward X-Request-Method in callback POST request - config/mod.rs: update auth_callback_url doc comment with new header and privilege-escalation security note - tracing log fields: add method to debug/warn entries - 6 new unit tests covering GET-vs-DELETE same-path regression, path forwarding, rejection 401, no-callback passthrough, missing credential, and POST/PATCH write-method forwarding - docs/guide/authentication.md: add X-Request-Method to callback format table, update flow diagram, add warning block about path-only authz risk, rewrite example callback with path+method fine-grained authz - docs/zh/guide/authentication.md: same updates in Chinese Signed-off-by: ls-ggg <335814617@qq.com>
9fcd47b to
0a12cf2
Compare
Collaborator
Author
|
/cubebot cr |
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.
The auth callback only received X-Request-Path, not the HTTP method. Routes like /templates/:id and /sandboxes/:id multiplex multiple methods (GET/POST/DELETE/PATCH) on the same path, so a callback that whitelists by path alone cannot distinguish read from write/delete operations -- a caller with read-only credentials could escalate to delete/rebuild.
Fix: add X-Request-Method header to every outgoing callback POST so the callback implementation can enforce fine-grained (path + method) authz.
Changes: