Skip to content

About

GlobalProtect as local HTTP & SOCKS5 proxies. Rust userspace networking, no TUN, no system route or DNS changes.

Topics

Resources

Security policy

Stars

1 star

Watchers

0 watching

Forks

Repository files navigation

gp-proxy-rs

English · 简体中文

Reach corporate resources through GlobalProtect from curl, a browser, or any app with HTTP or SOCKS5 proxy support. The proxy listens on loopback and carries corporate traffic through an in-memory TCP/IP stack. It never creates a virtual network interface or changes system routes, DNS settings, or firewall rules.

CI MIT license Rust 1.91 Tested on macOS arm64

An app reaches a corporate resource through a loopback proxy, an in-memory TCP/IP stack, and a GlobalProtect TLS tunnel.

Tested on Apple Silicon with one enterprise deployment. Direct gateway password login and separate password logins at a same-origin portal and gateway have both established a tunnel. In the latter flow, the portal listed the expected gateway without issuing a gateway user cookie. Both proxies carried certificate-verified HTTPS requests through that session.

Quick start · Connect an app · Routing and DNS · Status and logs · Compatibility · Development

Quick start

Build with the pinned Rust 1.91 toolchain and a C/C++ compiler for AWS-LC. On macOS, install the Xcode Command Line Tools first.

git clone https://github.com/mingmingtsao/gp-proxy-rs.git
cd gp-proxy-rs
cargo build --locked --release
./target/release/gp-proxy --config gp-proxy.example.toml check
cp gp-proxy.example.toml gp-proxy.toml

The check command validates the configuration and TLS roots offline. Edit gp-proxy.toml with the gateway your administrator authorizes and the corporate destinations you need. A GlobalProtect portal can have a different address from its gateway. Full example configuration

gateway = "https://vpn.example.com"
http_listen = "127.0.0.1:8080"
socks_listen = "127.0.0.1:1080"
domains = ["corp.example.com"]
networks = ["10.20.0.0/16"]
# ca_file = "/path/to/approved-corporate-ca.pem"
./target/release/gp-proxy check
./target/release/gp-proxy run --username your-user

Enter your password at the hidden terminal prompt. The proxy runs in the foreground as your regular user. Certificate verification is always on. Set ca_file if your gateway uses a private CA. A listener port conflict is reported before the login is sent.

For file-based login, copy .env.example to .env, run chmod 600 .env, then fill it in locally. Start with ./target/release/gp-proxy --env-file .env run. This file supplies credentials and the gateway address. The TOML rules still determine which destinations the VPN may reach.

For a waiting service configured with a portal, use reauth --portal-env-file with a separate file containing GP_PORTAL, GP_USER and GP_PASSWORD. If both services share one HTTPS origin and you explicitly authorize sending an existing gateway password to that portal, reauth --env-file .env --expect-portal https://vpn.example.com --expect-gateway https://vpn.example.com checks both roles against the configuration, running service and file. Add --json for a credential-free authentication receipt.

Some deployments authenticate the password separately at the portal and the gateway. For this flow, set both portal and gateway to the same HTTPS origin, including the port, and add portal_gateway_password = true to your TOML. Start the service with run --wait-auth, then run:

gp-proxy --env-file .env reauth --expect-portal https://vpn.example.com \
  --expect-gateway https://vpn.example.com --password-to-both --json

GP Proxy submits the password to the gateway once the portal returns a policy listing that exact gateway. A rejection, an unlisted gateway or an interactive challenge ends this login. Each attempt keeps HTTPS session cookies in memory and respects their path scope.

macOS menu bar

Building the menu bar app requires macOS 13 or later, Xcode Command Line Tools, Rust and Python 3. Run these commands from the repository root.

python3 scripts/build-macos-app.py --install
open "$HOME/Applications/GP Proxy.app"

Open GP Proxy from Finder or Spotlight to see the connection status, copy proxy addresses or view logs. Account settings store the password in the macOS login keychain and let you open the app at login. The app uses the same routing and authentication configuration as the CLI.

Connect an app

App setting Default address
HTTP or HTTPS destination via HTTP proxy http://127.0.0.1:8080
SOCKS5 with proxy-side DNS socks5h://127.0.0.1:1080
Browser proxy auto-config (PAC) URL http://127.0.0.1:8080/proxy.pac

In another terminal, replace the example URL with an HTTPS endpoint inside one of your configured domains.

curl --disable --noproxy '' --proxy http://127.0.0.1:8080 https://intranet.corp.example.com/
curl --disable --noproxy '' --proxy socks5h://127.0.0.1:1080 https://intranet.corp.example.com/

socks5h passes the hostname to the proxy so corporate DNS stays inside the tunnel. --noproxy '' makes curl use the proxy even if NO_PROXY includes the destination. The loopback listeners have no client authentication and are intended for a trusted personal workstation.

Routing and DNS

How the app connects Known VPN destination Other destination
HTTP/SOCKS5, default routing_mode = "vpn_only" Tunnel if currently authorized and available Reject
HTTP/SOCKS5, routing_mode = "auto" Same VPN policy, including during outages Use the original network after checking resolved IPs
PAC-aware app Send to the local HTTP proxy App connects directly for an unmatched hostname

