# Passing secrets as command-line arguments: our trade

> Arguments are readable through ps by other accounts on a Mac, but never written to disk. Mosaic puts a cookie key there anyway, for one threat.

Source: https://mosaicbrowser.com/blog/a-secret-on-the-command-line

## Why we accept a cookie key on the command line

Arguments are readable through ps by other accounts on a Mac, but never written to disk. Mosaic puts a cookie key there anyway, for one threat.

![A key on argv, and the threat it answers, beside a screenshot: mosaic security settings: everything on disk sealed with AES-256-GCM, and an optional app lock](https://mosaicbrowser.com/covers/a-secret-on-the-command-line.webp)

Passing secrets as command-line arguments is a bad default, because a process's arguments are among the easiest things on a computer to read. On Linux, `/proc/<pid>/cmdline` is open to every user unless `/proc` is mounted with `hidepid`. On a Mac, `/bin/ps` runs as root and prints every process's arguments to every account. We still put one secret there: the engine takes each profile's cookie password as `--os-crypt-password`. This is why, and the threat it does not cover.

## Passing secrets as command-line arguments: who can read them

Three readers, in the order people forget them:

1. **Other processes on the machine.** Linux's `proc(5)` page says it plainly for `hidepid=0`: "Everybody may access all /proc/pid directories. This is the traditional behavior, and the default if this mount option is not specified." The command line is one of the files in there.
2. **Your shell's history.** A secret typed after a command name lands in `~/.zsh_history` or `~/.bash_history`, in plain text, for ever.
3. **Anything that logs command lines.** Process monitors, CI logs that echo each step, and crash reports that record how a program was started.

On macOS we checked the first one on our own machine, macOS 26.7.1, from an ordinary account. Asking the kernel directly for another user's arguments, through the `KERN_PROCARGS2` sysctl, fails with `EINVAL`. Then `ps -axww -o user,args` prints root's daemons with their arguments anyway: `/usr/sbin/systemstats --daemon`, `/usr/sbin/securityd -i`. The reason is in the file listing: `-rwsr-xr-x root wheel /bin/ps`. It is setuid root, so the restriction on the sysctl does not apply to it, and every account on the Mac can read every process's command line.

If you are writing a launcher from scratch, pipe the secret into the child's stdin, or hand it an open descriptor (`3<` in a shell, `stdio: ['pipe', 'inherit', 'inherit', 'pipe']` in Node), or write it to a `0600` file and pass the path. An environment variable is a half step: on Linux `/proc/<pid>/environ` is mode `0400`, owner and root only, but every child you start inherits it unless you scrub it.

Mosaic is a desktop app

Email yourself the link and open it on your computer.

[How it works: Local first](https://mosaicbrowser.com/features/local-first)

## The threat it answers

Every Mosaic profile launches with `--use-mock-keychain`. A Mac has one login Keychain, and a machine running three hundred profiles cannot answer a Keychain dialog for each of them. The flag leaves Chromium's cookie encryption on and swaps the password for `mock_password`, a constant anyone can read in Chromium's source. Before 0139, we pointed one command at a real profile's `Cookies` file and had a live session cookie back in about a second:

```
DECRYPTED -- password "mock_password", offset 32
  .dev.to  _Devto_Forem_Session = "bb0cbcf3b126b691797c6126a7f3ae48"

```

That is a threat about files. Somebody walks off with the laptop, or copies a Time Machine disk, or pulls the SSD out of a Mac that died, and every cookie in the folder was theirs.

For that threat argv is a fine place, because **Mosaic never writes argv to disk**. `launcher.ts` calls Node's `spawn` with an argument array and no shell, so nothing lands in `~/.zsh_history`. The password itself is not stored anywhere: `vault.ts` derives it at each launch with scrypt over the library's data key and the string `mosaic-cookies:<profile id>`. Delete the profile and its key is gone with it. The data key is wrapped under your Mosaic account, so a copied folder opened by a different account, or by nobody signed in, decrypts nothing. How Chromium turns that password into an AES key, and what our change does in `keychain_key_provider.mm`, is in [how every profile's cookies get their own key](https://mosaicbrowser.com/blog/cookie-key-per-profile).

## The threat it does not cover

The header of that change names **code already running as you**. A process with your user id can attach a debugger to the engine or read Mosaic's memory, and the key is in both no matter how it got there. A pipe instead of argv would not stop that, and the header does not claim otherwise.

Writing this post found a second one the header understates. The header says `ps` can read the key "for the user who started it". On a Mac that is too narrow: through the setuid `ps`, **any account on the computer** can read a running profile's cookie password while the browser is open. What that account cannot do is read the jar. The profile lives under `~/Library/Application Support`, and `~/Library` is `drwx------`, so the other account sees the password of every profile that is open, and none of the files those passwords open. Joining the two takes someone who can watch the process list while the profile runs and also carry the folder away, which is the stolen-laptop case plus a second account on the same machine.

One question is still open. Chromium can copy some of its switches into a crash report, and whether a crash of our engine would ever put this one in a report on disk is a measurement we have not made. Until we have, "never written to disk" is a statement about what Mosaic writes.

## The same trade, made shorter, for launch tokens

The engine also takes a signed launch token on its command line, and there the `ps` reader shaped the design. An offline launch could have used one long token, but a token valid for a day on argv is a day of replay for anything that can run `ps`. So a token expires about five minutes after it is made. Pro's offline day works through a key this computer generates and the account server certifies for a day; the engine checks that certificate, and the key's private half never goes on the command line. Everything on the command line is short-lived.

Today no setting moves the cookie password off the command line. App lock (Settings › Security) wraps the data key under a password nobody stores, so a copied disk is ciphertext, and a running profile still gets its key on argv all the same. What the server knows and what stays on the Mac is listed under [local-first](https://mosaicbrowser.com/features/local-first). If a second person has an account on the Mac where your profiles run, this post is about you; each profile's sessions are in its own [cookie jar](https://mosaicbrowser.com/features/cookie-jars).

## Sources

1. [proc(5), Linux manual page (hidepid)](https://man7.org/linux/man-pages/man5/proc.5.html), read November 3, 2026
2. [proc_pid_cmdline(5), Linux manual page](https://man7.org/linux/man-pages/man5/proc_pid_cmdline.5.html), read November 3, 2026

## Questions

### Is it safe to pass a password as a command-line argument?

Usually not. On Linux, /proc/<pid>/cmdline is world-readable unless /proc is mounted with hidepid. On macOS, /bin/ps is setuid root and shows every account the arguments of every process. A command typed into zsh also lands in ~/.zsh_history. Pipe the secret to stdin, pass an open file descriptor, or point at a 0600 file instead.

### Can other users on a Mac see my process arguments?

Yes. /bin/ps on macOS is setuid root, so an ordinary account running ps -axww sees the full command line of every process, including other users' and root's. We checked this on macOS 26.7.1: a direct sysctl for another user's arguments is refused, and ps prints them anyway.

### Are environment variables safer than arguments for secrets?

Somewhat. On Linux /proc/<pid>/environ is mode 0400, owner and root only, where cmdline is open to everyone. But every child process inherits the variable unless you unset it, and anything running under your user id can still read it.

### What does Mosaic pass on the engine's command line?

Each profile's cookie password, which the engine accepts as --os-crypt-password, and a signed launch token that expires after five minutes. Neither is written to disk by Mosaic, and both are derived or made per launch rather than stored.

## Related

[Mosaic gives every profile's cookies their own key](https://mosaicbrowser.com/blog/cookie-key-per-profile): Chrome on a Mac turns a Keychain password into an AES key with PBKDF2. Our engine lets Mosaic pass each profile its own password and keeps the v10 format.

[Chromium's mock keychain, and why we encrypt the store](https://mosaicbrowser.com/blog/mock-keychain-cookies): Chromium's --use-mock-keychain keeps cookie encryption on but uses a password from its own source. We read a live session cookie off disk, then sealed it.

[Local first: your profiles stay on your computer](https://mosaicbrowser.com/features/local-first): Mosaic has no cloud copy of your profiles. Profiles, cookies and proxies stay on your computer, encrypted on disk, with app lock, daily backups and a trash.

[Cookie jars: import and export cookies per browser profile](https://mosaicbrowser.com/features/cookie-jars): Import and export cookies per browser profile in Mosaic: paste Cookie-Editor JSON, a Netscape cookies.txt or a Cookie header, and export the jar as JSON.

[App-Bound Encryption, and why tools stopped reading Chrome's cookies](https://mosaicbrowser.com/blog/chrome-app-bound-encryption): App-Bound Encryption ties Chrome's cookie key on Windows to Chrome itself, so tools reading the Cookies file broke. Export from inside the browser.

[Device-bound sessions and the end of copying a cookie](https://mosaicbrowser.com/blog/device-bound-session-credentials): With Device Bound Session Credentials in Chrome, a site reissues its session cookie only to the device with the key. A copied cookie lasts until it expires.

[Chrome kept third-party cookies. What that means for cookie jars](https://mosaicbrowser.com/blog/chrome-keeps-third-party-cookies): Chrome is not removing third-party cookies: Google dropped the phase-out and then the prompt. A jar per account matters as much as it did before.



## Mosaic, on your own computer

The browser this blog is about: its own Chromium, fingerprints from real machines and a proxy IP per profile. Free covers 3 profiles with no card, and Pro is $25 a month for any number of them.

Mosaic is a desktop app

Email yourself the link and open it on your computer.
