Skip to content

Fix remote server socket path exceeding sun_path limit#11009

Merged
kevinyang372 merged 3 commits into
masterfrom
kevin/fix-socket-path-length
May 15, 2026
Merged

Fix remote server socket path exceeding sun_path limit#11009
kevinyang372 merged 3 commits into
masterfrom
kevin/fix-socket-path-length

Conversation

@kevinyang372
Copy link
Copy Markdown
Member

@kevinyang372 kevinyang372 commented May 15, 2026

Description

PR #10782 ("Version aware daemon socket") changed daemon socket filenames from server.sock (11 chars) to server-v0.2026.05.13.09.15.stable_01.sock (41 chars), adding ~30 bytes to the Unix domain socket path. This pushes users over the sun_path limit (107 bytes on Linux, 103 on macOS), causing UnixListener::bind to fail silently in the daemon. The proxy then times out after 10s, exits with code 1, and the client sees ResponseChannelClosed.

This accounts for the ~20% drop in remote server initialization success rate (90% → 70%). Sentry issue: WARP-CLIENT-BETA-STABLE-7M9M (11 occurrences across 9 users, all anonymous with 36-char UUID identity keys).

Fix (two changes):

  1. Hash the version string in socket/PID filenames to an 8-hex-char suffix (server-a1b2c3d4.sock, 20 chars) instead of the full version string (41 chars).

  2. Hash the identity key directory name to 8 hex chars instead of using the raw identity key (up to 36 chars for anonymous UUIDs). This is needed because longer channel base dirs like .warp-preview (+8 chars vs .warp) would otherwise narrow the headroom too much on macOS.

Both changes use std::hash::DefaultHasher for deterministic, fixed-length output. The existing cleanup_old_versions() logic automatically cleans up old long-form files.

Also adds an explicit sun_path length guard in the proxy that fails fast with a clear error message instead of silently timing out.

Worst-case path after fix: /home/{32-char-user}/.warp-preview/remote-server/{8-char-hash}/server-{8-char-hash}.sock = 97 bytes, well under both limits (103 macOS, 107 Linux).

Fixes WARP-CLIENT-BETA-STABLE-7M9M

Linked Issue

  • The linked issue is labeled ready-to-spec or ready-to-implement.

Testing

  • 10 unit tests: version hash determinism, identity key hash (length, determinism, uniqueness), socket/PID name length bounds, and worst-case path length regression test against the preview channel (longest base dir)

  • Validated via Docker containers on linux/amd64, linux/arm64, and macOS/aarch64 with the actual 9 Sentry-reported identity keys

  • Cross-referenced Sentry events to confirm all affected users are anonymous (36-char UUID identity keys)

  • cargo fmt and cargo clippy pass

  • I have manually tested my changes locally with ./script/run

Agent Mode

  • Warp Agent Mode - This PR was created via Warp's AI Agent Mode

Co-Authored-By: Warp agent@warp.dev

@cla-bot cla-bot Bot added the cla-signed label May 15, 2026
Copy link
Copy Markdown
Member Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

@oz-for-oss
Copy link
Copy Markdown
Contributor

oz-for-oss Bot commented May 15, 2026

@kevinyang372

I'm starting a first review of this pull request.

You can view the conversation on Warp.

I completed the review and no human review was requested for this pull request.

Comment /oz-review on this pull request to retrigger a review (up to 3 times on the same pull request).

Powered by Oz

@kevinyang372 kevinyang372 changed the title Fix socket path length Fix remote server socket path exceeding sun_path limit May 15, 2026
Copy link
Copy Markdown
Contributor

@oz-for-oss oz-for-oss Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overview

This PR shortens the versioned remote-server socket and PID filenames and adds an early proxy-side path length guard for Unix domain socket limits.

Concerns

  • The new server-{hash}.sock name is still too long for the same realistic identity/home inputs on longer channel directories such as .warp-preview, so Preview users can continue to exceed sun_path and fail before the daemon starts.

Verdict

Found: 0 critical, 1 important, 0 suggestions

Request changes

Comment /oz-review on this pull request to retrigger a review (up to 3 times on the same pull request).

Powered by Oz

Comment thread crates/remote_server/src/setup.rs
@kevinyang372
Copy link
Copy Markdown
Member Author

/oz-review

@oz-for-oss
Copy link
Copy Markdown
Contributor

oz-for-oss Bot commented May 15, 2026

@kevinyang372

I'm re-reviewing this pull request in response to a review request.

You can view the conversation on Warp.

I completed the review and no human review was requested for this pull request.

Comment /oz-review on this pull request to retrigger a review (up to 3 times on the same pull request).

Powered by Oz

@kevinyang372 kevinyang372 requested a review from alokedesai May 15, 2026 15:00
Copy link
Copy Markdown
Contributor

@oz-for-oss oz-for-oss Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overview

This PR shortens remote-server daemon socket/PID paths by hashing the version and identity components, then adds a proxy-side sun_path length guard.

Concerns

  • Hashing the identity directory changes the location used by remote_server_daemon_data_dir, which stores the remote daemon SQLite database, so existing per-identity state under the previous percent-encoded directory becomes unreachable without a migration.
  • The same new identity directory is only an 8-hex-character hash; because it scopes the daemon socket and data directory, collisions can make distinct identity keys share daemon/data state.

Security

  • The 32-bit identity hash is used for identity-scoped daemon/data isolation; a collision can cross-contaminate daemon state between distinct identities.

Verdict

Found: 0 critical, 1 important, 0 suggestions

Request changes

Comment /oz-review on this pull request to retrigger a review (up to 3 times on the same pull request).

Powered by Oz

encoded
let mut hasher = std::collections::hash_map::DefaultHasher::new();
identity_key.hash(&mut hasher);
format!("{:016x}", hasher.finish())[..8].to_string()
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ [IMPORTANT] [SECURITY] Hashing the identity key into an 8-hex (32-bit) directory changes the existing data path and can collide across distinct identities; remote_server_daemon_data_dir stores the daemon SQLite DB under this directory, so this can orphan existing state or make two identities share daemon/data state. Use a stable digest with enough bits and migrate from the previous percent-encoded directory before switching.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't need migration here. SQLite DB is unused right now

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cool, as long as we use the actual right identity key for sqlite directory i'm good

Comment thread app/src/remote_server/unix/proxy.rs
Comment on lines +119 to +122
anyhow::bail!(
"daemon socket path is {path_len} bytes, which exceeds the \
platform sun_path limit of {SUN_PATH_MAX} bytes: {}",
socket_path.display()
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the case we hit this, what do we or the user do?

Copy link
Copy Markdown
Member Author

@kevinyang372 kevinyang372 May 15, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is realistically never going to happen after this fix. It is just a safe guard so we could return clearer errors rather than hitting generic timeout

Comment thread crates/remote_server/src/setup.rs Outdated
Comment thread crates/remote_server/src/setup.rs
@kevinyang372 kevinyang372 enabled auto-merge (squash) May 15, 2026 15:44
@kevinyang372 kevinyang372 merged commit 18baecd into master May 15, 2026
28 checks passed
@kevinyang372 kevinyang372 deleted the kevin/fix-socket-path-length branch May 15, 2026 15:50
lawsmd pushed a commit to lawsmd/cortex that referenced this pull request May 22, 2026
)

## Description

PR warpdotdev#10782 ("Version aware daemon socket") changed daemon socket
filenames from `server.sock` (11 chars) to
`server-v0.2026.05.13.09.15.stable_01.sock` (41 chars), adding ~30 bytes
to the Unix domain socket path. This pushes users over the `sun_path`
limit (107 bytes on Linux, 103 on macOS), causing `UnixListener::bind`
to fail silently in the daemon. The proxy then times out after 10s,
exits with code 1, and the client sees `ResponseChannelClosed`.

This accounts for the ~20% drop in remote server initialization success
rate (90% → 70%). Sentry issue: WARP-CLIENT-BETA-STABLE-7M9M (11
occurrences across 9 users, all anonymous with 36-char UUID identity
keys).

**Fix (two changes):**

1. **Hash the version string** in socket/PID filenames to an 8-hex-char
suffix (`server-a1b2c3d4.sock`, 20 chars) instead of the full version
string (41 chars).

2. **Hash the identity key** directory name to 8 hex chars instead of
using the raw identity key (up to 36 chars for anonymous UUIDs). This is
needed because longer channel base dirs like `.warp-preview` (+8 chars
vs `.warp`) would otherwise narrow the headroom too much on macOS.

Both changes use `std::hash::DefaultHasher` for deterministic,
fixed-length output. The existing `cleanup_old_versions()` logic
automatically cleans up old long-form files.

Also adds an explicit `sun_path` length guard in the proxy that fails
fast with a clear error message instead of silently timing out.

**Worst-case path after fix:**
`/home/{32-char-user}/.warp-preview/remote-server/{8-char-hash}/server-{8-char-hash}.sock`
= **97 bytes**, well under both limits (103 macOS, 107 Linux).

Fixes WARP-CLIENT-BETA-STABLE-7M9M

## Linked Issue
- [x] The linked issue is labeled `ready-to-spec` or
`ready-to-implement`.

## Testing
- 10 unit tests: version hash determinism, identity key hash (length,
determinism, uniqueness), socket/PID name length bounds, and worst-case
path length regression test against the preview channel (longest base
dir)
- Validated via Docker containers on linux/amd64, linux/arm64, and
macOS/aarch64 with the actual 9 Sentry-reported identity keys
- Cross-referenced Sentry events to confirm all affected users are
anonymous (36-char UUID identity keys)
- `cargo fmt` and `cargo clippy` pass

- [x] I have manually tested my changes locally with `./script/run`

## Agent Mode
- [x] Warp Agent Mode - This PR was created via Warp's AI Agent Mode

Co-Authored-By: Warp <agent@warp.dev>

<!--
CHANGELOG-BUG-FIX: Fixed remote server connections failing for some
users due to the daemon socket path exceeding the OS length limit.
-->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants