Skip to content

Check lease targets when acquire returns and reach leases by the client's key - #46

Merged
lydakis merged 7 commits into
mainfrom
claude/errand-fix-targets
Oct 6, 2026
Merged

lydakis merged 7 commits into
mainfrom
claude/errand-fix-targets

Conversation

@lydakis

@lydakis lydakis commented Oct 6, 2026 •

Copy link
Copy Markdown
Owner

Before: a provider command could return a target no client can use (both url and ssh, a non-HTTP URL, a bad SSH name, a malformed host_key). The cloud peer accepted it and kept the machine until acquire_timeout. A target with ssh but no host_key never offered the client's errand key, so a machine that only admits that key turned the client away. Starting any lease needed ssh-keygen on the client, even for a URL-only lease. An SSH connection opened to a host before its lease host key was pinned could be reused for the lease. A .pub rebuilt without the errand comment counted as a different key, which hid ready leases from that device. A device let into a lease by name could be shown a short peer name that another lease also matched.

After: the cloud peer checks the target as soon as acquire exits, using the same rules as configured peers and clients. A bad target fails the launch with provider target: ..., and the machine is released right away. Clients offer their lease key to every SSH lease target. If the host key is pinned, only that key is offered. If it isn't, the key is offered alongside the user's own keys and known_hosts applies. errand makes its own ed25519 keys (the client lease key and the Lambda host key), so neither the client nor the cloud peer needs ssh-keygen. Clients and the cloud peer compare SSH keys by type and data only. A device let into a lease by name gets a name that is unambiguous among all of the cloud peer's leases.

How: a new proto.CheckPeerTransport holds the url/ssh/remote_command/remote_socket rules, and config.PeerURL uses it. LeaseTarget.Check builds on it and adds the host key rules. The broker's checkTarget and the client's leaseTargetPeer both call Check. proto.SSHKeyBody/SameSSHKey replace cloud.ValidSSHPublicKey, the Lambda provider's sshKeyBody and the client's host key parsing. They accept only keys OpenSSH loads as host keys: ed25519, NIST ECDSA (point on the curve) and RSA (1024 to 16384 bit modulus, odd exponent of at least 3). This is a check of form, not a cryptographic audit, and a test compares it with ssh-keygen when that is installed. Each TrustSSHHost registration replaces what an earlier one said about its target, and it now accepts an identity without a host key. The SSH round tripper keeps one pool per endpoint, tagged with the trust it was opened under. When that trust changes, a new pool replaces the old one, whose idle connections close. Ordinary SSH peers have no trust entry, so their pool never changes, at the cost of one extra map lookup per request. client.NewSSHKey writes OpenSSH's unencrypted key format with the Go standard library. A key and its .pub are written into a directory of their own that is renamed into place whole, so errand never reads private keys back. The client's lease key and the Lambda cloud peer's key move into such directories (ssh/lease/ and lambda/key/ under the state directory). A key in the old place is left alone, and a new one is made and admitted on first use.

Closes items in #33: Lease identity dropped without a host key; Invalid provider targets accepted; Lease setup needs ssh-keygen; SSH transport pool ignores pinned trust; SSH keys compared with their comments; An admitted lease peer can get a too-short name.

🤖 Generated with Claude Code

https://claude.ai/code/session_013BQxiCNDXMnjv5pvmgo5E6


Generated by Claude Code


Generated by Claude Code

A cloud peer now refuses a provider target that no client could use (url
and ssh both set, a non-HTTP URL, a bad SSH name, a malformed host key) as
soon as acquire returns, with the same check configured peers and clients
use, so its machine is released at once instead of at acquire_timeout.

Clients offer their lease key to an ssh target whether or not the cloud
peer pinned its host key, pool SSH connections by the host key and keys
they trust, so an unpinned connection is never reused for a pinned lease,
and compare SSH keys by type and data without comments. errand makes its
SSH keys itself, so a client needs no ssh-keygen, and a device let into a
lease by name is named against all the cloud peer's leases.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_013BQxiCNDXMnjv5pvmgo5E6

lydakis commented Oct 6, 2026

Copy link
Copy Markdown
Owner Author

github-advanced-security fails on GitHub's side (Copilot autofind quota/model error), as on every PR in this repo; it isn't this change, and a re-run returns 403 from here. CodeQL itself runs as a separate check.


Generated by Claude Code

