fix: add safe type assertions in Bitbucket webhook handlers#27757
Open
SebTardif wants to merge 1 commit intoargoproj:masterfrom
Open
fix: add safe type assertions in Bitbucket webhook handlers#27757SebTardif wants to merge 1 commit intoargoproj:masterfrom
SebTardif wants to merge 1 commit intoargoproj:masterfrom
Conversation
Two type assertions in the Bitbucket webhook handler use the single-value form, which panics if the underlying value has an unexpected type. In affectedRevisionInfo (Bitbucket Server path), elements of the clone links array are asserted as map[string]any without an ok check. A malformed or malicious webhook payload where any clone link entry is not a map causes a runtime panic, crashing the webhook handler. In fetchDiffStatFromBitbucket (Bitbucket Cloud path), the diffstat path value is asserted as string without an ok check. If the Bitbucket API returns a non-string path value, this panics. Both assertions now use the two-value (comma ok) form consistent with the surrounding code (e.g., line 291 already uses the safe form for the outer clone assertion). Signed-off-by: Sebastien Tardif <sebtardif@ncf.ca>
✅ Preview Environment deployed on Bunnyshell
See: Environment Details | Pipeline Logs Available commands (reply to this comment):
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #27757 +/- ##
==========================================
- Coverage 63.92% 63.88% -0.04%
==========================================
Files 421 421
Lines 57657 57659 +2
==========================================
- Hits 36856 36836 -20
- Misses 17345 17363 +18
- Partials 3456 3460 +4 ☔ View full report in Codecov by Sentry. |
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
Two type assertions in the Bitbucket webhook handler use the single-value form, which panics if the underlying value has an unexpected type. Since webhooks accept unauthenticated external HTTP requests, a crafted payload can crash the Argo CD server.
Bug 1: Bitbucket Server clone links (
affectedRevisionInfo)In the Bitbucket Server webhook path, elements of the
clonelinks array are asserted asmap[string]anywithout anokcheck. A malformed webhook payload where any clone link entry is not a map causes a runtime panic.The outer assertion on line 291 already uses the safe two-value form (
clone, ok := ....([]any)), but the inner loop assertion does not:This pattern was introduced in #3036.
Bug 2: Bitbucket Cloud diffstat path (
fetchDiffStatFromBitbucket)The diffstat
pathvalue is asserted asstringwithout anokcheck. If the Bitbucket API returns a non-string value for the path field, this panics:This was introduced in #21811.
Checklist