{"slug": "your-public-ai-chatbot-is-an-open-wallet", "title": "Your public AI chatbot is an open wallet", "summary": "The team behind askdare, a successor to the open-source @boldare/openai-assistant, released a public-chatbot framework that moves model choice, instructions, tools, vector stores and OpenAI conversation IDs server-side so browsers receive only signed, encrypted handles. The framework enforces per-visitor, per-IP and per-bot rate limits plus daily token budgets, reserving an estimate before each model call and charging failed or abandoned turns, and can require a Cloudflare Turnstile check that fails closed. The developers warn that in-memory counters let each instance spend the full budget, so production deployments should use a shared store such as Upstash.", "body_md": "Put a chatbot on a public page and you have published an endpoint that spends your money. Anyone can send it a message, every message is billed to your OpenAI project, and a script can send thousands of them.\n\naskdare's threat model starts from one admission: an anonymous public bot can't be made unforgeable. A determined attacker can always use it as a rate-limited LLM. So the goal is narrower and reachable. Bound the damage in requests, tokens and money per day, and stop the attacker from escalating to data, scripts or other people's conversations.\n\nBelow are the threats I'd check in any public chatbot, whatever it's built with, and then what askdare does about each one by default.\n\nThe cheapest attack is a field in the request body. If the browser sends the model name, an attacker sends the most expensive one. If it sends instructions, a vector store ID or a conversation ID, they send their own or try someone else's.\n\nThis isn't hypothetical for us. askdare's predecessor, `@boldare/openai-assistant`, let the client override `assistantId`, reflected any origin in CORS and had no authentication or rate limits. ADR-0004 calls it \"effectively an open, paid proxy\".\n\nIn askdare the client never chooses the model, instructions, tools, vector stores, raw `file_id` values or OpenAI conversation IDs. All of them live in `defineBot` on the server. The browser gets only signed handles. The resume token that carries a conversation ID is encrypted, bound to the bot and the visitor, and a mismatch answers `404`. Uploaded files come back as encrypted handles that expire after an hour, and raw file IDs are refused.\n\nOnce the request can't pick the price, the attacker goes for volume. Rate limits slow one visitor down. Budgets decide what a bad day costs.\n\naskdare has both. By default each bot allows 10 messages per visitor per minute, 30 per IP, 50 turns per conversation and 1,024 output tokens per model call. On top of that sit daily token budgets: 2,000,000 tokens per bot and 200,000 per client IP, counted per UTC day. With several bots, `globalDailyTokens` caps them together:\n\n```\ndefineBot({\n  // …\n  limits: { dailyTokens: 1_000_000, dailyTokensPerIp: 50_000 },\n});\n\nexport const { GET, POST, DELETE } = createChatHandler({\n  bots,\n  limits: { globalDailyTokens: 3_000_000 },\n});\n```\n\nTwo details matter more than the numbers. First, each turn reserves an estimate against every budget before the model is called, and the real usage replaces it afterwards. A turn that fails or times out keeps the estimate charged. Second, a turn whose model call has started runs to the end even if the visitor disconnects, because OpenAI keeps no record of an aborted streamed response, usage included. Disconnecting mid-answer hides nothing from the counter.\n\nCounters live in memory by default, per instance. On Vercel or with several Heroku dynos, every instance would allow the full budget, and a deployment would reset them. Use a shared store, and make production refuse to start without one:\n\n``` js\nimport { upstashStore } from '@boldare/askdare-upstash';\n\nexport const { GET, POST, DELETE } = createChatHandler({\n  bots,\n  limits: { store: upstashStore(), requireSharedStore: process.env.NODE_ENV === 'production' },\n});\n```\n\nPer-IP limits have a hole: they bound what one address can spend, not what many can. Ten addresses use up a bot's default daily budget. For a public chat that attracts scripted traffic, askdare can ask for a Cloudflare Turnstile check when a session starts:\n\n``` js\nimport { defineBot, turnstile } from '@boldare/askdare';\n\ndefineBot({\n  // …\n  security: {\n    allowedOrigins,\n    // The site key is public; the secret key comes from TURNSTILE_SECRET_KEY.\n    humanVerifier: turnstile({ siteKey: '0x4AAAAAAA…' }),\n  },\n});\n```\n\nThe token is verified on the server, and if Cloudflare can't be reached the session is refused, so the check fails closed. A passed check covers session renewals for 24 hours, and renewing can't stretch that. The trade-off is trust. Cloudflare's script runs inside the chat with your app's access, without Subresource Integrity, because Cloudflare updates it in place. That's why it's off by default.\n\nIf your widget loads on any page, anyone can put your bot on their site and let you pay for their visitors.\n\n`security.allowedOrigins` lists the exact origins allowed to embed the chat, such as `https://www.example.com`. No paths, no wildcards. Your app's own origin is always allowed. The browser enforces it through the chat page's `frame-ancestors` policy.\n\n`frame-ancestors` stops browsers. It doesn't stop a script calling the API directly, which is why the limits and budgets above still matter. askdare also uses no cookies: requests carry Bearer tokens and JSON bodies that need a CORS preflight it never grants.\n\nIf session tokens are guessable, unsigned or long-lived, the attacker mints their own or reuses one forever.\n\naskdare issues two tokens, both encrypted JWE with keys derived from `CHAT_SECRET`. The access token lives 15 minutes and stays in memory. The resume token lives 30 days and carries the conversation, opaque to the client. Each token names its bot as audience, the key is looked up by its ID with no fallback, and the visitor ID is generated by the server. `CHAT_SECRET` must be at least 32 characters, and a short or low-entropy secret is refused. You rotate it by moving the old value to `CHAT_SECRET_PREVIOUS`.\n\nThe residual risk is written down too: anyone with physical access to a browser holding a resume token can continue that conversation for up to 30 days.\n\nPer-IP limits are only as good as the IP. The leftmost `X-Forwarded-For` value is whatever the client typed.\n\naskdare reads the client IP according to `trustProxy`. The default, `'auto'`, uses Vercel's headers on Vercel and otherwise trusts one proxy, which matches Heroku's router. Behind a CDN in front of Heroku, set it to the number of proxies. IPv6 addresses are grouped by /64. And never expose `next start` directly to the internet: without a proxy that sets `X-Forwarded-For`, clients choose their own IP and the per-IP limits stop working.\n\nAssume visitors can make the model repeat its instructions, so put no secrets in them: no keys, no internal URLs, nothing you wouldn't put on the page.\n\naskdare keeps instructions, model and tools on the server, and clients can't send system messages. Model output is rendered as Markdown without raw HTML, and images are never loaded, only their alt text, so an injected image URL can't leak the conversation to someone else's server. Three guardrails are opt-in per bot: OpenAI moderation (`moderation`), your own rules for messages and answers (` onInput`, `onOutput`), and `toolResults: 'untrusted'` for tools that return third-party text. That last one lowers the risk of planted instructions in a web page or a ticket. It doesn't remove it, so tools that act on the visitor's behalf should wait for the visitor's approval.\n\nThe last line of defence runs at OpenAI and needs no infrastructure:\n\n`npx @boldare/askdare doctor` names a missing one);\nSet the hard limit a little above what your askdare budgets allow in a month. The budgets then stop spending first, and the hard limit catches what they miss. OpenAI's docs say enforcement isn't instantaneous, so recorded spend can end slightly above the limit.\n\nThe budgets are the main cost control. The OpenAI hard limit is the backstop. If you remember one thing, set both.\n\n`ASKDARE_DISABLED=true` and a redeploy or restart).\nYou pay OpenAI for tokens. askdare is MIT-licensed, made at Boldare, and adds no per-conversation or per-seat fee.\n\n*Sebastian Musiał ([sebastianmusial.pl](https://sebastianmusial.pl/)) builds askdare at [Boldare](https://boldare.com/).*", "url": "https://wpnews.pro/news/your-public-ai-chatbot-is-an-open-wallet", "canonical_source": "https://dev.to/sebastianmusial/your-public-ai-chatbot-is-an-open-wallet-64b", "published_at": "2026-12-04 20:50:57+00:00", "updated_at": "2026-12-04 21:14:38.224905+00:00", "lang": "en", "topics": ["ai-agents", "ai-tools", "developer-tools", "ai-safety"], "entities": ["askdare", "Boldare", "OpenAI", "Cloudflare", "Vercel", "Heroku", "Upstash", "@boldare/openai-assistant"], "also_reported_by": [], "takeaway": "Keep model, instructions, tools and conversation IDs server-side and issue only signed handles, then reserve an estimated token charge against per-bot and per-IP daily budgets before each model call so failed or abandoned turns still count.", "recommendation": {"advice": "Move model selection and conversation IDs out of the request body, enforce per-visitor and per-IP daily token budgets with pre-call reservation, and require a shared counter store in production.", "playbook": "agent-security", "playbook_url": "https://wpnews.pro/playbooks/agent-security"}, "alternates": {"html": "https://wpnews.pro/news/your-public-ai-chatbot-is-an-open-wallet", "markdown": "https://wpnews.pro/news/your-public-ai-chatbot-is-an-open-wallet.md", "text": "https://wpnews.pro/news/your-public-ai-chatbot-is-an-open-wallet.txt", "jsonld": "https://wpnews.pro/news/your-public-ai-chatbot-is-an-open-wallet.jsonld"}}