Skip to content

[Security] netrc support passes original credentials on HTTP redirects #9327

Closed

Description

@keith

Description of the problem / feature request:

When you have a ~/.netrc file with these contents:

machine github.com
  login something
  password something

Downloads of GitHub tarballs fail with this error:

skylib.0.8.0.tar.gz: GET returned 400 Bad Request
ERROR: no such package '@bazel_skylib//': java.io.IOException: Error downloading [https://github.com/bazelbuild/bazel-skylib/releases/download/0.8.0/bazel-skylib.0.8.0.tar.gz] to 

If you copy the curl request of what bazel is doing, you can see why:

% curl -H 'User-Agent: Bazel/release 0.29.0' -H 'Authorization: Basic somebase64' -H 'Host: github.com' -H 'Accept: text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2' 'http://github.com/bazelbuild/bazel-skylib/releases/download/0.8.0/bazel-skylib.0.8.0.tar.gz' -L
<?xml version="1.0" encoding="UTF-8"?>
<Error><Code>InvalidArgument</Code><Message>Only one auth mechanism allowed; only the X-Amz-Algorithm query parameter, Signature query string parameter or the Authorization header should be specified</Message><ArgumentName>Authorization</ArgumentName><ArgumentValue>token anything</ArgumentValue><RequestId>8A1908B7B4F61B0B</RequestId><HostId>G3CxaBga4CoVWwqf1fu4WMrr2LjLJ28s2H8+Kn90PFFFygw8KKQ6+JINoeUTipnpbtbcxmKhr9A=</HostId></Error>

Removing the Authorization header from the request fixes this issue. Switching the Basic auth to bearer or token and providing that directly doesn't solve this issue.

Bugs: what's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.

bazel build //... --repository_cache=

What operating system are you running Bazel on?

macOS

What's the output of bazel info release?

release 0.29.0

Have you found anything relevant by searching the web?

#7978

Activity

  1. keith commented on Sep 4, 2019

    @keith
    MemberAuthor
  2. jin commented on Sep 5, 2019

    @jin
    Member
  3. added
    team-ExternalDeps
    untriaged
    on Sep 5, 2019
  4. dslomov commented on Sep 5, 2019

    @dslomov
    Contributor

    cc @laurentlb this looks like a release blocker for 0.29 /cc #9293

  5. katre commented on Sep 5, 2019

    @katre
    Collaborator

    Do we know what Bazel commit caused this to stop? Does it work with 0.28.1?

  6. genrym commented on Sep 5, 2019

    @genrym

    @keith the PR referenced there is not the final implementation, and it was scrapped. The final implementation is pretty different.

    Just to clarify, the same configuration works well with bazel 0.28.1?

  7. dslomov commented on Sep 5, 2019

    @dslomov
    Contributor

    The original functionality went in in c26e339, so should already be present in 0.28. Does this work with 0.28 for you @keith?

  8. laurentlb commented on Sep 5, 2019

    @laurentlb
    Contributor

    I think c26e339 was released only in 0.29 (it has only the 0.29 tag on GitHub; the baseline of 0.28 was from July 1st, so a few days before).

  9. katre commented on Sep 5, 2019

    @katre
    Collaborator

    Is the solution to roll back c26e339, then?

  10. dslomov commented on Sep 5, 2019

    @dslomov
    Contributor

    The rollback might not be that easy... Can we investigate an actual fix?

  11. katre commented on Sep 5, 2019

    @katre
    Collaborator

    I am afraid I don't understand the error. What is wrong with the "Authorization" header that Bazel is generating in the curl command?

  12. dslomov commented on Sep 5, 2019

    @dslomov
    Contributor

    I can reproduce the problem with 0.29.0 (with Bazel not with curl). I assume some versions of curl remove duplicate Authorization: headers and some don't.

  13. added
    P0
    on Sep 5, 2019
  14. 15 remaining items

  15. added a commit that references this issue on Sep 6, 2019
    1fd67db
  16. added a commit that references this issue on Sep 6, 2019
    bc89e41
  17. added a commit that references this issue on Sep 16, 2019
    d278904
  18. added 2 commits that reference this issue on Sep 30, 2019
    301f6ed
    bd6b02c
  19. orgads commented on Dec 24, 2019

    @orgads

    This still happens to me with bazel 1.2.0.

  20. orgads commented on Dec 24, 2019

    @orgads

    I had a cached version of http.bzl. I cleared the cache and it was solved.

  21. added
    team-OSS
    on Jun 15, 2020
  22. orgads commented on Aug 19, 2020

    @orgads

    I just tried to build on a new machine, and ran into this issue again with 3.4.1. Possibly related #10998.

  23. removed
    team-OSS
    on Nov 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

P0team-ExternalDeps

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions