harden: escape every value that goes into an API path or query #609
Labels
No labels
breaking
bug
documentation
enhancement
epic
good first issue
help wanted
refactoring
resolution/duplicate
resolution/invalid
resolution/wontfix
security
severity/critical
severity/high
severity/low
severity/medium
status/abandoned
status/blocked
status/needs-decision
status/needs-info
status/needs-verification
testing
upstream
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
sixfold-space/madtea#609
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
What
apiPath(internal/gitea/client_query.go:72) escapes each path segment withurl.PathEscape. Most endpoint builders do not use it. They join strings instead: 173 call sites in 37 files ininternal/giteamatchc.repo+"..."+<variable>. Examples:client_tags.go:10,client_branches.go:13,client_collaborators.go:18)client_label.go:11,client_comment_extra.go:63)A value with a
/,?,#, or..changes the path or adds a query. The request still goes to the same forge host, with the user's own token. It can hit a different endpoint than the caller meant. A..segment cannot take a repo-scoped client out of its repo:pathUnderScope(internal/gitea/client_http.go:85) percent-decodes the path and resolves dot-segments before its prefix check. The fix must keep a/inside a value (a branchfeat/x, a file path), so it escapes each/-separated part.UploadReleaseAssetalso puts the file name into the query string without escaping (client_release.go:57,?name=+filename).Fix
apiPath, or escape each variable segment withurl.PathEscape.url.Values.Acceptance
internal/giteajoins an unescaped variable into a path.a b&x=1.zipuploads with that exact name.