CVE-2022-39395: Improper Privilege Management (CWE-269)
value: Vela is a Pipeline Automation (CI/CD) framework built on Linux container technology written in Golang. In Vela Server and Vela Worker prior to version 0.16.0 and Vela UI prior to version 0.17.0, some default configurations for Vela allow exploitation and container breakouts. Users should upgrade to Server 0.16.0, Worker 0.16.0, and UI 0.17.0 to fix the issue. After upgrading, Vela administrators will need to explicitly change the default settings to configure Vela as desired. Some of the fixes will interrupt existing workflows and will require Vela administrators to modify default settings. However, not applying the patch (or workarounds) will continue existing risk exposure. Some workarounds are available. Vela administrators can adjust the worker's `VELA_RUNTIME_PRIVILEGED_IMAGES` setting to be explicitly empty, leverage the `VELA_REPO_ALLOWLIST` setting on the server component to restrict access to a list of repositories that are allowed to be enabled, and/or audit enabled repositories and disable pull_requests if they are not needed.
CWE description: The product does not properly assign, modify, track, or check privileges for an actor, creating an unintended sphere of control for that actor.
CVSS v3 base score: 9.9
Published: 2022-11-10T18:15Z
Repository: https://github.com/go-vela/server
Language: Go
Files changed: api/repo.go
Commit date: 2022-11-09 09:50:11 -0600
Commit message: Merge pull request from GHSA-5m7g-pj8w-7593

* fix(allowlist)!: modify repo allowlist behavior

* setting allow pull to false on create repo endpoint by default

Co-authored-by: ecrupper <easton.crupper12@gmail.com>
Diff: diff --git a/api/repo.go b/api/repo.go
index b1ee440..b8e9725 100644
--- a/api/repo.go
+++ b/api/repo.go
@@ -151,12 +151,11 @@ func CreateRepo(c *gin.Context) {
 
 	// set default events if no events are passed in
 	if !input.GetAllowPull() && !input.GetAllowPush() &&
 		!input.GetAllowDeploy() && !input.GetAllowTag() &&
 		!input.GetAllowComment() {
-		// default events to push and pull_request
-		r.SetAllowPull(true)
+		// default event to push
 		r.SetAllowPush(true)
 	} else {
 		r.SetAllowComment(input.GetAllowComment())
 		r.SetAllowDeploy(input.GetAllowDeploy())
 		r.SetAllowPull(input.GetAllowPull())
@@ -1042,15 +1041,16 @@ func ChownRepo(c *gin.Context) {
 
 	c.JSON(http.StatusOK, fmt.Sprintf("repo %s changed owner", r.GetFullName()))
 }
 
 // checkAllowlist is a helper function to ensure only repos in the
-// allowlist are allowed to enable repos. If the allowlist is
-// empty then any repo can be enabled.
+// allowlist are allowed to enable repos.
+//
+// a single entry of '*' allows any repo to be enabled.
 func checkAllowlist(r *library.Repo, allowlist []string) bool {
-	// if the allowlist is not set or empty allow any repo to be enabled
-	if len(allowlist) == 0 {
+	// check if all repos are allowed to be enabled
+	if len(allowlist) == 1 && allowlist[0] == "*" {
 		return true
 	}
 
 	for _, repo := range allowlist {
 		// allow all repos in org

Vulnerable code: 		// default events to push and pull_request
		r.SetAllowPull(true)
// allowlist are allowed to enable repos. If the allowlist is
// empty then any repo can be enabled.
	// if the allowlist is not set or empty allow any repo to be enabled
	if len(allowlist) == 0 {
Fixed code: 		// default event to push
// allowlist are allowed to enable repos.
//
// a single entry of '*' allows any repo to be enabled.
	// check if all repos are allowed to be enabled
	if len(allowlist) == 1 && allowlist[0] == "*" {