An aFile share link looks like this:

A share link

https://api.afile.sh/s/5fcf4cd1-d94a-4764-bbfd-16a15a36bb7c#E9Ct7VFgJvGcFpME05InesyKxst7M_A7aqy0fAHCW_o

The part before # finds the encrypted file. The part after it is the key that decrypts the file. aFile’s server sees the first part and never the second.

The fragment stays in the browser

The part of a URL after # is called the fragment. A browser takes it off before it asks the server for the page (RFC 3986, section 3.5). So it isn’t in the request, in the server’s logs or in a proxy’s. Browsers also leave it out of the Referer header, and aFile’s share page sends Referrer-Policy: no-referrer anyway.

The key is 32 random bytes, written as 43 characters. It’s a 256-bit AES key, and nobody is going to guess it.

What happens when someone opens the link

  1. The browser asks api.afile.sh for /s/<id>, without the fragment. The server returns a page and its script.
  2. The page shows the file’s name and size, decrypted with the key from the fragment, and a Download button.
  3. A click fetches the encrypted copy, and the page decrypts it with AES-256-GCM in the browser.
  4. That download counts as a use. A link made with --once is used up, and its copy is erased.

The copy behind the link isn’t the item itself. When an agent runs afile share, the CLI encrypts a separate copy under a fresh key made for that link, so the link’s key opens nothing else. Loading the page doesn’t count as a download. Only fetching the file does.

An agent can open a link without the page:

afile get '<link>' --out report.pdf

The CLI decrypts it on your machine and checks the contents against the fingerprint saved with them before it writes anything.

Where it stops

  • The link is the password. Anyone with the whole link can open the file until it closes. Send it where you’d send the file itself, and use --once or a short --expires.
  • The fragment is kept in places. It’s in the browser’s history, and in whatever the link was pasted into: a chat, an email, a ticket. That’s why links close, after a day by default, 30 days at most, or after the downloads you allowed. Closing a link, or its expiry, erases its copy.
  • You trust the page. The script that reads the key comes from the same server that stores the copy. A server that wanted the key could serve a script that sends it home. aFile’s page loads only its own scripts and can connect only to its own origin, which keeps a third party out, but not aFile. If that matters to you, open the link with afile get, whose code is public at github.com/afile-org/cli.

Receive links use the fragment differently

In a receive link, what follows # isn’t a secret. It’s the fingerprint of the agent’s public receive key. The page asks aFile for that key and refuses to encrypt if the fingerprint doesn’t match. So the fragment there keeps the server honest about which key the files are encrypted to.

afile receive --expires 1h

Questions people ask

Does HTTPS protect the fragment?

It doesn’t need to. The fragment is never sent, so there’s nothing to protect in transit. The rest of the request goes over HTTPS.

Why not protect the link with a password?

A password is one more thing to send, and it usually goes in the same message as the link. The key in the link is already the secret, and a link that closes after one download or a day limits how long it matters.

Can aFile read a shared file?

Not from what it stores or what it receives. It would have to serve a page that sends the key back, which is the trust described above.