Skip to content
mentoor

Topic 2 of 4 · 5 min read

Sandboxing and consent for app interfaces

Goal: Review an MCP App's resource and security declarations and find the permission or consent gap a reviewer should reject.

An MCP App is third-party code running next to the user's conversation, so review it like a browser extension: list what it can reach, and reject anything the feature does not need. The host enforces the limits. Your job as author and reviewer is to declare the smallest set.

Check yourself · 1 of 3

What does the _meta.ui.csp declaration on an MCP App's resource control?

Choose one answer

Why it matters

The page may come from a server the user connected five minutes ago. It can draw anything, including a fake login form or a fake "Approve" button inside the chat. It can try to call tools. Hosts therefore render it in a sandboxed iframe with no access to the host page's DOM, cookies or local storage, and with a content security policy built from the server's declarations.

What to check, in order

  1. CSP domains. The UI resource's _meta.ui.csp lists origins the page may use: connectDomains for fetch, XHR and WebSocket, and resourceDomains for scripts, images, styles and fonts. If it is omitted, the host applies a restrictive default. Every extra origin is a place data can leave or code can arrive from.
  2. Permissions. _meta.ui.permissions requests capabilities such as camera or microphone. A chart does not need a microphone.
  3. Tool visibility. A tool's visibility is ["model", "app"] by default. Set ["app"] for tools only the page should call, such as a submit action, and the host must hide them from the model. Set ["model"] when the page has no reason to call a tool.
  4. Consent. A tool call started from the page still acts as the user. Destructive or costly calls need the host's approval prompt, and the tool description should say what changes.
  5. Spoofing. Check that the view cannot pass as part of the host: no fake system dialogs, no sign-in forms asking for passwords.

Before and after

{
  "_meta": { "ui": {
    "csp": {
      "connectDomains": ["*"],
      "resourceDomains": ["https://cdn.jsdelivr.net", "https://unknown-cdn.example"]
    },
    "permissions": { "microphone": {}, "camera": {} }
  } }
}

A chart viewer that loads one library needs far less:

{
  "_meta": { "ui": {
    "csp": { "resourceDomains": ["https://cdn.jsdelivr.net"] }
  } }
}

No network origin for connectDomains, no device permissions. Better still, bundle the library and declare nothing.

What goes wrong

  • Wildcard or unexplained domains. A page that can connect anywhere can send whatever it renders to anyone.
  • Over-broad tools reachable by the page. A delete_project tool left at default visibility can be triggered by a compromised page and listed to the model.
  • Trusting the sandbox for everything. The sandbox protects the host page. It does not stop a view from showing a convincing fake prompt to the user.

Examples

Review comment on a manifest

A reviewer reads a dashboard view that declares connectDomains: ["*"]. The page only calls the server's own tools through the host, so it needs no network origin. Comment: remove connectDomains, keep the one CDN in resourceDomains, or bundle the script and declare none.

Visibility that closes a gap

delete_record is registered with default visibility, so the model can list it and the page can call it. Delete is a button in the page, behind a confirmation. Set visibility: ["app"], and the model no longer sees it. The host also has to reject any other source.

Key points

  • The host renders an app in a sandboxed iframe; the page cannot read the host's DOM, cookies or local storage.
  • The resource's _meta.ui.csp lists the only origins the page may load from or connect to, and each extra origin widens the risk.
  • Permissions such as camera or microphone are requested explicitly, and a view should request none it does not use.
  • Tool visibility decides whether the model, the page or both can call a tool; submit-style tools belong to the page only.
  • A sandboxed view can still imitate a dialog or sign-in form, so reviewers check what the user is shown, not only what the code can reach.

Common mistakes

  • Declaring a wildcard or a long list of origins because it is quicker than finding the real ones.
  • Requesting camera or microphone permissions in a view that never uses them.
  • Leaving destructive tools at default visibility so both the model and the page can call them.
  • Assuming the sandbox makes a view safe to show, ignoring fake prompts and sign-in forms drawn inside it.

Check yourself · 2 of 3

A chart view needs one CDN script and no network calls of its own. Which declaration fits?

Choose one answer

Check yourself · 3 of 3

Why set visibility to ["app"] on a submit_order tool that only the page's Submit button calls?

Choose one answer

Practice items, not counted towards your mastery.

Start here

More for this topic