Skip to content

Safe ipc between browser and app #456

Closed

Description

@cpsubrian

I am loading potentially unsafe pages into a BrowserWindow, however, I still need those windows to be able to send messages to the server. If I use node-integration = disable, to make loading the page safe, that disables the ability to use ipc, correct?

Activity

  1. zcbenz commented on Jul 21, 2014

    @zcbenz
    Contributor

    The ipc relies heavily on the node integration so it is unlikely that we would ever support using ipc without node integration.

    For your purpose, you may put the unsafe pages in iframe and do the ipc in the main frame.

  2. cpsubrian commented on Jul 21, 2014

    @cpsubrian
    Author

    Just a note, I would then need the iframe to communicate with the main frame, which can certainly be done with something like window.postMessage.

    Thanks for clarifying the situation :)

  3. abram commented on Jul 24, 2014

    @abram

    I think there might still be an issue here. I'm working on an app that needs to be able to do the following:

    1. Load an arbitrary user-supplied web page into a secure container
    2. Inject some Javascript code into the page
    3. Have the page send back a message with results

    At first glance, this would seem be possible in Atom today using a iframe with node-integration=disable and window.postMessage. However, many pages use the X-Frame-Options header to prevent being loaded in an iframe. So that means I have to load these pages in their own window. But with node integration disabled, I don't think there's any way for me to receive messages from that window, or listen for postMessage events.

    Thoughts? Am I missing something?

  4. buschtoens commented on Jul 24, 2014

    @buschtoens

    @abram So basically what you're asking is: How can I make Atom ignore the X-Frame-Options header? 😄

  5. abram commented on Jul 24, 2014

    @abram

    @phvcky I think that would work, although I'm not sure if old-fashioned Javascript-based frame-busting would still be an issue. If there's going to be an iframe that acts like a self-contained window, I think the ideal solution would be the ability to embed a BrowserWindow or WebContents in a page, similar to the webview tag in Chrome apps. Of course, that would still leave the problem of not being able to listen for postMessage events on the embedded WebContents.

  6. srlowe commented on Nov 5, 2015

    @srlowe

    IMO a node-integration = ipc-only option (or a seperate ipc-only = <bool> field) would be a good solution.

  7. whiskyagogo commented on Nov 6, 2015

    @whiskyagogo

    I second the suggestion from @bgSosh. We only need the ability to pass messages and it would be wonderful to use the provided ipc module without concerns for full node access security issues.

  8. arendjr commented on Nov 6, 2015

    @arendjr

    +1 for being able to use IPC from web pages.

  9. jdurand commented on Nov 25, 2015

    @jdurand

    Is there a simple way to receive CustomEvents from outside the BrowserWindow? Something like :

      // main.js
      browserWindow.on('custom-event', function(e) { doSomething(); });
      // index.html
      window.dispatchEvent(new CustomEvent('custom-event'))

    I thinking of writing a hack by listening on page-title-updated and I don't think I'll be able to look at myself in the mirror if I go through with it...

  10. anaisbetts commented on Nov 25, 2015

    @anaisbetts
    Contributor

    Being able to use IPC means you can use remote eval, because that's how remote eval works. Having IPC enabled in a webpage is no different from a security boundary perspective than having node integration enabled

  11. ava-sig commented on Apr 26, 2016

    @ava-sig

    I need to use jQuery from the pages that user loads in renderer process, but still use ipc.
    In order for the websites to load properly I need to disable node integration so they can use jquery.
    Does anyone have any idea how that might be achieved ? I'm doubtful that I'm the only one that needs jQuery on pages to load in Renderer process but still be able to use ipc., so any help would be appreciated, since I've read through issues #2048 and #1753, even tried #3921 with no succes.

  12. ava-sig commented on Apr 26, 2016

    @ava-sig

    nevermind, I managed to implement electron-safe-ipc which works perfectly with nodeIntegration off, exactly what I needed.

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