Skip to content

skip balance checks in cloud-agent and webhook triggers#35

Merged
pandemicsyn merged 2 commits intomainfrom
florian/chore/cloud-agent-skip-balance-checks
Feb 5, 2026
Merged

skip balance checks in cloud-agent and webhook triggers#35
pandemicsyn merged 2 commits intomainfrom
florian/chore/cloud-agent-skip-balance-checks

Conversation

@pandemicsyn
Copy link
Copy Markdown
Contributor

@pandemicsyn pandemicsyn commented Feb 5, 2026

Skip balance checks in cloud-agent and webhook triggers during kilo league

@pandemicsyn pandemicsyn marked this pull request as ready for review February 5, 2026 16:02

export function createCloudChatClient(authToken: string): CloudAgentClient {
return new CloudAgentClient(authToken, {
skipBalanceCheck: true,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CRITICAL: skipBalanceCheck is hard-enabled for createCloudChatClient()

createCloudChatClient() always sets skipBalanceCheck: true, which sends the x-skip-balance-check header for all requests from this client. If this is used outside of a separately-billed product surface, it effectively disables server-side balance enforcement in cloud-agent. Consider either (a) keeping skipBalanceCheck limited to explicitly separately-billed integrations (e.g. App Builder/Slack), or (b) adding an explicit server-side authorization check gating when this client can be used.

const authToken = generateApiToken(ctx.user);
const githubToken = await getGitHubTokenForUser(ctx.user.id);
const client = createCloudAgentClient(authToken);
const client = createCloudChatClient(authToken);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CRITICAL: Cloud Agent router now bypasses balance validation

This router previously constructed the default client; it now uses createCloudChatClient() (see cloud-agent-router.ts), which hard-enables skipBalanceCheck. The router’s existing checkEligibility endpoint is informational only and doesn’t enforce anything on mutations/subscriptions, so this change can allow running sessions with insufficient credits unless there is another server-side gate.

@kilo-code-bot
Copy link
Copy Markdown
Contributor

kilo-code-bot bot commented Feb 5, 2026

Code Review Summary

Status: 3 Issues Found | Recommendation: Address before merge

Overview

Severity Count
CRITICAL 3
WARNING 0
SUGGESTION 0

Fix these issues in Kilo Cloud

Issue Details (click to expand)

CRITICAL

File Line Issue
cloudflare-webhook-agent-ingest/src/queue-consumer.ts 299 Hard-coded x-skip-balance-check: true bypasses credit enforcement for webhook-trigger sessions
cloudflare-webhook-agent-ingest/src/queue-consumer.ts 376 Hard-coded x-skip-balance-check: true bypasses credit enforcement for webhook-trigger sessions
src/components/cloud-agent/CloudSessionsPage.tsx 76 Hard-coded hasInsufficientBalance = false disables eligibility gating in UI
Files Reviewed (7 files)
  • cloudflare-webhook-agent-ingest/src/queue-consumer.ts - 2 issues
  • src/app/(app)/cloud/webhooks/WebhookTriggersListContent.tsx - 0 issues
  • src/app/(app)/cloud/webhooks/new/CreateWebhookTriggerContent.tsx - 0 issues
  • src/components/cloud-agent/CloudSessionsPage.tsx - 1 issue
  • src/lib/cloud-agent/cloud-agent-client.ts - 0 issues
  • src/routers/cloud-agent-router.ts - 0 issues
  • src/routers/organizations/organization-cloud-agent-router.ts - 0 issues

@pandemicsyn pandemicsyn changed the title skip balance checks in cloud-agent skip balance checks in cloud-agent and webhook triggers Feb 5, 2026
'Content-Type': 'application/json',
Authorization: `Bearer ${token}`,
'x-internal-api-key': internalApiSecret,
'x-skip-balance-check': 'true',
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CRITICAL: Balance check bypass via x-skip-balance-check

Hard-coding x-skip-balance-check: true on the internal prepareSession call bypasses credit enforcement for webhook-trigger initiated sessions. If this header is honored in production, this is effectively a billing/eligibility bypass. It also makes the 402 handling below largely unreachable.

'Content-Type': 'application/json',
Authorization: `Bearer ${token}`,
'x-internal-api-key': internalApiSecret,
'x-skip-balance-check': 'true',
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CRITICAL: Balance check bypass via x-skip-balance-check

Same concern as the prepareSession request above: this hard-codes a balance-check bypass on initiateFromKilocodeSessionV2, which can enable running webhook-trigger sessions without sufficient credits.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

its fine this is temporary

: personalEligibilityQuery.isPending;
const hasInsufficientBalance =
!isEligibilityLoading && eligibilityData && !eligibilityData.isEligible;
const hasInsufficientBalance = false;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CRITICAL: Hard-coded hasInsufficientBalance = false disables eligibility gating

This forces the UI to treat every user/org as eligible, regardless of what the checkEligibility endpoint would return. If server-side balance checks are also being skipped, this becomes a direct billing bypass; if server-side checks still enforce, users will hit late 402 failures after form submission.

@pandemicsyn pandemicsyn merged commit 70b67b4 into main Feb 5, 2026
20 of 21 checks passed
@pandemicsyn pandemicsyn deleted the florian/chore/cloud-agent-skip-balance-checks branch February 5, 2026 17:51
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.

2 participants