Skip to content

Feature/create security cookie #2

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

Merged
merged 4 commits into from
May 27, 2023
Merged

Conversation

simonhamp
Copy link
Member

Adds a route for the security cookie to be created by the runtime

@mpociot
Copy link
Member

mpociot commented May 19, 2023

Why do we need such a cookie? 🤔

@simonhamp
Copy link
Member Author

It means the local PHP server application can't be accessed directly by another browser, only by the environment

This will prevent a whole slew of attack vectors where, for example, a public webpage could embed some request/iframe to exploit behaviour on the users machine or exfiltrate private data

Consider a public webpage is crafted to direct a user to GET http://localhost:3000/api/clipboard and now the users clipboard has been accessed without any explicit permission

(Equally applies to any unsecured endpoint served by PHP or Electron/Rust - I'm still working on securing the Rust server)

So far, I haven't found a way to let Tauri set custom headers for the webview, so it's an alternative way of doing that

So for the Tauri implementation right now, the first request when booting the app is to /_native/api/cookie?secret={randomly-generated-secret} where {randomly-generated-secret} is a UUID4 generated in Rust that is passed to the PHP application as an env value at boot up of the PHP web server

In that way it's like a rotating pre-shared key that we can use to make sure both sides of the app only talk to each other

This is client->server, but equally something like this should apply PHP<->Rust/Electron (tho we can just use the header there)

@simonhamp simonhamp merged commit e55a31d into main May 27, 2023
@simonhamp simonhamp deleted the feature/create-security-cookie branch May 27, 2023 21:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants