Skip to content

Fix budget-control bypass and enforce strict spend rules - #5

Open
mozluk wants to merge 1 commit into
sapiom:mainfrom
mozluk:mozluk-patch-2
Open

Fix budget-control bypass and enforce strict spend rules#5
mozluk wants to merge 1 commit into
sapiom:mainfrom
mozluk:mozluk-patch-2

Conversation

@mozluk

@mozluk mozluk commented Aug 16, 2026

Copy link
Copy Markdown

Summary:
This PR patches a HIGH-severity vulnerability where transient governance API failures allowed bounded jobs to execute as unbounded, unmetered tasks. It enforces a "fail closed" policy on spend-rule creation and integrates strict, pre-call budget checks into the orchestration engine.

Changes:

Fail Closed Policy: Updated app/api/jobs/create/route.ts to treat spend-rule creation failures as fatal. The API now rejects job creation and returns a 502 status if sapiomCreateSpendRule fails, preventing the persistence of jobs without budget boundaries.

Authoritative Pre-Call Checks: Refactored lib/orchestrator.ts to perform a strict budget check (spendRef.total + cost > job.budget) inside trackAndExecute before invoking any paid tool APIs. Tools are preemptively aborted if their execution would exceed the job's defined limits.

Summary:
This PR patches a HIGH-severity vulnerability where transient governance API failures allowed bounded jobs to execute as unbounded, unmetered tasks. It enforces a "fail closed" policy on spend-rule creation and integrates strict, pre-call budget checks into the orchestration engine.

Changes:

Fail Closed Policy: Updated app/api/jobs/create/route.ts to treat spend-rule creation failures as fatal. The API now rejects job creation and returns a 502 status if sapiomCreateSpendRule fails, preventing the persistence of jobs without budget boundaries.

Authoritative Pre-Call Checks: Refactored lib/orchestrator.ts to perform a strict budget check (spendRef.total + cost > job.budget) inside trackAndExecute before invoking any paid tool APIs. Tools are preemptively aborted if their execution would exceed the job's defined limits.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant