Keys that are worthless if copied#
A Lockpin key copied off its machine does not work anywhere else. A bait key tells you when someone tries one. Every key has a daily limit, so even a key used where it is allowed can spend only so much. This page is for the admins who make keys.
What each part stops#
Who has a copy of the key |
Bound to |
Bound to a machine |
Provider key on a team node |
|---|---|---|---|
A program on another machine |
Refused |
Refused |
Out of reach |
Another user’s program on the same machine |
Not stopped |
Refused: the forwarder needs your token |
Out of reach |
A program running as you on the bound machine |
Not stopped |
Not stopped |
Out of reach; what it spends is bounded by the caps |
A binding stops a copy used on another machine. A program running as you on the bound machine can use the key there: it can read your forwarder token, unseal your machine key and call the forwarder. What a stolen key can spend is bounded by the caps: its daily limit, plus whatever open team grants (pools) the key still has, and the task budgets.
Bindings#
New keys are bound to loopback: only calls from this machine are accepted. On a node that
listens beyond loopback (a LAN or VPN address), lockpin keys create asks you to choose with
-bind. A running node records where it listens in lockpin-listen.json beside the keys file; until
it has started once, create asks for -bind too.
lockpin keys create alice # $20 a day, bound to loopback
lockpin keys bind alice loopback
lockpin keys list # the BOUND column
A call that breaks its binding gets the same answer an unknown key gets, so whoever tried it
learns nothing. A misuse alert goes to the alert destinations configured on the node (Slack,
Teams, ntfy, the webhook, a paired phone) and the meter:
Key "alice" used from 192.0.2.7 (not its machine). Refused. Key frozen. $0.00 spent by that call.
The key is frozen at once when the use could only be someone else’s: a loopback key from another
address, or a machine key whose call claims another machine. Lockpin reads the address of the connection
itself, never X-Forwarded-For. A proxy or tunnel on the node’s own machine would make every
caller look local, so a loopback key’s call that carries Forwarded, X-Forwarded-For or Via
is refused (and alerted, not frozen), and lockpin doctor repeats it. A proxy or tunnel that adds
none of those headers cannot be detected: do not put one in front of a node that has loopback keys.
Bind a key to another machine#
For a team node that people reach over the network:
On the person’s machine:
lockpin node join -key alice
It makes the machine’s key, sealed for that user, and a forwarder token only that user can read, and prints a line.
On the node, an admin runs the line it printed:
lockpin keys bind alice machine lpm1....
On the person’s machine, run the forwarder and start agents with
lockpin run:lockpin -upstream-node https://NODE:8787 lockpin run -- claude
The forwarder listens on loopback only and answers only callers that show this user’s token, which
lockpin run puts in the agents’ base URLs. It signs each call with the machine key: the method,
path, body, the call’s credentials and its X-Lockpin-* headers. The node checks the signature,
that its time is within 60 seconds, and that it has not seen the call before. The signature is a
header, so it passes through a company proxy that inspects TLS. Use https for a node beyond this
machine: over plain http the key itself crosses the network readable, and the forwarder warns.
Always go through the forwarder, for the member page too: open it with lockpin open (see
Pages in your browser). A call that skips it, or whose signature does not
match, is refused and alerted but does not freeze the key, as it can come from the key’s own
machine. So is a call sent twice, one more than a minute off the node’s clock, and one dated before
the node last started: the node remembers calls in memory only, so after a restart it refuses older
proofs rather than risk a replay.
Pages in your browser#
A browser cannot send the token in a header, and a link that carries it
(http://127.0.0.1:8787/f/TOKEN/lockpin/me) stays in the browser’s history and its restored
sessions and, on Linux and macOS, in a command line other users can read. So a page is opened
with a one-time link:
lockpin open # your own page, /lockpin/me
lockpin open team
The VS Code extension does the same for Lockpin: Open meter and Open wallets on the meter.
lockpin openasks the forwarder for a link, with the token in theX-Lockpin-Forwarderheader (POST /f/code). Only a program that can read your token file can ask.The forwarder answers with
/f/open/CODE. The code is 256 random bits, works once, for 30 seconds, and only for the page it was asked for:/lockpin/,/lockpin/me,/lockpin/teamor/lockpin/setup. At most 16 wait at a time.Your browser opens
http://127.0.0.1:PORT/f/open/CODE. The forwarder makes a session: a random path,/s/SESSION/, and a cookie for that path only (a random value that has nothing to do with the token,HttpOnly,SameSite=Strict, for127.0.0.1only). It sends the browser to the page under that path,http://127.0.0.1:PORT/s/SESSION/lockpin/me, and takes the path off before it signs and forwards.With the cookie, under its own session’s path, the forwarder passes the four pages, their files, and only the calls those pages make: your own page’s reads and its grant request, the team page’s reads and changes, the setup page’s reads, and the list of wallets. Every other call needs the token: a model call (
/v1/...,/anthropic/..., a task or wallet path), the test call, answers to held calls, budgets, keys, teams, the breaker, pauses, and every change to a wallet. Nothing in a browser can spend through it. Agents still need the token.
lockpin open sends the token only to the address your running forwarder recorded when it
started (lockpin-forwarder.json beside the token, readable by you only), never to a default
address. With no forwarder running it sends nothing and says so.
It also makes what listens there prove it is your forwarder first. The file holds a random secret,
new each time the forwarder starts. lockpin open sends a random nonce to POST /f/prove, with
no token, and the forwarder answers HMAC-SHA256 of a fixed label and the nonce under the secret.
The token is sent only after a correct answer. The secret signs nothing else, the call is limited
to 20 in 10 seconds, and it is held to this machine like every other call to the forwarder.
Invites made on the team page through the forwarder: the page is at the forwarder’s 127.0.0.1
address, which nobody you invite can reach, so the invite’s address field starts empty there.
Enter the address members reach the node on. It is remembered for the next invite.
The session ends 30 minutes after its last request and 8 hours after it was opened, and when the forwarder stops. Codes and sessions are kept in the forwarder’s memory only, and neither is logged. The forwarder takes the cookie off before it signs a call, so the node never sees it. A wrong, used or expired link gets a page that says to open the page again.
What it stops:
The token in an address. It is in no link, so not in history, a restored session or a command line.
Another user of the machine. They cannot ask for a link: they cannot read your token.
Another program’s port on this machine. A browser keeps one set of cookies for every port of
127.0.0.1. The session’s cookie is for the path/s/SESSION/only, so the browser sends it only to a request under that path, which no other program knows. The cookie without its path opens nothing, and neither does the path without the cookie.A page on another site, or on another port of this machine. The cookie is taken only for requests the browser marks as coming from the forwarder’s own address, reads included, and only at the
Hostthe link was opened at. The forwarder still refuses anyHostthat is not this machine (DNS rebinding) and any page on another site. The pages are told to send noReferer, so the session’s path is not told to another site.The name
localhost. Links use127.0.0.1itself, and the forwarder takes a link or a cookie only there. By the namelocalhosta browser can reach the other loopback family, where another user may be listening on the same port.A link used twice. The second use is refused, and it ends the session the first use opened, for as long as that session lasts. If something else used the link first, your browser opening it shuts that out, and you see the refusal page.
What it does not stop:
A program running as you. It can read the token and ask for links, as it can use the key.
A program that can read your browser. One that has both the cookie and the session’s path (from the browser’s own files, as you) can make the calls the pages make until the session ends. It could read the token too. The session’s path is in the browser’s history; alone it opens nothing. Restart the forwarder to end every session.
A link read in its 30 seconds. On Linux and macOS the opener’s command line can be read by other users for a moment. A code used from there works once; when your own browser then opens the link, that session ends and you see the refusal page.
A forwarder that stopped without tidying up. If it is killed, its recorded address stays.
lockpin opensends that port nothing: whatever listens there now cannot prove it knows the file’s secret.lockpin runhas no such check: it puts the token in the agents’ base URLs for the port it is given, so start agents only while your forwarder runs.Another user of this machine can ask your forwarder for proofs, up to the limit, and so make
lockpin openwait a few seconds. A proof is of no use to them.Browsers other than Chromium were not tested. The same-origin rule relies on the browser marking its requests (
Sec-Fetch-Site,Origin); a browser that sends neither is not held by it. The cookie’s path does not depend on that: it is what keeps the cookie from other ports in any browser.
Passkeys do not work through the forwarder. A passkey belongs to a name (localhost, or an
https address), never to an IP address, and the forwarder’s pages are at 127.0.0.1 for the
reason above. A passkey confirmation (unfreeze, a raise above an allowance, a wallet) is done on
the node’s own meter, by an admin or on the node itself. The page says where when you try.
A team node shows its meter (/lockpin/, the Wallets panel, the setup page) only on the node
itself. Through a forwarder on another machine, the pages it serves are yours (/lockpin/me) and
your team’s (/lockpin/team).
Frozen keys#
A frozen key is refused like a disabled one. On its own machine the answer says it is frozen, not why; the node’s alerts and meter say why. Unfreezing is a loosening:
on the node:
lockpin keys unfreeze aliceon the meter: Unfreeze in the Keys panel, confirmed with your passkey
Both raise a loosened alert. If the key was copied, rotate it (lockpin keys rotate alice)
before you unfreeze it. Someone who has a copy can freeze a key by using it from elsewhere; the
alert says so, and the answer is to rotate it.
Bait keys#
A bait key looks like any Lockpin key but never works. Plant it where nothing of yours reads it,
such as a .env beside the real one:
lockpin keys bait demo -guard alice -out leak.env
leak.env holds two lines: ANTHROPIC_API_KEY=lp_... and an ANTHROPIC_BASE_URL of this node.
Every use is refused exactly as an unknown key is and raises a bait alert. Its first use freezes
the -guard keys:
Bait key "demo" used from 100.64.0.7 (not this machine). Refused. Key "alice" frozen. $0.00 spent.
Later uses freeze nothing (“its guards were already tripped”): whoever holds the file cannot freeze a key again after you unfreeze it. Repeated uses send one alert per bait key per 10 minutes, then one with the count.
After a trip, rotate the keys it guards (the file was beside them), then re-arm the bait with a fresh file, or disarm it:
lockpin keys bait demo -guard alice -out leak.env # re-arm: a new secret and new lines to plant
lockpin keys bait demo -guard '' # disarm: it still alerts, freezes nothing
lockpin keys disable demo # disarm too
lockpin keys unfreeze and lockpin doctor remind you while a tripped bait still lists a key.
What a bait key catches: a program that reads the planted file and uses it at the address in it, such as a prompt-injected agent, a package that steals files, or a person using the file as found. What it misses: a key tried only at a provider’s own address, and anyone who cannot reach the node. It reaches only this machine and the networks the node listens on.
Daily limits#
Every key has a daily limit: $20 unless you give -day. A key with no daily limit needs
-no-day-limit on the node, or removing it on the meter with a passkey; both raise a loosened
alert. The daily limit is hard: it is never held for a yes, and a yes at a task’s budget never
raises it. A team grant can let a key spend more, up to the grant’s amount, but it never removes
the daily limit, never changes a binding, and never targets a bait key.
Upgrading from an older Lockpin#
Keys made before this version keep working as they did: one with no binding works from any
machine, and one with no daily limit keeps none. Lockpin warns at start, and lockpin doctor and
lockpin keys list name them. To give them the default daily limit and a binding:
lockpin keys harden # shows what it would change
lockpin keys harden -yes # changes it
The provider’s own key#
Everything above is about a Lockpin key. The provider’s own key is not covered by a binding: whoever
holds a copy can call the provider directly, and no Lockpin cap sees that call. The
outside-spend check (-outside-check) detects it after the fact. It
reads the provider’s usage per key with an admin key and alerts when the provider billed a key for
use that did not go through this Lockpin. It detects and does not stop anything, and it cannot say who
used the key or that it was copied. lockpin doctor -exposure lists where provider keys lie in plain
files and in the environment of this machine.
Provider keys sealed on your own machine#
On one person’s machine, without a team node:
lockpin keys seal anthropic -solo < anthropic.key
The key is sealed for your user in Lockpin’s data folder, and a keys file is made there with one
key, me, bound to loopback with a $20 daily limit. Start Lockpin with the -keys and
-provider-keys-sealed flags it prints, take the provider keys out of your shell profile and
.env files, and start agents with lockpin run -- claude: the agent’s environment then holds
me, never a provider key.
This protects copies of your environment: a dumped environment, a CI log, a committed .env. It
does not protect against a program running as you. Such a program can unseal the store and spend
the provider key at the provider directly, with no Lockpin limit at all. The meter says “sealed for
your user: protects copies, not this account”.