Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] Unsafe functions in preload contextBridge #522

Open
hyperknot opened this issue Dec 29, 2024 · 0 comments
Open

[Bug] Unsafe functions in preload contextBridge #522

hyperknot opened this issue Dec 29, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@hyperknot
Copy link

Describe the bug

Electron's documentation especially recommends against the pattern used in preload. They are unsafe.

contextBridge.exposeInMainWorld('ipcRenderer', {
on(...args: Parameters<typeof ipcRenderer.on>) {
const [channel, listener] = args
return ipcRenderer.on(channel, (event, ...args) => listener(event, ...args))
},
off(...args: Parameters<typeof ipcRenderer.off>) {
const [channel, ...omit] = args
return ipcRenderer.off(channel, ...omit)
},
send(...args: Parameters<typeof ipcRenderer.send>) {
const [channel, ...omit] = args
return ipcRenderer.send(channel, ...omit)
},
invoke(...args: Parameters<typeof ipcRenderer.invoke>) {
const [channel, ...omit] = args
return ipcRenderer.invoke(channel, ...omit)
},
// You can expose other APTs you need here.
// ...
})

Documentation:
https://www.electronjs.org/docs/latest/tutorial/context-isolation#security-considerations

image

@hyperknot hyperknot added the bug Something isn't working label Dec 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant