Repository navigation
Replies: 1 comment 1 reply
|
The prototype’s stale-ticket result seems especially useful for the rollout gate. Could the client test record both the handshake outcome and whether the server received any credential-bearing bytes after a pin change? Run that separately for each native networking stack; a passing Node hook cannot establish the mobile paths. AI-assisted review suggestion, not an independent validation of the protocol. |
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Pinned TLS for direct connections
Status: proposal.
Source links and line numbers refer to commit
15fe283272.T3 Code servers listen only on plain HTTP. Credentials are protected on the
wire only when something in front of the server adds TLS: Tailscale Serve,
T3 Connect, or a reverse proxy. Everywhere else, pairing codes and bearer
tokens travel in clear. Peer links try to limit that with a hostname check that
trusts some addresses by how they are spelled.
This proposal has the server terminate TLS itself with a self-signed
certificate. A client authenticates that certificate with its pairing code.
Pairing also gives the client a pin key, a 256-bit secret that authenticates
any later certificate, so the code is used once and never again. The pairing
URL gains no fingerprint or version field; codes grow by four characters, or
eight for long-lived ones.
What it delivers. Desktop, mobile, CLI, and peer-link clients on direct
routes to an upgraded server get encrypted, authenticated transport. Once a
client pairs with a code from an upgraded server, nothing it sends to that
environment travels in clear again, and an active attacker can only block the
connection.
This proposal, if implemented, would leave a two tiered system. Native clients
and peer links that pair with a new code get the guarantee above. Browsers
on plain HTTP and old versions stay as they are today, and so does anything
that passes through them, including pairing codes.
What it does not cover:
http://routes. They cannot pin a key, and anattacker can rewrite a page served over plain HTTP anyway
(Future work). This includes the server's startup
pairing URL opened in a browser. A phone camera scanning the startup QR code
also opens the browser, not the T3 app. The code then crosses the network in
clear, as today. Native clients that use the same URL or code are covered,
including the T3 app's own scanner and the
t3code://pairlink.if it reaches the client out of band (a QR code, the terminal, typing) or
over a pinned or
https://connection. A code created in a browser overplain HTTP has already crossed the network in clear. So has one that the
link-request card mints on an environment and carries to another over an
unpinned route
(peerPairingCode.ts).
code in clear, after the user agrees to it.
An attacker on the path at that moment can keep them on plain HTTP.
cloudflaredon the host carries traffic to the server, and T3's relaybrokers credentials, so all three stay trusted, as today. Pins learned over
Connect trust them too (section 7). Similar work has been proposed for T3 Connect (End to end encryption for T3 Connect #21286).
An
http://route inside WireGuard or Tailscale is already encrypted, and oneacross café Wi-Fi is not. The application cannot tell them apart. So whether
plain HTTP is allowed depends on what the client expects of the server, never on
the address it dials.
The problem
What crosses the wire
On a plain
http://route:/oauth/mcp/decisionbody(PeerLinks.ts:270). The 30-day
access token comes back in the
/oauth/mcp/tokenresponse(EnvironmentAuth.ts:74).
Every call then sends
Authorization: Bearer <token>(PeerMcpClient.ts:108).
/oauth/token, the30-day session token comes back, and later requests carry it.
rewrite.
A link made with
autoorfull-accessaccess lets agents run unattended onthe peer. A passively captured link token therefore gives remote code execution
on the peer until it expires (30 days by default) or is revoked. One command is
enough to leave behind something that outlives it.
The peer-link hostname check
peerOriginacceptshttp://only for loopback and for what
isTailnetHostcallstailnet: a name ending in
.ts.net, or an IPv6 address infd7a:115c:a1e0::/48. It checks the address string, not the path packetstake:
Tailscale's own
100.64.0.0/10IPv4 addresses, although all of those areencrypted.
.ts.netname however that nameresolves. When MagicDNS is not answering for the process (tailscaled stopped,
or
--accept-dns=false, which is common on Linux servers), the name goes tothe network's resolver. A hostile network then receives the pairing code and
token. /etc/hosts and
LD_PRELOADcan redirect the name too, but anyone whocan do that can already read the token from the secret store.
it is this peer" (PeerLinks.ts:560)
compares an environment id the server reports without authentication. It
catches a LAN address that now belongs to another machine, which is its stated
purpose in remote.md, but any attacker can
echo the id.
The rest of the product already sends the same class of credential over plain
LAN HTTP:
http://<lan-ip>:<port>/pair#token=…(startupAccess.ts:139).
NSAllowsArbitraryLoads(app.config.ts:266).
tokenAllowsPlainHttplets a token paired over plain HTTP keep using plain HTTP.
The check gives false assurance on
.ts.netnames, refuses encrypted networks,and does not match how clients behave.
Proposal
1. TLS on the existing port
The server keeps a P-256 key pair and a self-signed certificate for it in the
server secret store, next to the session signing secret. The certificate does
not expire: its
notAfteris99991231235959Z, whichRFC 5280 reserves
for that, and its
notBeforeis a fixed date long past, 1 January 2000.Clients ignore its name, and no client clock falls outside its dates. The key
changes only through recovery or a
planned change, such as moving off P-256, and clients authenticate a new
certificate with their pin key (section 5).
The listener sniffs the first byte of each connection.
0x16(a TLS handshakerecord) goes to a
tls.Server, which accepts only TLS 1.3 and whose decryptedsockets are re-emitted into the same HTTP server. Anything else goes to the
HTTP parser as today. There is one port, one router, and WebSocket upgrades
work unchanged. The private-network connection filter
(server.ts:315) still runs first on the raw
socket.
Whether a request arrived on a direct TLS socket is a property of the socket,
carried into the HTTP server with it. No header can claim it. It decides only
whether the key-pin endpoint answers and whether a pin key is issued.
Pinned TLS sits below HTTP, as WireGuard or an SSH forward does. The server
still derives request URLs from Host and
X-Forwarded-Proto(environment-auth.md), so a request over
pinned TLS to
http://host:portkeeps that URL. DPoP proofs, OAuth metadata,and redirects use it unchanged. This is an invariant, held by a test: the
server never derives an
https://URL from a TLS socket.The pin is
base64url(SHA-256(certificate DER)). For a certificate signed withSHA-256, that hash is the
tls-server-end-pointchannel binding ofRFC 5929.
2. The key-pin endpoint
A client asks the server to vouch for the certificate it sees with one of
three credentials: a pairing code's id when pairing, its session id when a
pinned environment's certificate has changed, or, once, a token's claims when a
pairing from before the upgrade first pins.
How the server finds the credential:
auth_pairing_links.credential. The server derivesKfor each of its live16- and 20-character codes with the client's nonce, two HMACs per code, and
finds the one whose id matches. The lookup does not consume the code.
12-character codes never match: at 60 bits, the offline search in
section 8 is within reach.
HMAC-SHA256(signingSecret, "t3-pin-key-v1" 0x00 sessionId). The serverchecks that the session is live and derives the key. It stores nothing new.
The 0x00 byte keeps these apart from token signatures, which sign base64url
text.
the first time (Existing pairings). Session
tokens are
base64url(claims) "." HMAC(signingSecret, claims)(SessionStore.ts:682). The
server rebuilds the token from its claims half, checks that the session is
live, and derives
Kfrom the token. Tokens are stateless andauth_sessionsstores no token hash
(031_AuthAuthorizationScopes.ts:32),
which is why the selector is the claims half rather than
SHA-256(token).The claims half is not secret: it travels in clear in every plain HTTP request
today, and it carries no authority without the signature.
Issuing the pin key. Wherever a pairing ends in a session, the response
that carries the token also carries
pinKey:/oauth/tokenfor clients,/oauth/mcp/tokenfor peer links. The server includes it only on a direct TLSsocket. No endpoint returns it later, so a token can never be turned into a pin
key. The client stores it with the token and discards it when the session
expires.
Rules:
pin and environment id. The client contributes a nonce and a credential
selector, never MAC input of its choosing, so the endpoint cannot be made to
vouch for any other key.
Kfor everycredential kind, under one versioned label. An answer recorded for one nonce
does not verify for another.
claims can ask the real server for a MAC under that pin key or token, and
test guesses against it. Pin keys and token signatures are 256-bit HMAC
outputs, so that search is infeasible. The pairing code is the only short
secret, and only a code request gives an interceptor something derived from
it.
Tailscale Serve or T3 Connect, the key the client sees belongs to the proxy,
so a pin would be meaningless.
environmentIdinto the MACmakes "this address is the environment I linked" an authenticated claim,
which the descriptor check alone could never be.
own limits: a small body cap, a nonce of exactly 16 bytes, a global cap on
concurrent requests, and a per-address rate. The per-address rate exempts
loopback, because behind an
ssh -Lforward every client arrives fromloopback, and one client could otherwise lock out the rest. The limits bound
resource use and online guessing. They cannot stop a network attacker from
blocking connections, and code length is what stops offline search.
3. The code tells the client what to expect
Only upgraded servers issue 16- and 20-character codes. Old servers issue 12,
and the reusable dev credential is at least 32 characters
(config.ts:180). However the code is
entered (a QR code, a pairing link, typing, or a CLI argument), it does not
cross the network the attacker controls, so the attacker cannot change its
length. That makes the length a version signal the attacker cannot forge, and it
needs no extra field. The rule is easy to break from the issuing side, so the
code-issuing service states it in a comment: a server issues 16- and
20-character codes only if it serves TLS.
gets a failed connection. One who intercepts it gets an offline check on the
code, which section 8 sizes
codes against.
so one act of interference does not last for the life of the process. The cost
is one round trip per connection to an old server.
explain that the server is too old to encrypt and ask before pairing. Peer
links need
--allow-plaintextor its equivalents(section 6).
client cannot carry the handshake, so a new code fails behind it. TCP forwards
such as
ssh -Lcarry TLS through, and HTTPS proxies usehttps://routes,which keep normal certificate validation. There is no escape hatch until
someone needs one.
and browsers cannot act on the signal.
4. Client flow for an
http://routehttps://and loopback routes are unchanged. A pinned route keeps itshttp://URL. The client sends requests and signs DPoP proofs for that URL,and its network stack carries them over pinned TLS to the same host and port.
port, accepting any certificate. Record the certificate from the handshake.
This connection carries no credentials: no cookies, no
Authorizationheader, no TLS early data. It follows no redirects and joins no connection
pool.
POST /api/auth/key-pinwith a fresh nonce and the selector: thecode id when pairing, the session id when a pinned environment's certificate
has changed, or the token claims when upgrading an old pairing.
environmentIdand the recordedcertificate's pin. Compare it in constant time. When an environment is
expected (a stored link or catalog entry), the id must also match.
connection that carries a credential validates the server's certificate with
the pinned certificate as its only trust anchor, checking dates and ignoring
the name. This includes pooled, retried, and redirected connections.
Resumed sessions are allowed only within one pin's TLS context
(section 5).
as explicit route policy, next to the route's unchanged
http://URL. A pinnever relaxes into normal certificate validation or plain HTTP.
If the MAC does not verify, abort without sending anything. With a pairing
code, tell the user to revoke the code (see Security).
A deadline for each code. The client stops using a code 15 minutes after
it first sends a key-pin request with it, whatever the code's length, and asks
for a new one. It records that moment durably, so retries and restarts do not
extend the deadline. A refused connection or a failed handshake sends no
request and starts no clock, so a server that is down does not use up a code.
An interceptor can start guessing only once it has a request, so this bounds
the time it has to impersonate the server to that client. Server-side expiry
cannot do that: it stops redemption at the real server, not a client from
accepting a fake one. The deadline covers one device; a second device given
the same code later is the case
section 8 sizes separately.
5. Pins are sticky
A pin belongs to the environment, not the route, and persists across restarts.
Once an environment is pinned, no route to it carries credentials in clear.
Its
http://routes must use TLS with that certificate. Itshttps://routesthrough T3 Connect or Tailscale Serve keep normal certificate validation. A
failed handshake is an error, never a fallback. This works like HSTS.
key-pin with its session id on a bootstrap connection and replaces the pin
if the MAC verifies;
https://route with normal certificate validation(section 7).
a new certificate on a pairing with no pin key, made before the upgrade,
unless an
https://route can report the new pin.schedule. A planned change, such as moving off P-256, makes a new key and
certificate, and every client with a pin key re-pins without the user
noticing. Nothing exercises that path in normal use, so a test does
(Rollout).
an
https://report discards the stored pin key, and any re-pin in progresswith it. Re-pairing brings a new one. Without this rule, after a recovery
that followed a theft of the signing secret, a client that had learned the
new certificate over Tailscale Serve would still accept the attacker's
certificate with a MAC under its old pin key. A client that learns a planned
change over
https://first loses its pin key the same way, and re-pairs atthe next change.
server is, and it is sent with every request. Anyone who has stolen one could
compute a valid MAC for a key of their own, even after a recovery has moved
the client to a new key. The pin key crosses the network once, inside the
pinned connection that ends pairing, and no endpoint returns it again.
has not changed in the meantime. Each pin has its own TLS context, with its
connection pool and session cache, and a replacement discards the old one
and closes its connections. A ticket from the old pin would otherwise resume
after the replacement, still counted as validated (see
Prototype).
or unencrypted.
is how a user goes back to an older server on purpose.
Recovery
Recovery replaces the key and every way to log in. A command, run with the
server stopped:
startup, and codes minted through T3 Connect;
leaves the rest of the secret store in place, including the T3 Connect
link. Pin keys derive from the signing secret, so every pin key stops
working too.
Starting the server again discards pending MCP authorization codes,
half-finished exchanges, and old connections. The server holds those codes
only in memory (McpOAuth.ts:257)
and reads its signing secret only at startup
(SessionStore.ts:499).
For a server the desktop app manages, recovery also quits the desktop app
completely. The app holds its bootstrap secret only in memory and passes it
to every backend it launches
(DesktopBackendConfiguration.ts:726).
The server accepts tokens derived from that secret before it checks stored
codes (PairingGrantStore.ts:441).
Older desktops pass a random token instead, made once per app run. Restarting
only the backend keeps either one. The next app launch makes a new one.
Apart from the reusable dev token, which only works in web dev mode (see
Security), no token, grant, or pin key from before recovery works
afterwards. Clients re-pair or learn the new pin over a trusted route, and
T3 Connect mints fresh codes.
6. Peer links
http://URL is accepted when it pins, or when it isloopback.
isTailnetHostno longer has a say.12-character code means an old peer, which needs the plain HTTP opt-in even
over
.ts.net. A name cannot prove the path its packets take, so exemptingit would leave the DNS spoofing described above open.
--allow-plaintextont3 environment link, aconfirmation in Settings → Linked environments, and a choice on the
pairing-code card that
t3_environment_linkraises. It is never a toolparameter an agent can set.
peer_environment_linksgains a nullablekey_pincolumn forthe pinned certificate. The pin key goes next to the link's token. A pinned
link keeps its
http://URLs in a new column and setsurls_jsonto[],so a downgraded server finds no address to send the token to.
resolve. It uses the pinned connection, so the token goes only to thekey that proved it holds the link's credential.
7. Learned routes
A server reports its LAN and tailnet addresses so clients can learn routes
(remote.md). The server adds its pin to that report.
A client pins learned routes without calling the endpoint when the report
arrives over an already pinned connection, or over an
https://route withnormal certificate validation: T3 Connect or Tailscale Serve. Clients that
paired over HTTPS gain safe LAN routes this way.
Over an
https://route, a reported pin that differs from the stored onereplaces it. That is how clients recover after a key compromise (see
Security). Replacing a pin this way gives no one new power. T3
Connect and Tailscale Serve terminate TLS, so they already see every token sent
through them, which matches the
trusted T3 Connect broker.
Over a pinned connection, a reported pin that differs from the key the
connection validated is ignored and logged. A planned change reaches the client
through the pin key, so a differing report means a bug or a stolen key, and
neither should move the pin.
For pinned environments, pins replace the
tokenAllowsPlainHttpandsendsTokenInClearrules. Those rules remain for environments that cannot pin.8. Pairing codes grow to 16 or 20 characters
Pairing codes go from 12 characters (60 bits) to 16 (80 bits), from the same
32-symbol alphabet. Codes that live longer than 15 minutes get 20 (100 bits).
They are shown in groups of four,
ABCD-EFGH-JKLM-NPQR, and accepted with orwithout the dashes, in either case.
Why: pinning creates an offline attack on the code. An active attacker who
intercepts the first connection completes TLS with its own key and receives the
client's nonce and id. The id is a function of the code, so the attacker can
test guesses offline without contacting the server, for as long as it likes.
What a found code is worth depends on when it is found:
the code stays live until the server expires or revokes it. Found by then,
the attacker can redeem it itself.
client first sends a request with it
(section 4), the attacker can answer a
retry with a valid MAC for its own key, and the client pins it.
Today this attack does not exist, because the code simply travels in clear.
How strong a code must be. Each guess costs two HMAC-SHA256 computations,
about eight SHA-256 compressions. An attacker making
Gcomplete guesses persecond finds a uniformly random
b-bit code within a windowTwithprobability about
G·T / 2^b. For redemption,Tis the code's lifetime. Forimpersonation, it runs from the first intercepted request with the code to the
last request a device accepts: 15 minutes when one device uses the code. The
table assumes
G = 2·10^15. That figure is a budget chosen for illustration,not a measurement:
The risk is per intercepted code. The accepted risk is a chance under 10^-5
per code at this rate, for either outcome. For redemption, 16 characters meet
it for lifetimes up to about 100 minutes, and 20 characters for any lifetime up
to 30 days, the longest a code may live. For impersonation, one device stays at
or below 1.5·10^-6, because of its deadline. A second device given the same
code later widens the window, since the attacker's search began at the first
intercepted request. A 16-character code stays under 10^-5 only if every device
tries it within about 100 minutes; a 20-character code, for far longer than any
code is kept. Reusing a 16-character code on another device later is outside
this guarantee, which is why a client that fails to pair tells the user to
revoke the code and get a new one.
Code length cannot bound how many pairings an attacker intercepts. A campaign
succeeds about as often as the sum of its codes' chances. One fresh five-minute
code every five minutes for a year comes to about 5% at this rate. The pin key
keeps that sum from growing with use: each client spends a code once, and
reconnections and certificate changes add nothing to the attacker's chances
(section 2). Online guessing at the server is
negligible at 80 bits even without the rate limits. So:
(PairingGrantStore.ts:251)
and get 16 characters.
hours, and any
t3 pair --ttlbeyond 15 minutes(PairingGrantStore.ts:391,
pair.ts:448).
shared issuing service in
PairingGrantStoreenforces this for every caller,so
t3 pair --ttlrefuses longer values, which it accepts today.Why the nonce too. The nonce adds no secret entropy, so it does not change
the table. It stops work from carrying over. Without it, the fixed label acts as
one global salt, and a table of ids computed once would apply to every server
and every pairing. It costs 16 bytes.
Why not a slow hash. Deriving
Kwith scrypt would make each guessexpensive, at a price:
measurement, for every live code on every request to an unauthenticated
endpoint.
measurement. Hermes has no JIT and was not measured.
Longer codes cost none of that.
The cost is four more characters, or eight for long-lived codes, wherever
someone types a code:
t3 environment link --pairing-code, manual entry in the web, desktop, andmobile apps, and the
t3_environment_linkpairing card. The QR code and the/pair#token=…URL absorb the extra length. Long-lived codes are rare andmostly travel as links.
Backwards compatibility
New server, old client
that never send a TLS ClientHello hit the HTTP parser as before, and the
endpoint is never called. Their credentials still travel in clear on plain
HTTP routes. A server cannot fix a client that does not ask for TLS.
proxies terminate TLS in front of the server and reach it over loopback.
applies its own hostname check and sends plain HTTP over
.ts.netas before.The new server serves it.
Old server, new client
400 Bad Request, and the client's handshake fails withERR_SSL_WRONG_VERSION_NUMBER. If TLS somehow succeeds and the endpointanswers
404or anything that is not the expected JSON, treat that as oldtoo. Note that older servers serve the web app's
index.htmlwith a 200 forany unknown GET (http.ts:637), which is why
the endpoint is a POST.
attacker can fake every one of those answers. What the client does depends on
what it holds (section 3):
failure means interference or a plain-HTTP proxy. Stop, and say that
something blocked the secure connection.
its identity: upgrade it, or remove and re-add it.
and label the route unencrypted. Peer links need the opt-in.
Existing pairings and links
Clients. A client holding a token from a plain HTTP pairing runs the
key-pin exchange with
tokenClaimson its next connect. If the server isupgraded, the client pins and continues. No re-pairing is needed yet.
No pin key. A token never yields one, so a certificate change sends
these pairings to re-pair. Certificates change only through recovery or a
planned change. Bearer tokens from a pairing expire within 30 days by
default, after which the user pairs again with a new code and gets a pin
key, so few pairings are still waiting when a certificate changes.
What the upgrade cannot fix. The token crossed the network in clear and
may have been recorded:
revoked. Expiry is signed into the token, and nothing renews the bearer
token a pairing returns. T3 Connect sessions differ: they are bound to a
DPoP proof key and renew with it
(SessionStore.ts:504).
own key, and the client pins it.
HTTP.
Revoking the session and re-pairing with a fresh code rules all of this
out.
Stored peer links. These upgrade the same way on next
resolve, withthe same limit at a certificate change; MCP access tokens are
session tokens too
(EnvironmentAuth.ts:1313).
A link to an old peer keeps working as it was created, because it was already
accepted.
Pairing code length
PAIRING_TOKEN_PATTERN(PairingGrantStore.ts:259),
and it only decides whether to upper-case a typed code. The contracts accept
any non-empty string, and no web, mobile, or desktop code checks the length.
through unchanged. They also pass a dashed code through as typed, so the
server strips dashes before matching.
clients read the length only to choose a policy, never to reject a code. They
strip dashes before sending, so old servers never see one.
for one release on its existing endpoints, never on key-pin. A code issued
just before an upgrade still pairs in plain HTTP until it expires.
Downgrading the client
Pinned routes keep their
http://URL, so an older client that ignored thepin would send credentials in clear. Pinned connections are therefore saved as
a new record kind that older clients do not decode, and pinned peer links keep
their URLs out of
urls_json(section 6). A downgraded clientor server finds no usable address, and the user re-adds the environment. The
implementation must confirm that an undecodable record drops only that
environment.
Surfaces
Every stack that carries a credential validates the server's certificate with
the platform's own code, using the pinned certificate as its only trust anchor
and ignoring the name. A stack that cannot do that refuses pinned environments.
It never falls back to plain HTTP or to normal certificate validation.
t3 environment link, and desktop main. A customconnect function. Bootstrap connections accept any certificate. Pinned
connections pass the pinned certificate as the only
ca, with acheckServerIdentitythat accepts any name. Requests keep theirhttp://URL. Status: probed (see Prototype); needs the adversarial
tests.
loopback
http://endpoint over a pinned Node connection, as it does for SSH.Pairing goes through main too. Today the window redeems a direct pairing
itself (onboarding.ts:22),
but SSH pairing already runs in main through an IPC call
(sshEnvironment.ts:169).
Pinned pairing does the same: the window passes the code and route to main,
and main runs key-pin, redeems the code, keeps the pin and pin key, opens the
forward, and returns the token. The pin key never reaches the window. Status:
design.
OkHttpClientProvider.setOkHttpClientFactory,which RN
fetchandWebSocketboth build on. A pinned environment'shttp://requests go tohttps://on the same host and port, with a trustmanager built from a key store that holds only the pinned certificate, and a
hostname verifier that accepts any name. Status: needs a feasibility
prototype.
RCTURLRequestHandlerwith a higherhandlerPrioritysends a pinned environment'shttp://requests withURLSession to
https://on the same host and port. Its server-trust callbackevaluates the trust with
SecTrustSetAnchorCertificatesholding only thepinned certificate, under an SSL policy with no hostname.
RCTSetCustomSRWebSocketProviderdoes the same for the socket. Status:needs a feasibility prototype, which must also confirm that a certificate
that never expires passes. If Apple's lifetime limit for TLS server
certificates applies under an SSL policy, a basic X.509 policy checks only
the anchor and dates.
expo-image,expo-video, andreact-native-webview. Each has its ownnetwork stack and needs its own hook. Until then they refuse pinned
environments, and mobile pinning does not ship (see below).
certificates through Tailscale Serve or T3 Connect, or plain HTTP
(Future work).
Why Node passes the pin as
ca. Node callscheckServerIdentityonlyafter chain validation succeeds, and with
rejectUnauthorized: falseitproceeds without calling it. Passing the pinned certificate as the only
cakeeps validation on. It succeeds only for that certificate and within its
dates, and
checkServerIdentitythen only skips the name check. A resumedsession reports the validation of its first handshake. Another server offered
the same ticket falls back to a full handshake and fails, but the same server
resumes a ticket from an earlier pin even after
cachanges. That is why eachpin gets its own TLS context (section 5). An earlier
draft compared keys by hand and had to turn resumption off, because Node
reports no peer key on a resumed session.
Why media can't lag behind. Mobile media is not just pictures:
app. It calls read-only tools, reads resources, and updates the model's
context without asking, and asks before mutating tools or messages
(McpAppWebView.tsx:319).
A page rewritten in transit could read data through the pinned API and leak
it, or inject text into the agent's context.
uploads to a browser or device on the server. An attacker could read what
the user types into a preview, inject input, or show a fake page.
and every image, video, and PDF reaches a native decoder.
for HTML previews (AssetAccess.ts:74).
Sent in clear, they let an observer fetch the file.
So a pinned environment's media and webviews must either go through the pinned
stack or refuse, never use plain HTTP, and mobile pinning ships only once all of
them do.
Why the desktop window doesn't pin. The window is a Chromium page, so its
fetchand WebSocket traffic goes through Chromium's network stack. Electron'ssession.setCertificateVerifyProcgets the hostname but not the port, andChromium caches its answer. It cannot tell two environments on one host apart,
so a key accepted for one would be accepted for the other. The
certificate-errorevent does get the full URL, port included, but whetherChromium remembers its answer per host or per host and port is unchecked
(Open questions). Until it is, the window doesn't pin.
Instead:
and opens the pinned connection for exactly one host, port, and environment.
passes bytes between the two. That is how the window already reaches SSH
environments
(remote.md).
the loopback Host and derives the same
http://127.0.0.1:<port>URL that thewindow uses and signs. This is why pinned TLS sits below HTTP
(section 1).
forward reaches the remote server without credentials, as it could directly.
A page served over plain HTTP cannot be protected from an active attacker by
any protocol, because the attacker can rewrite its JavaScript.
Security
The attacker controls the network: it can observe, redirect, inject, delay, and
drop traffic, answer DNS, and run its own T3 environment. The client and its
saved state are intact. The pairing code reaches the client out of band or over
a pinned or
https://connection, never over plain HTTP the attacker can read(What it does not cover). The code's
length is a signal only because the attacker cannot change it.
Defended. A passive observer of a pinned connection sees only TLS: the
code, token, pin key, key-pin request, and all content stay inside it, with
forward secrecy from TLS 1.3 ephemeral key exchange. Addresses, timing, and
sizes remain visible. An active attacker against a pinned environment, or
against a pairing with a new code, causes a hard failure. Against a pairing it
may also get the offline check that
section 8 sizes codes against.
Against a certificate change it gains nothing: anyone can get a MAC under a
pin key from the real server, but a 256-bit key cannot be guessed. Hostname
spoofing (DNS,
/etc/hosts) has no effect, because no name is trusted, andevery key-pin answer is bound to the client's nonce, so none can be replayed.
Not defended:
default, or are revoked. Whoever holds one and is on the path when that
pairing upgrades can pin its own key. Revoking the session and re-pairing
fixes both.
Guessing an intercepted code. The captured nonce and id stay an offline
check forever. A code found while it is still live can be redeemed at the real
server. A code found before the client's 15-minute deadline lets the attacker
impersonate the server to that client. After that, the client no longer accepts
the code. A second device given the same code later starts its own clock, but
the attacker's search started earlier, so for a 16-character code that reuse
falls outside section 8's
bound. After a failed MAC or a timeout, the client tells the user to revoke
the code and get a new one.
Trusted parties. T3 Connect and Tailscale Serve see and can change the
traffic they carry. Pins learned through them, including replacements, trust
them to name the environment. A malicious broker, a compromised PKI root, and
compromise of either endpoint are out of scope.
Key compromise. The signing secret mints tokens and derives every pin key,
so leaking it gives the environment away. The TLS key alone lets an attacker on
the path impersonate the server to pinned clients and collect their tokens,
until recovery. It also reads every pairing code a client sends the server.
With one, it can make any other device still pairing with that code pin a key
of the attacker's own. Both secrets live in the same store, so they usually
leak together, but they are not the same capability.
Recovery for either is the command in Recovery.
Replacing only the keys is not enough. Tokens the attacker collected would stay
valid unless the signing secret changes. A pairing code the attacker
intercepted and kept would stay live: with the stolen key, it can pass the real
server's key-pin answer to the client and receive the code, then redeem it
after the keys change, so recovery also revokes every outstanding code. Wiping
the whole secret store instead would also unlink T3 Connect
(CloudLink.ts:983). The reusable
dev token comes from configuration, not the database, so recovery cannot revoke
it. It works only in web dev mode.
After recovery:
is no longer accepted. It fails, and the user re-pairs.
the new pin there (section 7). It recovers on its own.
server's identity and discards its old pin key, but its token is dead, so
the user re-pairs.
mismatch, so it must be told out of band, as with a compromised SSH host key.
A stolen TLS key works against it until it re-pairs. If the signing secret
leaked too, the attacker can also derive that client's pin key and move it to
a key of the attacker's own, until the client re-pairs or its session
expires.
Recorded traffic stays protected after either leak, because TLS 1.3 key
exchange is ephemeral.
Session liveness. A key-pin request with a session id or token claims tells
its sender whether that session is live. Only someone who has seen the client's
traffic has either value: the claims in plain HTTP requests, the session id on
an intercepted bootstrap connection. It carries no authority.
No post-quantum claim. The identity key is P-256, and key exchange depends
on what each client stack offers.
iOS export classification
The app declares
ITSAppUsesNonExemptEncryption: false(app.config.ts:273). This design adds no
encryption of its own to the app:
the app's
http://requests tohttps://on the same host and port. Theapp ships no TLS or cipher code of its own.
Apple's
guidance
distinguishes encryption the OS provides, standard encryption, and proprietary
encryption. This is an engineering read, not a compliance conclusion. Confirm
the shipped implementation's obligations before release.
Alternatives considered
PSK = SHA-256(token). It works between Node processes:Node 26.12.1 with OpenSSL 3.5.9 negotiated TLS 1.3 with X25519MLKEM768, using
only the signing secret on the server. But browsers, URLSession, and OkHttp
cannot do PSK, and pinning covers the Node case equally well. One mechanism is
simpler than two.
for typed codes or existing pairings. The code's length already tells the
client to expect TLS.
entirely. A separate public random selector, not derived from the code, can
pick the record, so the server need not try every live code. But it needs a
reviewed implementation in Node, Hermes, and the native stacks, plus binding
to the TLS channel, and the selector adds characters to typed codes too. A
longer random code needs only HMAC. Revisit this if codes must get shorter.
new session changes a peer link's identity, which fences what a restricted
link may change (linkOrigin.ts).
Keeping the session instead needs a token version, an exception to the
MCP-only guard, and retry handling for a lost response. Captured tokens
expire within 30 days by default anyway.
a key of its own. That holds even for a token never sent in clear, if it was
collected with a stolen TLS key, and even after a recovery has moved the
client to a new key. The pin key does the same job without that exposure: it
crosses the network once, inside the pinned connection that ends pairing.
would stop working at the next replacement. But the TLS key shares a store
with the signing secret, which does not expire, mints tokens, and derives
every pin key, so most thefts take both, and replacing the TLS key does
nothing against that attacker. It helps only when the TLS key leaks alone,
for example through a memory-disclosure bug in the TLS library. The cost is a
dependency on client clocks, a breakage at every replacement for clients with
no pin key, and a timer and replacement path on a running server. A path that
runs every few months would stay working. Here a test keeps it working
instead.
It reaches browsers, but covers only what JavaScript sends: cookies,
<img>loads, and preview iframes still leak. It cannot protect a page served over
plain HTTP.
which is the only thing React Native's
fetchandWebSocket, the mediastacks, webviews, Chromium, and Node's HTTP client speak, and it would put
cipher code in the iOS app. As a handshake inside TLS that authenticates the
key, it does the key-pin MAC's job with a key exchange TLS already provides.
Either way it does not help with pairing codes: given a hash of a code as its
pre-shared key, an interceptor gets the same offline check. Removing that
takes a PAKE. Noise fits when T3 owns both ends of the transport, as
WireGuard does.
RFC 7677). It is the nearest
vetted standard. Its final server signature authenticates the TLS endpoint
through the same
tls-server-end-pointbinding the pin now uses, with thesame offline exposure for low-entropy secrets. Adopting the complete protocol
would inherit its analysis; reusing only its message format would not. The
cost is an extra round trip and its salt and iteration machinery. Both bind
to the endpoint rather than the session (
tls-exporter), because URLSession,OkHttp, and Chromium expose the certificate but not exporters.
not cover the body, and nothing is encrypted.
Open questions
certificate-erroranswer per hostor per host and port. If per host and port, the desktop window could pin
directly instead of going through main.
Future work: browsers
None of this is part of the proposal. It is the largest gap left: a browser on
a plain
http://route cannot authenticate the server, and an attacker canrewrite the page itself, so no protocol run by that page helps. The options all
change what browsers may do:
real certificates. Everything else would stay native-only.
anything but loopback. It breaks LAN browser use, so it cannot be the default
while browsers rely on it.
serverCertificateHashesand WebRTC's DTLS fingerprints let a pageauthenticate a self-signed certificate by its hash. The page must itself come
from an HTTPS origin such as app.t3.codes, the server would need a new
transport stack, and WebTransport limits such certificates to two weeks.
Rollout
Each step ships on its own, and none needs both sides upgraded together.
the pin in reported endpoints, 16- and 20-character codes with the comment
at the issuing site, the 30-day code lifetime cap, the key-pin limits, and
the offline recovery command. This is invisible to old clients.
step removes the hostname check and fixes linking over WireGuard and LANs.
iOS, each shipping only with its media and webview stacks covered
(Surfaces).
Tests belong at the layers that can break:
12-character codes never matching; codes with or without dashes, in either
case; 421 on plain sockets, even with a forged
X-Forwarded-Proto; no clientvalue but the nonce reaching the MAC; the body and rate limits, including the
loopback exemption. The pin key is returned only when a code is exchanged on
a direct TLS socket, and nowhere else.
private-network filter still applies. Requests over TLS keep their
http://URL.
written, on every credential-bearing stack and on resumed connections. A
ticket from a previous pin is never offered after a replacement. Node,
OkHttp, URLSession, and each media stack are tested separately, since a pass
on one says nothing about another. The test server keeps accepting the old
pin's tickets and records, for every connection after a replacement, whether
the handshake resumed and whether any application bytes arrived. A
connection under the old pin must show neither. The bootstrap connection
carries no credentials and follows no redirect. Two environments on one host
refuse each other's certificates.
12-character code asks first; nothing caches "no TLS". The issuing service
refuses lifetimes over 30 days from every caller, including
t3 pair --ttl.A code that has expired at the server, and whose MAC the attacker can now
compute, installs no pin through a delayed response or a retry with a new
nonce once the client's 15-minute deadline has passed, including across a
restart. A refused connection starts no clock.
accepted through the pin key and closes connections made under the old one.
A changed certificate fails with a valid token MAC. A pin reported over T3
Connect replaces a stale one; one reported over plain HTTP never does, and
neither does a differing one reported over a pinned connection.
and the old desktop bootstrap credential from before recovery all fail
afterwards, and old connections are closed. Stolen key A, recovery to B, then
an attacker's key C: C fails. Stolen signing secret, recovery, a pin learned
over Tailscale Serve, then C endorsed under the old pin key: C fails, before
the old token expires. A fresh pairing and a fresh T3 Connect session still
work.
working. An older client or server finds no usable address for a pinned
environment, even after a migration interrupted by a restart, and unrelated
environments keep working.
through the forward, carry DPoP proofs for the
http://URL and pass theserver's checks.
exchange changes.
Prototype
Throwaway Node scripts (not committed) checked the compatibility cases and the
Node pin hooks on Node 26.12.1 and 26.13.0, with OpenSSL 3.5.9. The scripts
predate the nonce on the token path and the pin key. They cover compatibility
and the Node hooks, not the adversarial tests above.
ERR_SSL_WRONG_VERSION_NUMBERkey-pinover plain HTTP on a new serverrejectUnauthorized: false, acheckServerIdentitythat failssecureConnect, wrong keygetPeerCertificate()reported no keyca, any name acceptedauthorizedtrueDEPTH_ZERO_SELF_SIGNED_CERTCERT_HAS_EXPIREDauthorizedtruecachanged to another certificateauthorizedtrueModel
A Tamarin model checks the exchange symbolically. Its source is in the
appendix. It has three theories, each proved in
full with Tamarin 1.12.0 and Maude 3.5.1:
of times, with recovery, pins learned over a trusted route, and stolen
tokens, TLS keys, and pin keys. It assumes pairing was secure, which the
pairing theory shows.
The model abstracts:
ticket is that key, remembered per pin. That has no forward secrecy, so a TLS
key leak at any time counts against secrecy. TLS 1.3 removes that case.
secrecy matters. It does not prove the 15-minute bound, which rests on the
arithmetic in section 8.
retry or a second device. Re-pins repeat without bound. The search for the
kept-pin-key attack is limited to clients that had not re-pinned before.
endorse a consumed code. That is more permissive than the design, so the
results still hold.
model, which only adds server behaviour.
theory's shape with the token in place of the pin key. A token travels with
every request, so it counts as leaked, and that path gets only the guarantee
conditioned on the leak.
The model found one consequence the first draft of these properties missed. A
stolen TLS key exposes every code sent to the server, and with one the attacker
can fool another device still pairing with it. Security now says so.
Appendix: Tamarin model
The three theories behind Model. Each proves in full with Tamarin
1.12.0 and Maude 3.5.1: pairing in about 15 seconds, re-pinning in about 90,
and tickets in about 12.
With Maude from its release zip rather than a package, set
MAUDE_LIBto thedirectory that holds
prelude.maude. Four lemmas are expected to befalsified, each showing that the model finds an attack the design avoids:
pair_pin_auth_ignoring_guesses,repin_auth_ignoring_leaks,kept_pin_key_after_recovery, andrequests_secret_with_stale_tickets.pairing.spthyrepin.spthytickets.spthyAll reactions