01. Secret isolation
No privileged credential, bearer token, or unrestricted data key reaches the browser bundle. The server owns secrets and exposes only the narrow operation required.
A practical launch guide for securing public AI generators, calculators, assistants, assessments, and lead magnets from browser to data store.
Get the guideSee the five gates
A public AI feature connects multiple systems in one click. Treating it like an ordinary form hides the places where privileged access, untrusted instructions, generated output, personal data, and unbounded usage cross boundaries.
No privileged credential, bearer token, or unrestricted data key reaches the browser bundle. The server owns secrets and exposes only the narrow operation required.
Define allowed length, structure, task, content classes, and rejection behavior. Treat visitor text as untrusted instructions, not as an extension of the system prompt.
Give the model the minimum data, tools, and privileges the feature needs. High-risk actions require deterministic policy and human approval.
Generated content is untrusted data. Render plain text where possible; otherwise validate, encode, and sanitize for the exact downstream context.
Set rate, token, cost, retention, and read-access ceilings. Log enough to investigate abuse without collecting data the feature does not need.
Run adversarial inputs, inspect the production bundle, test permission boundaries, verify cost controls, and rehearse key rotation and endpoint shutdown.
An internal recruiting-product audit found a public generator where privileged credentials were delivered to the browser and visitor-influenced model output could reach a raw HTML rendering path. The correction moved generation server-side, protected the model credential in a vault, capped public input, returned plain text, and narrowed lead capture to the access it required. This guide shares the defensive pattern without naming the product, repository, vendors, credentials, endpoints, or exploit details. No breach or customer harm is claimed.
Rotating a browser-exposed key is temporary if the replacement must still ship to every visitor.
A plausible answer is not necessarily safe HTML, SQL, a file path, or an instruction for another tool.
A public page that only appends a lead should not receive credentials capable of reading the lead store.
Search the built browser assets for credential patterns, provider hosts, privileged tokens, private endpoints, and unexpected configuration.
Try role changes, instruction overrides, long inputs, encoded payloads, hostile markup, repeated requests, and cross-user data access.
Define per-request and per-identity ceilings, daily budget alerts, timeouts, concurrency limits, and an emergency disable switch.
Rotate credentials, revoke the old path, disable generation, preserve safe lead capture, and confirm the product fails honestly.
OpenAI API documentation says API keys must not be exposed in client-side code. OWASP documents prompt injection, improper output handling, and safe output sinks and encoding. React warns that raw HTML rendering should receive only trusted, sanitized data.