Skip to content

Security: Require cross-origin iframes to opt-in to user-agent tool exposure #389

Todo

Description

@khushalsagar

Currently, there's no way for a descendant cross-origin iframe to decide whether its tools are exposed to the user-agent based on which origin is embedding it. The issue was discussed here but never made it to the spec.

I was dubious about the use-case for this constraint since foo.com is already embeding you. When would you be ok with an origin embedding you in an iframe but not ok with exposing your tools to the user-agent in this state? This is coming from a desire to make security here more robust. cross-frame embedding is allowed by default and frames have to explicitly opt-out of it with CSP. Tool composition could be more conservative by being an opt-in: even if you were embedded by attacker.com the browser doesn't use your tools.

The latest proposal here has a permission policy for the embedder to select which frames are used. This issue is about the embedee controlling whether its used based on which origins are embedding it. We talked about reusing exposedTo for this: the user-agent uses a tool from the embedded page if all origins in its ancestor chain are in exposedTo. This doesn't make sense because the embedded page could be ok with exposing a tool to the user-agent but not the embedder.

So this issue would need some hook for this ancestor list. Could be a new userAgentToolAncestors option on Tool which works like frame-ancestors in CSP and defaults to same-origin only.

@johannhof FYI.

Activity

  1. johannhof commented on Nov 23, 2026

    @johannhof
    Contributor

    Thank you for filing this! The concern here is that we should not make the same mistakes that the original iframe design made in allowing clickjacking by default, for agents. A malicious top-level site could viably embed a third party to disguise the third-party tools as part of its own toolset ("Shop simulator - including fake real-merchant.example transaction tools").

    To be clear, I would be okay with optional wildcard ("*") exposure here to enable broadly embeddable tools if the developer opts into it. But the opt-in seems critical to avoid introducing a new fundamental security flaw in the Web Platform.

    We previously solved this using Document Policy, and I thought that #160 (which removed DP) had maintained our security stance here but looking back I'm not sure the solution proposed there was ever a good long-term approach for this.

    cc @victorhuangwq @domfarolino @jpagnucco

  2. khushalsagar commented on Nov 23, 2026

    @khushalsagar
    CollaboratorAuthor

    I'd prefer not to add another knob that only matters for authors who aren't explicitly setting frame-ancestors. There's no case where "I'm ok being embedded by X" differs from "I'm ok exposing tools to the user agent while embedded by X". This whole issue is coming up from because frame-ancestors defaults to frame-ancestors *. This issue could come up for any new feature. Do we really want each such feature to have its own frame-ancestors-style allowlist?

    Another way we could do this: Don't use tools from embedded cross-origin iframes unless an explicitly set frame-ancestors policy allows that embedding? Throw a console warning if an embedded frame registers a tool which wasn't used for this reason so authors know how to fix it. I am unsure about this because its weird for the presence of the policy to turn on the feature. But this seems more aligned with the intent of this issue so putting it out there.

  3. martinthomson commented on Nov 24, 2026

    @martinthomson

    I'm inclined to agree with @khushalsagar. frame-ancestors might be disengaged by default, but it's a better tool for this.

    In addition, an origin can make decisions about what to expose based whether it is framed (window.self !== window.top) or even how (with location.ancestorOrigins). That's a small check to run before exposing tools. Still, if the goal is to engage static policy, frame-ancestors is the tool.

    There seems to be a real risk here in that tools provided to the browser might be falsely contextualized based on prompt-injected content from the embedder. That's a problem for agentic browsers to address with prompt injection defenses. I don't see how this needs any sort of special API surface.

    You could change defaults, which would be safer for everyone, but I'm guessing that there isn't a whole lot of appetite for that. Nor do I really think that static policies are the best way to manage this risk.

  4. victorhuangwq commented on Nov 25, 2026

    @victorhuangwq
    Contributor

    based on the discussion in the original #57, i was also thinking we needed something that clearly indicates the x-origin iframe is opting in. dominic wrote this back in #160:

    So basically, by default main frame tools are exposed to the native agent by default, and cross-origin iframe tools are not (they have to opt-in with exposedTo: ['native-agent'] or some keyword we need to bikeshed. Both can opt-out of native agent exposure by explicitly providing an exposedTo array, without the magic keyword.

    seems like it didn't quite make it into the spec yet? right now it's kind of up to the UA:

    While exposure of tools to the browser agent is implementation-defined, user agents are expected to include the origin field to avoid confusion that could be exploited by an attacker.

    and in chromium, it seems like currently allow="tools" from the embedder is enough, nothing from the cross origin iframe?

    i would like to bring that idea back:

    • embedder: allow="tools", same as today
    • embeddee: has to add 'native-agent' (naming tbd), or potentially the "*" mentioned (though that's still under debate), to expose a tool to the built-in agent, otherwise it's disabled
    • if it only wants certain embedders, it can check location.ancestorOrigins before adding it

    this is mainly about @johannhof's point on not "allowing clickjacking by default, for agents". a site that's just adding its tools, without knowing where it's being embedded, shouldn't be surprised later to find them being used by the built-in agent on someone else's page.

  5. khushalsagar commented on Nov 26, 2026

    @khushalsagar
    CollaboratorAuthor

    I don't like the proposal above. A 'native-agent' option makes it sound like the intent is to convey whether a tool is suitable for the native agent which is not the case here. The real intent here is to say: "The embedder may try to attack me with prompt injection so the browser shouldn't use my tools". The binary flag also means authors wouldn't really think about an origin list.

    And I come back to: this should be expressed by frame-ancestors. A separate option doesn't make sense because as an author how do I decide when I should be allowing embedding by frame-ancestors but disallowing tool use.

  6. victorhuangwq commented on Nov 26, 2026

    @victorhuangwq
    Contributor

    Okay, then looking at this through frame-ancestors lens, I do broadly agree that if an author explicitly allowlists an origin for embedding, it seems reasonable to also make the embedded page’s tools available to the browser agent in that context.

    The default case is where like Johann said, the concern comes in: authors might register tools without anticipating a malicious embedder using prompt injection to get the agent to call them, since frame-ancestors defaults to *.

    I guess the safer default, when no frame-ancestors is declared, is to still allow embedding but not expose the page’s tools to the browser agent when it’s in a cross-origin iframe? I guess this is the part where Martin is talking about the lack of appetite for changing defaults?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions