Skip to content

https proxies leak credentials when requesting http #2909

Description

@0x676e67

When using an HTTPS proxy with proxy credentials, making requests to HTTP websites can leak the proxy authorization headers.

The replicated code:

#![deny(warnings)]

// This is using the `tokio` runtime. You'll need the following dependency:
//
// `tokio = { version = "1", features = ["full"] }`
#[tokio::main]
async fn main() -> wreq::Result<()> {
    // Make sure you are running tor and this is your socks port
    let proxy = wreq::Proxy::all("https://gngpp:gngpp123@192.168.1.1:1080")
        .expect("tor proxy should be there");
    let client = wreq::Client::builder()
        .proxy(proxy)
        .cert_verification(false)
        .build()
        .expect("should be able to build wreq client");

    let res = client.get("http://httpbin.io/get").send().await?;
    println!("Status: {}", res.status());

    let text = res.text().await?;
    println!("Body:\n{}", text);
    Ok(())
}

Result:

Status: 200 OK
Body:
{
  "args": {},
  "headers": {
    "Accept-Encoding": [
      "zstd,gzip,deflate,br"
    ],
    "Host": [
      "httpbin.io"
    ],
    "Proxy-Authorization": [
      "Basic Z25ncHA6Z25ncHAxMjM="
    ]
  },
  "method": "GET",
  "origin": "142.171.157.68:52788",
  "url": "http://httpbin.io/get"
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions