← Blog

Gemini Search Entry Points Need a Safe Rendering Boundary

Parminder Singh
Parminder Singh··5 min read
Summarize with AI

Gemini grounded responses can include a searchEntryPoint with renderedContent for embedding and sdkBlob containing base64-encoded JSON. A gateway should validate the response shape, decode within strict limits, and send display content through an isolated rendering policy before it reaches an authenticated user or agent.

Problem-Awareai-securityllm-securitypolicy-enforcementzero-trustarchitectureaudit
Gemini Search Entry Points Need a Safe Rendering Boundary

Gemini grounding can return searchEntryPoint inside a candidate's groundingMetadata. Google's API schema describes renderedContent as a web content snippet that can be embedded in a page or app webview. The same object can carry sdkBlob, a base64-encoded JSON representation of an array of tuples. Those fields cross a provider-to-application trust boundary even when the HTTP response has status 200.

I want the gateway to validate the object before any browser or webview consumes it, and before any template engine or agent does. Search suggestion rendering belongs behind a narrow response policy with byte limits, exact types, controlled decoding, and an isolated display path.

TL;DR

  • Validate searchEntryPoint as an optional typed object inside candidate groundingMetadata.
  • Treat renderedContent as untrusted embeddable web content and send it through a dedicated rendering policy.
  • Base64-decode sdkBlob within a strict size budget and parse JSON once. Validate the expected array shape.
  • Preserve raw-field hashes, validation findings, model version, response ID, and the final delivery decision.

The response contains display-capable content

Google's GenerateContent API reference defines the broader response envelope, including candidates and grounding metadata. The official Google Search grounding guide explains that grounded responses include search suggestions for display in an application's interface. Its current examples describe an HTML snippet returned for that purpose and point implementers to Google's usage requirements.

The machine-readable Gemini API Discovery document gives the exact REST shape. GroundingMetadata.searchEntryPoint is optional. SearchEntryPoint.renderedContent is an optional string described as web content that can be embedded in a page or app webview. sdkBlob is an optional byte-formatted string described as base64-encoded JSON representing an array of tuples.

That description establishes format and intended use. It leaves the application's trust decision to the implementer. My blunt view is that inserting provider-returned markup directly into the main document is careless, even when the provider is Google.

The Google Gemini enterprise security guide places this field-level check inside the wider authenticated Gemini route.

Validate the object before rendering

Start with the response envelope. Confirm that candidates has the route-approved shape and select the candidate under a recorded rule. Then inspect groundingMetadata. If searchEntryPoint is absent, record absence and continue according to the route contract. If present, require an object with only the fields your parser supports.

Apply separate limits to renderedContent and sdkBlob before copying either value. A character limit applied after base64 decoding arrives too late to protect the decoder's allocation. Reject arrays, numbers, nested objects, duplicate JSON members in the surrounding response, and strings above the route budget. Unknown keys can enter quarantine under a strict route or survive in protected raw evidence while the known fields remain withheld.

Keep provider evidence separate from local decisions. Useful fields include candidate index, response ID, model version, raw byte lengths, parser version, validation outcome, and application disposition. The AI audit log schema supplies the identity and policy envelope for those findings.

renderedContent needs an isolated display policy

renderedContent is display-capable web content. Pass it to a renderer created specifically for Google Search suggestions. The renderer should use an allowlist of elements and attributes derived from the integration contract. Enforce approved URL schemes separately. Remove event-handler attributes, active scripting surfaces, unexpected form controls, and link schemes outside the approved set. Cap nesting depth and total nodes before attaching the result to the interface.

A sandboxed iframe or comparably restricted webview adds another boundary between suggestion markup and the application's authenticated document. Content Security Policy should restrict scripts, frames, forms, connections, and link destinations according to the widget's actual needs. The application should bind clicks to approved link handling instead of allowing arbitrary in-page execution.

A useful review fixture is physical and obvious: place the search suggestion inside a white, bordered card with a small Google Search label. If the markup escapes that card or changes the surrounding page, the fixture fails. An overlay covering the sign-out button also fails.

Sanitization rules are application policy. Google documents the field and its intended embedding use; the gateway team owns the safe rendering contract.

sdkBlob needs bounded decoding and schema checks

The Discovery document labels sdkBlob as base64-encoded JSON. Validate the encoded string before decoding. Require the accepted base64 alphabet and padding behavior. Reject whitespace or alternate alphabets unless the contract explicitly permits them, and calculate the maximum decoded size. Decode once into a bounded buffer.

Parse the decoded bytes as UTF-8 JSON under limits for depth, element count, string length, and total input. The schema description says the JSON represents an array of tuples, so an object or scalar should fail validation. A deeply nested payload should also fail. The application still needs a versioned tuple schema before reading positions as names or display labels. Treat URLs under a separate field-specific check. Avoid guessing semantics from an unfamiliar tuple length.

Never evaluate decoded values as JavaScript, template source, CSS, shell text, or a URL without a second field-specific check. The blob is data for the supported SDK path. A valid base64 string proves only that decoding succeeded. Valid JSON proves only that parsing succeeded.

The LLM API parameter allowlisting guide covers the same discipline on request fields. Here, response allowlisting prevents a grounded suggestion object from acquiring capabilities through permissive parsing.

Streaming and malformed states need named outcomes

A streaming collector can receive candidate content before complete grounding metadata arrives. Keep the search entry point provisional until the candidate assembly finishes and the validator sees the complete object. Rendering an early fragment creates an awkward security state because later chunks can change lengths or add fields. They can also complete previously invalid markup.

Give common failures stable names. Use search_entry_point_wrong_type for the enclosing object and rendered_content_oversize for display bytes. Decoding failures can use sdk_blob_invalid_base64, while parsing and shape failures use sdk_blob_invalid_json and sdk_blob_schema_mismatch. Record the exact candidate and stream attempt associated with each finding. A retry should create another attempt because grounded output and search suggestions can change.

Release fixtures should include an absent object, a valid renderedContent string, valid base64 JSON, malformed padding, oversized decoded bytes, a scalar JSON value, excessive nesting, unknown tuple lengths, and extra object keys. Add markup that attempts an event handler, an unapproved URL scheme, a full-page overlay, and a form submission. The accepted fixture should stay inside the small suggestion card.

DeepInspect

DeepInspect can inspect Gemini GenerateContent responses on authenticated user or agent HTTP traffic deliberately routed through its proxy. It can validate searchEntryPoint types and size limits, block malformed response fields, bind the result to route policy, and write a per-decision audit record before delivery.

The application owns the sanitizer implementation, browser or webview isolation, click handling, tuple semantics, and any action after the response leaves the routed exchange. Direct Gemini calls, local rendering paths that bypass the proxy, STDIO traffic, and Google's internal search processing remain outside DeepInspect's enforcement and evidence.

Book a technical deep dive at deepinspect.ai.

Frequently asked questions

Is renderedContent safe because Google generated it?

Provider origin supplies provenance, while the application still decides how returned web content enters its authenticated interface. Validate the field and use a dedicated isolated renderer with an integration-specific allowlist.

Should the gateway strip all HTML from renderedContent?

The route's display contract decides. Plain-text conversion may break the search suggestion experience or attribution requirements. A dedicated sanitizer and isolated renderer can preserve approved markup while blocking capabilities the application never granted.

What does sdkBlob contain?

Google's current API schema describes it as base64-encoded JSON representing an array of tuples. The schema does not define a universal application meaning for every tuple position. Use the supported integration contract and reject unfamiliar shapes.

Can valid base64 be accepted without parsing the JSON?

Decode under a size limit, parse the UTF-8 JSON, and validate its array and tuple structure before any consumer reads it.

Should missing searchEntryPoint block the whole Gemini response?

Route policy determines the missing-field disposition. A route that promises search suggestions may hold a response with missing metadata, while another can deliver grounded text and record that the optional entry point was absent.

Does this protect Google's internal search systems?

This control protects the enterprise application's response boundary. It validates and renders fields returned over the authenticated user or agent to Gemini HTTP exchange. Google's internal search infrastructure sits outside that boundary.