# Proxy-Authorization header: base64 is not encryption

> The Proxy-Authorization header is Basic plus base64 of user:password. Anyone who reads the hop to a plain HTTP proxy can decode it in one command.

Source: https://mosaicbrowser.com/blog/proxy-password-in-base64

## Your proxy password crosses the internet in base64

The Proxy-Authorization header is Basic plus base64 of user:password. Anyone who reads the hop to a plain HTTP proxy can decode it in one command.

![Base64 is an encoding, not a lock, beside a screenshot: routing Mosaic launches through Proxyman, Charles or mitmproxy to read their traffic](https://mosaicbrowser.com/covers/proxy-password-in-base64.webp)

The `Proxy-Authorization` header for a Basic proxy is the word `Basic`, a space, and the base64 encoding of `username:password`. For the username `user` and password `pass` that is `Proxy-Authorization: Basic dXNlcjpwYXNz`. Base64 is an encoding, not encryption: `echo dXNlcjpwYXNz | base64 -d` prints `user:pass`. On a plain HTTP proxy that header crosses the network as readable text, every time.

We send this header on behalf of every profile in Mosaic that has a proxy with a password, so we have had reason to look at it closely.

## How the header is built

The rules are in RFC 7617, which defines the Basic scheme, and RFC 7235 (now folded into RFC 9110), which defines the proxy side of the exchange.

1. The client asks the proxy for something without credentials.
2. The proxy answers `407 Proxy Authentication Required` with a `Proxy-Authenticate: Basic realm="..."` header naming the scheme it accepts.
3. The client joins the username and password with one colon, encodes the bytes as base64, and repeats the request with `Proxy-Authorization: Basic <that string>`.

A client that already knows the proxy wants Basic can skip the first round trip and send the header on the first request. Mosaic does that.

To build one by hand:

```
printf '%s' 'user:pass' | base64
dXNlcjpwYXNz

```

Use `printf` or `echo -n`, not plain `echo`. A trailing newline gets encoded too, the password becomes `pass\n`, and the proxy answers 407 to credentials that look right.

Two details from the RFC catch people out. The username cannot contain a colon, because the decoded string is split at the first one; anything after it is the password, and a password may contain colons. And the RFC lets a server say `charset="UTF-8"` in its challenge to state the encoding it expects. Without it, a password with non-ASCII characters is encoded however the client chooses. Mosaic encodes UTF-8.

Mosaic is a desktop app

Email yourself the link and open it on your computer.

[How it works: A new IP for every profile](https://mosaicbrowser.com/features/proxy-providers)

## Why base64 is in there at all

Base64 exists so that arbitrary bytes fit inside a header line. It was never meant to hide anything, and it does not. Any decoder reverses it, there is no key, and the same credentials always produce the same string, so the header is as good as the password to whoever copies it.

With a proxy seller, the string carries more than a password. Sellers put targeting and sessions in the username: something like `customer-acme-cc-de-sessid-k3j9q2` for a German IP on one sticky session. Encoded with a password, that is:

```
Proxy-Authorization: Basic Y3VzdG9tZXItYWNtZS1jYy1kZS1zZXNzaWQtazNqOXEyOlRyMHViNGRvcg==

```

Decode it and you get the account, the country, the session id and the password, which is enough to browse on that account's traffic from that IP.

## Who can read it

The header goes to the proxy and stops there. A proxy that follows the spec consumes it and does not forward it, so the site at the far end never sees your proxy credentials.

What can read it is the hop between your computer and the proxy. With a plain HTTP proxy that hop is plain TCP. For an `https://` site, the header sits in the CONNECT request, before any TLS starts:

```
CONNECT example.com:443 HTTP/1.1
Host: example.com:443
Proxy-Connection: keep-alive
User-Agent: Mozilla/5.0 ...
Proxy-Authorization: Basic dXNlcjpwYXNz

```

For an `http://` site it is worse, because the whole request goes to the proxy in the clear, path, cookies and all, with the credential attached.

So the café Wi-Fi, an office network that inspects traffic, or anyone else on the path can collect the password from the first request. Repeating it on every request does not add exposure on top of that, since the first one already gave it away. SOCKS5 has the same problem in a different shape: its username and password sub-negotiation, RFC 1929, sends both as plain bytes.

There is one fix on the wire, and it is TLS to the proxy itself. With an HTTPS proxy the client opens TLS to the gateway first, and the CONNECT line and its header travel inside it ([what an HTTPS proxy adds over an HTTP one](https://mosaicbrowser.com/blog/what-an-https-proxy-adds) covers what that hides and what it does not). The other options avoid the password altogether: a seller's IP allowlist, where the gateway accepts your address instead of credentials, or a VPN to a network you trust before the proxy.

## Where Mosaic puts the header

Chrome's `--proxy-server` switch has no place for a username or a password, and the login prompt Chrome shows for a 407 waits for a person to type into it. So a profile in Mosaic with an authenticated proxy does not log in to the gateway itself. Mosaic logs in for it, on your computer: the browser hands its traffic to Mosaic on `127.0.0.1`, with no credentials at all, and Mosaic adds `Proxy-Authorization` on the way to the proxy.

That splits the path in two. The browser's half of the path is loopback, so the credential never appears in the browser's own traffic and never leaves the machine on that hop. Any `Proxy-Authorization` the browser itself sends is treated as hop-by-hop and dropped, never forwarded. The gateway's side is where the header is written, last in the CONNECT request, which is where Chromium's own `BuildTunnelRequest` puts it, after `Host`, `Proxy-Connection` and the browser's own `User-Agent`. We copied that order from the Chromium source after a recording proxy showed Mosaic writing a different one ([our proxy login told the gateway it was a script](https://mosaicbrowser.com/blog/the-relay-that-looked-like-a-script) has the before and after).

What Mosaic cannot do is encrypt a hop the gateway does not encrypt. For a proxy set to `http`, the header leaves your computer as base64 text, exactly as it would from Chrome. For a proxy set to `https`, Mosaic opens TLS to the gateway first, with the gateway's hostname as the server name, and writes CONNECT and the header only once that channel is up. A gateway whose certificate does not check out is refused.

So the honest summary is short. Mosaic keeps the password out of the browser and off the loopback hop. Only an HTTPS proxy keeps it off the wire to the gateway. If your seller offers a TLS port, use it. The full list of what to test before trusting an account to an IP is in [how to check a proxy before you use it](https://mosaicbrowser.com/guides/how-to-check-a-proxy-before-you-use-it).

## Questions

### How is the Proxy-Authorization header built?

Join the username and password with a colon, encode that string as base64, and put it after the word Basic. user:pass becomes Proxy-Authorization: Basic dXNlcjpwYXNz.

### Is base64 proxy authentication secure?

Not on its own. Base64 is an encoding that anyone can reverse. On a plain HTTP proxy the header crosses the network as readable text, so the hop to the proxy needs TLS, as with an HTTPS proxy, if that network is not yours.

### Can a proxy username contain a colon?

No. Basic authentication splits the decoded string at the first colon, so a colon in the username would move part of it into the password. A password may contain colons.

### Why does a proxy answer 407?

407 Proxy Authentication Required means the proxy wants credentials and did not get valid ones. It names the scheme it accepts in a Proxy-Authenticate header, usually Basic with a realm, and the client retries with Proxy-Authorization.

### Does the website I visit see my proxy password?

No. The proxy consumes the Proxy-Authorization header and does not pass it on. What can read it is anything on the network between you and the proxy, when that hop is not encrypted.

## Related

[What an HTTPS proxy adds over an HTTP one](https://mosaicbrowser.com/blog/what-an-https-proxy-adds): An HTTPS proxy encrypts the hop to the gateway, so your network cannot read the sites you connect to or your proxy password. Sites see no difference.

[Mosaic told the proxy gateway it was a script](https://mosaicbrowser.com/blog/the-relay-that-looked-like-a-script): Chrome sends Proxy-Connection: keep-alive, lower case, to every proxy. Mosaic sent Keep-Alive, no User-Agent and Connection: close, until we copied Chrome.

[What your proxy provider can and cannot see](https://mosaicbrowser.com/blog/what-a-proxy-provider-can-see): Over HTTPS a proxy provider sees each hostname, port, time and byte count, never the pages or passwords. Over plain HTTP it sees everything you send.

[socks5 and socks5h: where Chrome resolves the name](https://mosaicbrowser.com/blog/socks5-and-socks5h-in-chrome): In curl, socks5h sends the hostname to the proxy and socks5 resolves it locally. Chrome's socks5 already sends the name; the leak is elsewhere.

[How to check a proxy before you use it](https://mosaicbrowser.com/guides/how-to-check-a-proxy-before-you-use-it): Check that a proxy answers and connects, where its IP really is, whether the address is residential or blocklisted, and that the browser stays behind it.







[Reading a proxy seller's grammar off one pasted line](https://mosaicbrowser.com/blog/a-sellers-grammar): Proxy sellers put country, session and lifetime in the username. Mosaic reads the grammar off the line you paste and keeps every token it does not know.

## Mosaic, on your own computer

The browser this blog is about: its own Chromium, fingerprints from real machines and a proxy IP per profile. Free covers 3 profiles with no card, and Pro is $25 a month for any number of them.

Mosaic is a desktop app

Email yourself the link and open it on your computer.
