Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
- CI: bun is pinned to 1.4.5 in every workflow and in the integration-suite images instead of `latest`, the `pull_request_target` workflow pins `actions/github-script` by commit, and translate-docs reads its `languages` input from `env:` and accepts only supported codes. The input used to run as shell, including in the job holding the translation credentials. The ts-sdk release preflight reads `github.ref` from `env:` too, where a crafted branch name could skip its branch check (#1056)
- Harden the Codex system hooks. The hooks failproofai writes into `/etc/codex/config.toml` now run `/opt/failproofai-codex/codex-hook`, a short root-owned script that hands each event to the failproofai of the account that set the hooks up, one line per account. Install and every `failproofai update` check that the config itself, the script, the directories above them, the `sh`, `id` and `cat` it runs, and each account's own failproofai can be changed only by root or that account; a block that fails is taken out, and an account that fails is taken out of the script. `update` rewrites a block from an earlier version to use the script, which needs sudo; an account the block does not run for gets a notice instead of a failed update. Uninstalling takes out only your account (#1061)
- An install of failproofai fetches one third-party package, `sql.js`, pinned to an exact version with no dependencies or install script of its own; everything else it uses is compiled into its bundles at build time from `bun.lock`. It used to declare six caret ranges, so each `npm install -g failproofai` or `npx failproofai` resolved them, and posthog-node's own ranges under them, afresh: a malicious in-range release (posthog-node was hit by Shai-Hulud 2.0 in November 2025) reached every install made after it was published, and its install script ran there. posthog-node, yaml, smol-toml, jsonc-parser and html-to-image are devDependencies now, since nothing loaded them from `node_modules` at run time, so the pin holds whichever package manager installs failproofai, and an install downloads about 1.2 MB less. `bun run build` now fails first if a runtime dependency is a range, has dependencies of its own or an install script, if a bundle leaves a package external that the install would not carry, or if the package itself gains an install script, a peer dependency or an optional dependency other than the daemon packages (#1059)
- Harden the privileged service install. Every file failproofai writes as root (the systemd unit, the launchd plist, Codex's system config and the daemon's copy under `/opt`) now reaches root as bytes on stdin and is checked against its SHA-256 before it is put in place; the daemon's copy is also held to the digest the build recorded, and a daemon binary that is a symbolic link is refused. `sudo` and every program it runs are named by absolute path from `/usr/bin`, `/bin`, `/usr/sbin` and `/sbin` and start with a minimal environment, the credential prompt included. The commands printed when sudo is not available do the same, run as printed, and on macOS carry the plist itself (#1060)
- The always-on guard (`block-failproofai-commands`) now protects failproofai's installed code, not only its state. A user-scope hook runs the package `which failproofai` found, which under nvm, Homebrew, Volta, bun, pnpm, yarn or the npx cache the agent's own user can write, so a Write of `process.exit(0)` over `dist/cli.mjs` turned every later hook into an allow. File-tool writes to `node_modules/failproofai/…`, pnpm's `.pnpm/failproofai@…`, the daemon's `@failproofai/failproofaid-*` package, or the `…/bin/failproofai` and `…/pnpm/failproofai` entry a hook runs are now denied, including through a symlink, and so are shell commands that name those paths literally. The protected paths match case-insensitively, because macOS volumes are case-insensitive by default (FailproofAI/agenteye#1796, #1050)
- A session pause whose recorded start is more than a minute in the future, or later than its latest renewal, is no longer honoured. The 8-hour ceiling was measured from that start, which comes from the same owner-writable file, so a hand-written pause dated 2100 stayed live until 2100. `failproofai config --resume --all` now also removes pause files that are not honoured yet, and exits 1 instead of reporting success when one cannot be removed (FailproofAI/agenteye#1796, #1050)

Expand Down
15 changes: 15 additions & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -1010,6 +1010,21 @@ Three consequences, all handled explicitly rather than assumed:
anything; when it fails, the install writes nothing and returns the exact commands to
run, classified as `needs_root`. `sudo -n`, never interactive — a password prompt fired
from under the wizard's TUI is unreadable.
- **Root is never handed a path the user can write.** Every file written as root (unit,
plist, Codex's `/etc/codex/config.toml`, the `/opt` binary) goes through
`writePrivilegedFile()`: the bytes go to `PRIVILEGED_INSTALL_SCRIPT` on stdin with their
SHA-256 as an argument, and root checks them in a hidden `mktemp` file beside the
destination before it sets the mode and renames. On Linux the `/opt` binary is read by
the CLI, as the user, with `O_NOFOLLOW`, and checked before the install tears anything
down; on macOS root writes only the plist, which runs the user's own copy as that user.
No `sudo install <file under $HOME or $TMPDIR>`: root installs only bytes it has
verified. The printed `needs_root` recipe carries the same digests.
- **Nor a program found through PATH.** `sudo` and everything it runs come from
`src/hooks/system-command.ts`, which looks only in `/usr/bin`, `/bin`, `/usr/sbin` and
`/sbin` and starts them with `privilegedEnv()` (root's PATH, the caller's locale and the
settings sudo authenticates with). PATH is the user's to change. Printed commands use
`sudoCommandLine()`, which returns null rather than a bare name where root's directories
lack sudo or the program; callers then print what to do instead of a command.
- **A system unit has no login environment.** `resolveWorkerCommand()` uses
`process.execPath`, not a bare `node`: the single most common Node install is nvm, whose
binary lives under `~/.nvm/versions/node/*/bin` and is on no system PATH. A bare `node`
Expand Down
49 changes: 49 additions & 0 deletions __tests__/helpers/system-command-stand-in.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/**
* A stand-in for `src/hooks/system-command` in tests that drive the privileged
* service install with `node:child_process` mocked.
*
* The install looks sudo and the programs it runs up in root's own directories
* on the machine running the tests, before any mocked command is called. A
* machine may lack some of them (launchctl on Linux, systemctl on a Mac or in a
* container, sudo itself), so where one is missing a path stands in for it;
* these tests never run them. Everything else is the real module. A test can
* also hide a program, to see what the install does where root has none.
*
* vi.doMock("../../src/hooks/system-command", async (importOriginal) =>
* standInSystemCommand(await importOriginal()));
*/
import type * as SystemCommandModule from "../../src/hooks/system-command";

type SystemCommand = typeof SystemCommandModule;

/** Programs the tests' sudo mocks answer for without running them. */
const STOOD_IN = new Set(["sudo", "systemctl", "launchctl"]);

/** On globalThis, because `vi.resetModules` evaluates this file afresh for each importer. */
const HIDDEN_KEY = "__failproofaiHiddenSystemPrograms";

/** Programs to report as absent from root's directories, for the current test. */
export function hiddenSystemPrograms(): Set<string> {
const store = globalThis as Record<string, unknown>;
if (!(store[HIDDEN_KEY] instanceof Set)) store[HIDDEN_KEY] = new Set<string>();
return store[HIDDEN_KEY] as Set<string>;
}

export function standInSystemCommand(actual: SystemCommand): SystemCommand {
const systemCommandPath = (name: string): string | null => {
if (hiddenSystemPrograms().has(name)) return null;
return actual.systemCommandPath(name) ?? (STOOD_IN.has(name) ? `/usr/bin/${name}` : null);
};
const requireSystemCommand = (name: string): string => {
const path = systemCommandPath(name);
if (!path) throw new Error(`${name} was not found in ${actual.SYSTEM_BIN_DIRS.join(", ")}`);
return path;
};
const sudoPath = (): string | null => systemCommandPath("sudo");
const sudoCommandLine = (command: string, ...args: string[]): string | null => {
const sudo = sudoPath();
const program = systemCommandPath(command);
return sudo && program ? [sudo, program, ...args].join(" ") : null;
};
return { ...actual, systemCommandPath, requireSystemCommand, sudoPath, sudoCommandLine };
}
Loading