For one fixed proxy address that also serves public traffic, add routing_mode = "auto" to the TOML and restart the service. When the VPN drops, a request to a known corporate destination fails. The proxy never retries that request on the host network.

  • Rules. domains matches a domain and its subdomains (DOMAIN-SUFFIX). exact_domains matches only the named host (DOMAIN). domain_keywords matches a case-insensitive literal substring (DOMAIN-KEYWORD). Use networks for CIDRs. Rules are local snapshots, with a limit of 8,192 rules in total and 1,024 CIDRs. To include split domains and routes from an authenticated gateway, explicitly set trust_gateway_routes = true. Gateway exclusions still apply.
  • DNS. Known VPN names use the tunnel resolver. The host resolves the gateway itself and, in auto mode, previously unclassified names. If any address returned for such a name belongs to the VPN, only those VPN addresses are tried. Host resolution uses at most eight worker threads.
  • History. Keep gp-proxy.pac-history.json and its .lock beside the default configuration when moving or upgrading. Past classifications prevent a destination from silently becoming direct after a rule is removed. Current rules still control VPN authorization. Newly learned VPN rules also close active direct streams that match. Exact names and keywords upgrade the history to v2. The current version reads v1 and v2. Older binaries reject v2.
  • Browser PAC. The generated PAC matches names and literal IPs without a DNS lookup. It cannot recognize an unlisted hostname by its resolved address. Known corporate entries have no DIRECT fallback. The PAC sends ambiguous numeric inputs to the proxy for validation when IPv4 rules exist. Chromium may go direct if it cannot load the PAC itself. The optional strict PAC extension makes loading it mandatory. Refresh the extension after changing rules and close existing browser connections.

Status and logs

To start the listeners before logging in, run the following from the same configuration directory. Private disk logs and the local reauth and stop commands are available on macOS and on x86-64 or arm64 Linux.

# Terminal 1
./target/release/gp-proxy run --wait-auth --log-dir "$PWD/logs"

# Terminal 2
./target/release/gp-proxy reauth --username your-user
./target/release/gp-proxy status
tail -n 20 logs/log-*.txt
./target/release/gp-proxy stop
  • status exits with 0 when the VPN is available and 3 when the service answers but the VPN is unavailable. For a custom HTTP port, pass the HTTP listener address, for example --address 127.0.0.1:18080. Connection counters describe VPN traffic. Disk logs rotate across four files of up to 4 MiB each by default.
  • A disconnect closes affected VPN streams. The service backs off between reconnect attempts. After authentication expires, run reauth again. Applications must reopen interrupted connections. The service never resubmits your password or replays an application request automatically. A healthy session rejects another reauth as busy.
  • stop returns a JSON cleanup receipt. Exit 0 confirms local cleanup and logout of all known sessions. Exit 3 means local cleanup finished but remote logout is uncertain. Exit 1 means completion was unobserved or incomplete. Ctrl-C and SIGTERM also start cleanup.

If status=512 is followed by role="gateway" stage="password_login", the direct gateway login was rejected. The code alone does not identify a bad password. Check whether the official client first authenticates with a portal. In the opt-in two-step flow, a rejection at the gateway is logged as stage="password_after_portal". The client logs a recognized rejection category when available. Administrators can correlate the timestamp with their authentication logs. PAN-OS log types

Compatibility

Area Current coverage
Platforms Apple Silicon macOS has real gateway coverage. CI builds and tests on macOS, Linux, and Windows. Live gateway compatibility on Linux and Windows is unverified.
Authentication Direct gateway password login and the opt-in same-origin portal and gateway password flow have real gateway coverage. The default portal flow requires a user cookie that the gateway accepts. Successful cookie handoff and interactive challenges have synthetic coverage only. Browser SAML, client certificates, and automatic push polling are unsupported.
Tunnel Corporate TCP runs inside a TLS tunnel, so TCP-over-TCP can limit performance on lossy links. Full HIP reports, ESP-over-UDP, and a complete IPv6 VPN data plane are unimplemented. IPv6 classification rules alone do not enable IPv6 transport.
Proxy protocols HTTP CONNECT, plain HTTP/1.1 forwarding, and SOCKS5 CONNECT. Plain HTTP uses one request per connection, drops trailers, and does not support Upgrade. CONNECT can carry TLS and WebSockets.
Service management The optional macOS service manager is experimental. Login startup and enterprise background-item policies still need field validation.

The GlobalProtect protocol, TLS protocol, smoltcp network stack, and proxies are implemented in Rust. The daemon runs without OpenConnect. TLS uses rustls with AWS-LC, whose C and assembly cryptographic primitives are the project's explicit exception to Rust.

To report a compatibility issue, include your OS, architecture, commit, authentication method, and whether DNS and HTTPS worked through each proxy. Replace internal hostnames with example.com and omit credentials and captures. Report a bug · Report a security issue privately

Development

cargo fmt --check
cargo test --locked
cargo clippy --locked --all-targets -- -D warnings
python3 scripts/check-dependencies.py
node scripts/tests/check-pac.cjs
python3 -m unittest discover -s scripts/tests -p 'test_*.py'

The default tests use synthetic TLS gateways and in-memory networks. Long-running and independent interoperability tests are opt-in. Node and Python are development tools. Go is used only by the optional gVisor interoperability tests.

GlobalProtect protocol · Session and reconnects · In-memory stack · HTTP and SOCKS5 · Routing · Authorization and PAC · DNS

License

The project is MIT-licensed. Its bundled smoltcp fork uses 0BSD. This is an independent project with no affiliation with or endorsement from Palo Alto Networks. MIT license · Dependency licenses · smoltcp license · Local TCP patch

About

GlobalProtect as local HTTP & SOCKS5 proxies. Rust userspace networking, no TUN, no system route or DNS changes.

Topics

Resources

Security policy

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages