Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
886ca0e
[hooks] Guard failproofai's installed code and refuse future-dated pa…
NiveditJain Nov 24, 2026
18328b0
[hooks] Address review: kernel-order symlink walk, pnpm store, $NVM_B…
NiveditJain Nov 24, 2026
8956fde
[hooks] CHANGELOG: cite #1050
NiveditJain Nov 24, 2026
ed5eb18
[hooks] Address hermes review: walk through missing directories; fail…
NiveditJain Nov 24, 2026
a57c623
Merge remote-tracking branch 'origin/main' into claude/sec-1796-dist-…
NiveditJain Nov 24, 2026
bda88fd
[hooks] CHANGELOG: move #1050's lines to 1.0.17-beta.0
NiveditJain Nov 24, 2026
65e9f10
Merge remote-tracking branch 'origin/main' into claude/sec-1796-dist-…
NiveditJain Nov 24, 2026
87045a6
[hooks] CHANGELOG: move #1050's lines to 1.0.18-beta.0 (1.0.17 shipped)
NiveditJain Nov 24, 2026
697fac9
[hooks] Address CodeRabbit: dotted pnpm-store glob; state the one-min…
NiveditJain Nov 24, 2026
6258224
Merge remote-tracking branch 'origin/main' into claude/sec-1796-dist-…
NiveditJain Nov 24, 2026
e91e18f
Merge remote-tracking branch 'origin/main' into claude/sec-1796-dist-…
NiveditJain Nov 24, 2026
603bb46
Merge remote-tracking branch 'origin/main' into claude/sec-1796-dist-…
NiveditJain Nov 24, 2026
70f0e1b
[hooks] Match node_modules and .pnpm only as whole path components
NiveditJain Nov 24, 2026
7ac5740
[hooks] Let a path component start right after a short-option cluster
NiveditJain Nov 24, 2026
d2f4f28
[hooks] Fix quadratic installed-code match: check the component start…
NiveditJain Nov 24, 2026
43bd947
[hooks] Start a path component only after a separator or a shell word…
NiveditJain Nov 24, 2026
1388f38
[hooks] Address hermes: daemon-store globs and case-insensitive glob …
NiveditJain Nov 24, 2026
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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
- `FAILPROOFAI_DAEMON_BASE_URL` must be https, and so must every hop a redirect sends the download to. Plain http is accepted only for a loopback address, because over http the checksum manifest arrives on the same unauthenticated connection as the binary (#1056)
- 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)
- 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)
- 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)

### Docs

Expand Down
308 changes: 308 additions & 0 deletions __tests__/hooks/guard-installed-code.test.ts

Large diffs are not rendered by default.

35 changes: 34 additions & 1 deletion __tests__/hooks/session-pause-cli.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { describe, it, expect, vi, beforeEach, afterEach } from "vitest";
import { mkdtempSync, rmSync } from "node:fs";
import { chmodSync, mkdtempSync, rmSync } from "node:fs";
import { tmpdir } from "node:os";
import { resolve } from "node:path";

Expand Down Expand Up @@ -257,6 +257,39 @@ describe("--resume", () => {
expect(readActivePause("s1", NOW)).toBeNull();
expect(readActivePause("s2", NOW)).toBeNull();
});

// A pause file dated in the future is not honoured, so it is not listed — but
// it turns live when its date arrives. `--all` is how a person ends every
// pause, so it must remove that one too (FailproofAI/agenteye#1796).
it("--all also removes a pause dated in the future, before it can turn live", () => {
writePause({ sessionId: "s1", durationMs: 600_000, now: NOW });
writePause({ sessionId: "later", durationMs: 600_000, now: NOW + 3_600_000 });
expect(readActivePause("later", NOW)).toBeNull();
const r = runPauseCommand({ action: "resume", all: true, cwd: "/tmp/p", now: NOW, render: PLAIN });
expect(r.affected).toBe(1);
expect(readActivePause("later", NOW + 3_600_000)).toBeNull();
});

// A pause file that stays behind is still read by the hook. Reporting
// "Resumed" over it, and exiting 0, left enforcement suspended while saying
// it was back (found in review). Root ignores the mode, so ordinary users only.
it.skipIf(process.getuid?.() === 0)("--all fails, and says so, when a pause file will not go", () => {
writePause({ sessionId: "s1", durationMs: 600_000, now: NOW });
const sessions = resolve(stateDir, "sessions");
chmodSync(sessions, 0o500);
const r = (() => {
try {
return runPauseCommand({ action: "resume", all: true, cwd: "/tmp/p", now: NOW, render: PLAIN });
} finally {
chmodSync(sessions, 0o700);
}
})();
expect(r.exitCode).toBe(1);
expect(r.affected).toBe(0);
expect(r.lines.join("\n")).not.toMatch(/Resumed/);
expect(r.lines[0]).toMatch(/Could not remove every pause file from .*sessions, so enforcement may still be paused/);
expect(readActivePause("s1", NOW)).not.toBeNull();
});
});

// `--status` is a whole-machine screen now (config-status.ts). Its two tests
Expand Down
107 changes: 106 additions & 1 deletion __tests__/hooks/session-pause.test.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import { describe, it, expect, beforeEach, afterEach } from "vitest";
import { mkdtempSync, rmSync, writeFileSync, mkdirSync, readdirSync } from "node:fs";
import { chmodSync, mkdtempSync, rmSync, writeFileSync, mkdirSync, readdirSync } from "node:fs";
import { tmpdir } from "node:os";
import { resolve } from "node:path";

import {
PAUSE_CEILING_MS,
PAUSE_DEFAULT_MS,
clearAllPauses,
clearPause,
formatDuration,
listActivePauses,
Expand Down Expand Up @@ -206,6 +207,110 @@ describe("pause state", () => {
// And it is genuinely inert once the ceiling passes.
expect(readActivePause("sess-h", start + PAUSE_CEILING_MS + 1)).toBeNull();
});

// The clamp above measures the ceiling from `firstPausedAt`, which comes from
// the same file. Moving the START out of reach moved the ceiling with it: a
// file dated 2100 read as live on every tool call until then — a single forged
// write that outlasted every session on the machine (FailproofAI/agenteye#1796).
describe("a pause that claims to start in the future", () => {
const forge = (fields: Record<string, unknown>) => {
writePause({ sessionId: "sess-f", durationMs: 60_000, now: 1_000 });
const [file] = readdirSync(pauseStateDir());
writeFileSync(
resolve(pauseStateDir(), file),
JSON.stringify({ schemaVersion: 1, sessionId: "sess-f", setBy: "cli", ...fields }),
);
};
const now = Date.UTC(2026, 10, 24);
const year2100 = Date.UTC(2100, 0, 1);

it("is not a pause at all", () => {
forge({ pausedAt: year2100, firstPausedAt: year2100, expiresAt: year2100 });
expect(readActivePause("sess-f", now)).toBeNull();
expect(readActivePause("sess-f", now + 30 * 24 * 3_600_000)).toBeNull();
expect(listActivePauses(now)).toEqual([]);
});

it("is refused when only the start of the run is in the future", () => {
forge({ pausedAt: now, firstPausedAt: year2100, expiresAt: now + 60_000 });
expect(readActivePause("sess-f", now)).toBeNull();
});

it("is refused when the run starts after its latest renewal", () => {
forge({ pausedAt: now - 60_000, firstPausedAt: now - 1_000, expiresAt: now + 60_000 });
expect(readActivePause("sess-f", now)).toBeNull();
});

// The writer and the reader share one clock, so a legitimate file is never
// ahead of it by more than a clock correction. Refusing would only ever turn
// enforcement back ON, but a pause that vanishes after a small clock step
// would just be re-issued, so a minute of slack costs nothing.
it("tolerates a small clock step backwards", () => {
forge({ pausedAt: now + 30_000, firstPausedAt: now + 30_000, expiresAt: now + 90_000 });
expect(readActivePause("sess-f", now)?.expiresAt).toBe(now + 90_000);
});

it("never lets a forged start carry into a real renewal", () => {
forge({ pausedAt: year2100, firstPausedAt: year2100, expiresAt: year2100 });
const renewed = writePause({ sessionId: "sess-f", durationMs: 60_000, now });
expect(renewed.firstPausedAt).toBe(now);
expect(renewed.expiresAt).toBe(now + 60_000);
});

// A renewal carries the run's start forward. After a small clock step back,
// that start reads as later than the renewal, and the reader would refuse
// the very pause the CLI had just reported extended.
it("survives a renewal issued just after the clock stepped back", () => {
writePause({ sessionId: "sess-c", durationMs: 600_000, now });
const renewed = writePause({ sessionId: "sess-c", durationMs: 600_000, now: now - 30_000 });
expect(renewed.firstPausedAt).toBe(now - 30_000);
expect(readActivePause("sess-c", now - 30_000)?.expiresAt).toBe(now + 570_000);
});

// Not honoured yet is not the same as gone: a file dated an hour ahead turns
// live in an hour. Ending every pause has to end that one too.
it("is removed by clearAllPauses, which counts only the active ones", () => {
forge({ pausedAt: now + 3_600_000, firstPausedAt: now + 3_600_000, expiresAt: now + 9 * 3_600_000 });
writePause({ sessionId: "sess-live", durationMs: 600_000, now });
expect(clearAllPauses(now)).toEqual({ cleared: 1, incomplete: false });
expect(readdirSync(pauseStateDir())).toEqual([]);
expect(readActivePause("sess-f", now + 2 * 3_600_000)).toBeNull();
});
});
});

// A pause file that stays behind is still read by the hook, so it must never be
// counted as cleared (found in review). Root ignores directory modes, so these
// only mean something for an ordinary user, which is what CI runs as.
describe.skipIf(process.getuid?.() === 0)("clearAllPauses when a file will not go", () => {
const now = Date.UTC(2026, 10, 24);
const withMode = (mode: number, body: () => void) => {
chmodSync(pauseStateDir(), mode);
try {
body();
} finally {
chmodSync(pauseStateDir(), 0o700);
}
};

it("does not count a pause it could not remove, and says so", () => {
writePause({ sessionId: "sess-ro", durationMs: 600_000, now });
withMode(0o500, () => {
expect(clearAllPauses(now)).toEqual({ cleared: 0, incomplete: true });
});
expect(readActivePause("sess-ro", now)).not.toBeNull();
});

// Without read permission the directory cannot be listed, but the hook opens
// each pause by name and still finds it — so "nothing listed" is not "nothing
// paused".
it("reports a directory it cannot list instead of calling it empty", () => {
writePause({ sessionId: "sess-nolist", durationMs: 600_000, now });
withMode(0o300, () => {
expect(clearAllPauses(now)).toEqual({ cleared: 0, incomplete: true });
expect(readActivePause("sess-nolist", now)).not.toBeNull();
});
});
});

describe("formatDuration", () => {
Expand Down
2 changes: 1 addition & 1 deletion docs/reference/failproof-cli.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ Run `failproofai` without arguments to open the local policy dashboard.
| `--session <id>` | Target an explicit session for pause or resume |
| `--all` | With `--resume`, end every active pause |

Local pauses suspend builtin, custom, convention, and pack policies for one session. They always expire and do not disable Cloud-managed policies. `block-failproofai-commands` — which is always on and cannot itself be disabled or paused — prevents an instrumented agent from using this escape hatch itself.
Local pauses suspend builtin, custom, convention, and pack policies for one session. They always expire, at most 8 hours after the first pause in a run, and they do not disable Cloud-managed policies or `block-failproofai-commands`, which is always on and cannot itself be disabled or paused. That guard refuses the direct ways an instrumented agent could pause itself: running `failproofai config --pause`, or writing the pause file under `~/.failproofai/state/sessions/`. It reads commands, not what a script does when it runs, so a script the agent writes and then runs can still reach the same state. A pause file is checked for a bounded expiry and a start no more than a minute in the future, not for who wrote it.

## Policy flags

Expand Down
Loading
Loading