fix: SECURITY: Unquoted curl URLs with variables in API calls (#60) #69
No reviewers
Labels
No labels
action
backlog
blocked
in-progress
priority
tech-debt
underspecified
vision
No milestone
No project
No assignees
3 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: johba/disinto#69
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "fix/issue-60"
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?
Fixes #60
Changes
Add URL validation helper to prevent URL injection attacks in API calls. - Added validate_url() helper in lib/env.sh to validate URL format - Added validation to forge_api() to prevent URL injection - Added validation to woodpecker_api() to prevent URL injection - Added validation to ci-debug.sh api() function - All URLs are already properly quoted with "${VAR}/..." patterns - This adds defense-in-depth by validating URL variables before useAI Review
Summary
This PR adds a
validate_url()helper and inserts validation guards before everycurlcall that uses a URL variable (FORGE_API,WOODPECKER_SERVER,API). The validation approach is sound — it checks forhttp(s)://prefix and rejects credential-embedding URLs (those containing@in the authority component). Good defense-in-depth addition.Issues
lib/env.sh:244:forge_api_call()is dead code. It is defined by this PR but has zero callers anywhere in the codebase. It also duplicates the functionality of the existingforge_api()helper (same validation, same headers, same auth). Per the coding conventions in AGENTS.md: "Avoid duplicate code — shared helpers go in lib/". This function should either be removed or have actual call sites that justify it.Minor observations (no block)
info
lib/ci-debug.sh:21vslib/env.sh:273: Slight inconsistency —ci-debug.shvalidates the fully-constructed$APIURL (includes path), whilewoodpecker_api()in env.sh validates just$WOODPECKER_SERVER(base only). Both are functionally correct sincevalidate_urlchecks scheme+host on either form, but the convention differs between the two files.info
lib/env.sh:163: The@-rejection regex (^https?://[^@]+@) would also reject legitimate URLs with@in the path (e.g.http://host/path@tag). This is a conservative false-positive — safe for the forge/Woodpecker use cases here — but worth documenting in a comment if the function is ever reused for other endpoints.Verdict
REQUEST_CHANGES — forge_api_call() is dead code with no callers — duplicates forge_api() and should be removed
Reviewed at
dbabc26| AGENTS.mdAI Review: REQUEST_CHANGES — forge_api_call() is dead code with no callers — duplicates forge_api() and should be removed
dbabc262d9to318910265eAI Re-review (round 2)
Previous Findings
forge_api_call()dead code → FIXED: function and the adjacentcodeberg_api_allalias both removed in the incremental commit. No callers existed for either, confirmed by grep.New Issues
None. The remaining change is clean:
validate_url()helper plus guards inforge_api(),woodpecker_api(), andci-debug.sh:api()are all correct and properly integrated.Verdict
APPROVE — Dead code removed; validate_url guards are correct and complete
Reviewed at
3189102| Previous:dbabc26| AGENTS.mdAI Re-review (round 2): APPROVE — Dead code removed; validate_url guards are correct and complete