@lydakis
lydakis marked this pull request as ready for review October 6, 2026 01:54
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 6, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-06T02:58:16.316334Z 953285a New commits
🔒 Security Review ✅ Completed 2026-10-06T02:21:42.748652Z 5cb66ba New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: bf2d4d697e

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread internal/client/ssh_pin.go Resolved
An unpinned lease registered for a user@host that an earlier lease had
pinned kept the old host key, so a long-lived cloud peer would refuse the
new machine at a reused address. A registration with another host key, or
none, now replaces what the process trusted about the target, and a target
left with no pin and no keys is an ordinary peer again, sharing its pool.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_013BQxiCNDXMnjv5pvmgo5E6

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 72c20e9d53

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread internal/proto/lease_target.go Resolved
A key whose data was any decodable base64, such as "ssh-ed25519 AAAA",
passed as a lease target's host key, so the cloud peer waited out
acquire_timeout on a machine no client could trust. The key data is now
parsed as SSH's wire format: the type inside must match the declared one,
and the fields must be those of ed25519, RSA, NIST ECDSA (with the point
on its curve), or their security-key forms, with nothing left over.
Strict base64 gives every key one spelling.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_013BQxiCNDXMnjv5pvmgo5E6

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 5cb66ba648

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread internal/proto/lease_target.go Resolved
Comment thread internal/client/ssh_key.go Resolved
Comment thread internal/client/ssh.go Resolved
claude added 2 commits October 6, 2026 02:27
errand no longer reads its private keys back: a key and its public half
are written into a directory of their own that is renamed into place, so
a reader finds the pair or nothing, and a process that loses the race uses
the winner's. The client's lease key and the Lambda cloud peer's key move
into such directories; keys in the old places are left alone and new ones
are made.

Keys are accepted only as OpenSSH host keys: ed25519, NIST ECDSA and RSA
with a 1024 to 16384 bit modulus and an odd exponent of at least 3. A test
checks the rule against ssh-keygen when it is installed.

Each SSH endpoint keeps one connection pool, tagged with the trust it was
opened with. When the trust for its target changes, a new pool replaces it
and the old one's idle connections close, so trust that rotates with every
lease at one address no longer grows the pools.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_013BQxiCNDXMnjv5pvmgo5E6
The Lambda install check keeps main's private copy of errand_binary and
drops its ssh-keygen requirement, since errand makes its SSH keys itself.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_013BQxiCNDXMnjv5pvmgo5E6
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for security reviews. Please try again later.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ea548f0114

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread cmd/errand/leases.go Resolved
Keeps the Lambda catalog from main. The install check needs only ssh,
since errand makes its SSH keys itself, and the docs no longer ask for
ssh-keygen.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_013BQxiCNDXMnjv5pvmgo5E6
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for security reviews. Please try again later.

Keeps both sides' lease tests in leases_interrupt_test.go.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_013BQxiCNDXMnjv5pvmgo5E6
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for security reviews. Please try again later.

@lydakis
lydakis merged commit 0438fe1 into main Oct 6, 2026
8 of 9 checks passed
@lydakis
lydakis deleted the claude/errand-fix-targets branch October 6, 2026 03:01
lydakis pushed a commit that referenced this pull request Oct 6, 2026
… them

Narrow the leased-machine admission guarantee to include the offer's
allow_users and leave provider-command machines to their operator; say
only the Lambda provider installs errand; limit the bounded-output
guarantee to the cloud peer's provider and SSH commands; describe
max_leases as a cap on new leases and when the Lambda price is checked;
note that a restart starts a fresh idle window; and add the target check
on acquire that #46 brought.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01LXfrreiGwp7WUvn3ubCMTS
lydakis added a commit that referenced this pull request Oct 6, 2026
* Bring the security policy up to date with cloud leases and Windows

SECURITY.md predated cloud peers, the Windows runner and the runner
heartbeat. It now describes leases and their owners, what a leased
machine admits, how cloud peer secrets and installs are handled, the
release rules, the lease-specific accepted limitations, the Windows
process scope and batch argument refusal, and that a lost heartbeat
never resubmits a job.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01LXfrreiGwp7WUvn3ubCMTS

* Describe lease admission, limits and target checks as main implements them

Narrow the leased-machine admission guarantee to include the offer's
allow_users and leave provider-command machines to their operator; say
only the Lambda provider installs errand; limit the bounded-output
guarantee to the cloud peer's provider and SSH commands; describe
max_leases as a cap on new leases and when the Lambda price is checked;
note that a restart starts a fresh idle window; and add the target check
on acquire that #46 brought.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01LXfrreiGwp7WUvn3ubCMTS

* Qualify lease revocation, release and lost-runner guarantees

A failed EndAll leaves leases until the next request, idle and lifetime
rules start a release rather than cutting access, Lambda release also
accepts preempted or vanished instances, and a stalled stream reports
the runner's state when it still answers.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01LXfrreiGwp7WUvn3ubCMTS

* Cover Windows job environment, tailnet capability grants and Lambda gaps

List the Windows job environment allowlist, count tailnet capability
grants on the lease tag among those a Lambda machine admits, say that
admitted callers have root on Lambda machines, and describe two gaps as
they are on main: the tailnet auth key is removed only after the runner
starts, and configured Lambda offers have no price cap.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01LXfrreiGwp7WUvn3ubCMTS

* Keep lease guarantees to what the cloud peer enforces

Say that whether to lease is the client's choice, scope the archive
guarantee to what it carries, drop the Lambda release-confirmation
detail that docs/CLOUD.md owns, qualify the spending limits, limit the
root note to callers that can run jobs, and say unknown state is
reported whenever the runner returns none.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01LXfrreiGwp7WUvn3ubCMTS

---------

Co-authored-by: Claude <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants