Skip to content

Fix: Block unauthenticated paid-API abuse and enforce session governance - #11

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

Fix: Block unauthenticated paid-API abuse and enforce session governance#11
mertcano wants to merge 1 commit into
sapiom:mainfrom
mertcano:mertcano-patch-1

Conversation

@mertcano

Copy link
Copy Markdown

This PR secures the chat and tool execution pathways by strictly enforcing server-validated sessions. It prevents unauthenticated callers from bypassing governance checks and consuming the server tenant’s paid services (such as web search, phone verification, and image generation) without a verified identity or spending rule.

Changes:

app/api/chat/route.ts: Removed the bypassable if (validatedSessionId) check. A verified sessionId and phoneNumber are now strictly required before triggering orchestrate(). Added a payload size limit (50KB) to prevent memory exhaustion

lib/sapiom.ts: Modified sapiomFetch to explicitly require an agentName (session identifier) and disabled fallback to the unauthenticated defaultClient for paid API requests

lib/tools.ts: Added strict context validation (context?.agentName) in tool executors to ensure billing and governance boundaries are respected before invoking paid services.

This PR secures the chat and tool execution pathways by strictly enforcing server-validated sessions. It prevents unauthenticated callers from bypassing governance checks and consuming the server tenant’s paid services (such as web search, phone verification, and image generation) without a verified identity or spending rule.

Changes:

app/api/chat/route.ts: Removed the bypassable if (validatedSessionId) check. A verified sessionId and phoneNumber are now strictly required before triggering orchestrate(). Added a payload size limit (50KB) to prevent memory exhaustion

lib/sapiom.ts: Modified sapiomFetch to explicitly require an agentName (session identifier) and disabled fallback to the unauthenticated defaultClient for paid API requests

lib/tools.ts: Added strict context validation (context?.agentName) in tool executors to ensure billing and governance boundaries are respected before invoking paid services.
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