security: repo-flags endpoints build API paths with raw, unescaped segments #711

Closed
opened 2026-10-04 18:21:36 +00:00 by hexajon · 0 comments
Owner

What happens

The repo-flags client builds its API paths with raw fmt.Sprintf, not the segment-wise escaping the other builders use. In internal/gitea/client_repo_flags.go, ListRepoFlags (:18), GetRepoFlag (:24), AddRepoFlag (:30), and RemoveRepoFlag (:36) each interpolate owner, repo, and flag directly, e.g. fmt.Sprintf("/repos/%s/%s/flags/%s", owner, repo, flag). Every other request-path builder routes its segments through the package's escapePath (segment-wise url.PathEscape); this family was missed.

Scope

Same-origin path reshaping only; the repo-scope boundary is unaffected. Hygiene. Per the #708 sweep this is the one raw request-path builder left after the rest were migrated. The fix is non-breaking: escaping a slug with no special characters is a no-op.

Fix (direction)

Route owner, repo, and flag through escapePath, as the sibling builders do.

Acceptance criteria

  • The four repo-flags endpoints escape each path segment.
## What happens The repo-flags client builds its API paths with raw `fmt.Sprintf`, not the segment-wise escaping the other builders use. In `internal/gitea/client_repo_flags.go`, `ListRepoFlags` (`:18`), `GetRepoFlag` (`:24`), `AddRepoFlag` (`:30`), and `RemoveRepoFlag` (`:36`) each interpolate `owner`, `repo`, and `flag` directly, e.g. `fmt.Sprintf("/repos/%s/%s/flags/%s", owner, repo, flag)`. Every other request-path builder routes its segments through the package's `escapePath` (segment-wise `url.PathEscape`); this family was missed. ## Scope Same-origin path reshaping only; the repo-scope boundary is unaffected. Hygiene. Per the #708 sweep this is the one raw request-path builder left after the rest were migrated. The fix is non-breaking: escaping a slug with no special characters is a no-op. ## Fix (direction) Route `owner`, `repo`, and `flag` through `escapePath`, as the sibling builders do. ## Acceptance criteria - [ ] The four repo-flags endpoints escape each path segment.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
sixfold-space/madtea#711
No description provided.