Skip to content

feat(server): optional Unix-domain socket for CDP - #4023

Merged
karlseguin merged 2 commits into
lightpanda-io:mainfrom
mcc0nnell:feat/cdp-unix-socket
Oct 18, 2026
Merged

karlseguin merged 2 commits into
lightpanda-io:mainfrom
mcc0nnell:feat/cdp-unix-socket

Conversation

@mcc0nnell

Copy link
Copy Markdown
Contributor

Summary

Add an opt-in lightpanda serve --socket /absolute/path/lightpanda.sock transport for CDP HTTP/WebSocket instead of opening a TCP listener. This is the small, native first step discussed by the maintainer in #3452; it intentionally does not add a bearer-token scheme or claim to protect against processes sharing the same Unix identity.

The existing TCP mode remains the default.

Behavior

  • --socket is mutually exclusive with --host, --port, and --advertise-host; Unix mode is CDP-only rather than advertising an invalid WebDriver BiDi session URL.
  • Reuses the existing HTTP/CDP WebSocket handlers over an AF_UNIX listener instead of TCP.
  • Requires an absolute socket path and rejects overlong paths.
  • Creates the socket with mode 0600, refuses to overwrite an existing path, and unlinks its socket on normal shutdown.
  • In Unix mode, GET /json/version returns webSocketDebuggerUrl: null rather than a fictitious TCP URL. Unix-aware clients connect to the socket directly.
  • Does not change TCP-origin validation, default CDP behavior, or browser implementation.

Verification (Linux x86_64, Zig 0.17.0, upstream main 2ad3877)

  • make download-v8: prebuilt V8 installed.
  • zig build -Ddev_fast=true: PASS.
  • make test: 1,877/1,877 passing, 7 skipped by upstream runner.
  • zig fmt --check ./*.zig ./**/*.zig: PASS.
  • Native executable integration: PASS:
    • Unix socket mode 0600, no TCP listener opened by this server
    • HTTP /json/version 200, null WebSocket discovery URL
    • Unix-socket WebSocket upgrade 101, CDP Browser.getVersion protocol 1.3
    • pre-existing path preserved, conflicting --port rejected, socket removed on SIGTERM
  • Targeted native tests cover connection acceptance, path validation, duplicate paths, CLI behavior and cleanup.

Security scope

Unix socket permissions do not isolate processes sharing a Unix identity, or those with ptrace/Docker/administrator authority. Per-peer SO_PEERCRED, PID or pidfd authorization are not in scope; those are separate design decisions. This references #3452 but does not close the broader authentication question.

Thanks for the guidance on #3452. Happy to adjust the interface or tests to fit project conventions.

@github-actions

github-actions Bot commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@mcc0nnell

Copy link
Copy Markdown
Contributor Author

I have read the CLA Document and I hereby sign the CLA

Allow WebDriver protocol (yes, we might advertise an invalid session URL, but
I think if someone uses --unix-socket, they'll be able to deal with that (at
least we can give them the chance to))

Dedupe json/version payload generation

Centralize all flag validation in Config.zig
@karlseguin
karlseguin merged commit f734e7f into lightpanda-io:main Oct 18, 2026
25 checks passed
@karlseguin

Copy link
Copy Markdown
Collaborator

Thanks. I renamed the option to --unix-socket and did some other fairly superficial changes.

@github-actions github-actions Bot locked and limited conversation to collaborators Oct 18, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants