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

Add Subresource Integrity Generator #12

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

vzool
Copy link
Member

@vzool vzool commented Feb 8, 2023

This PR uses gulp-sri-hash plugin on a build tool called gulp to force SRI Hash on js,css files when received by html files, gulp can be installed globally with this command:

npm install --global gulp-cli

Don't forget to run npm install to update dev dependencies.
gulp will update html files with recommended coding style and update SRI Hash automatically if necessary.
So, for any new future changes to js,css files contents then you just need to run:

gulp

Finally, for future development just gulp, Commit and Push. 😋✌️

@zigazajc007
Copy link
Member

zigazajc007 commented Feb 8, 2023

We also need to add Nonce-based strict CSP or Hash-based strict CSP. As Passky Website is client side only, we would need to use Hash-based strict CSP.

https://web.dev/strict-csp/

@zigazajc007
Copy link
Member

zigazajc007 commented Feb 8, 2023

CSP is already provided in _headers file and it is not recommended to use CSP inside HTML. It should be provided by Nginx / Apache (Web Server)

@vzool
Copy link
Member Author

vzool commented Feb 8, 2023

CSP is already provided in _headers file and it is not recommended to use CSP inside HTML. It should be provided by Nginx / Apache (Web Server)

I think if it does provide on both sides it will be better, so zero trust means every party must always verify. 🤗

@zigazajc007
Copy link
Member

CSP is already provided in _headers file and it is not recommended to use CSP inside HTML. It should be provided by Nginx / Apache (Web Server)

I think if it does provide on both sides it will be better, so zero trust means every party must always verify. hugs

Would need to check / make a research about the disadvantages on providing CSP in both ways.

@vzool
Copy link
Member Author

vzool commented Feb 9, 2023

Would need to check / make a research about the disadvantages on providing CSP in both ways.

Of course there is one issue which is an advantage also, website will no longer work with HTTP when access a deployment on LAN (http://192.168.x.x), and that's an excellent thing.
So, the solution is by providing Self-Singed certificate which is better than a plain-text and access LAN deployment by (https://192.168.x.x). 🤗
Even, all browser will just give certificate error with the option to ignore and continue surving the website. 😋✌️

@vzool
Copy link
Member Author

vzool commented Feb 9, 2023

We also need to add Nonce-based strict CSP or Hash-based strict CSP. As Passky Website is client side only, we would need to use Hash-based strict CSP.

https://web.dev/strict-csp/

Done 😋✌️

@vzool
Copy link
Member Author

vzool commented Feb 9, 2023

Now if you try to inject any code like:

let script = document.createElement("script");
script.innerHTML = "alert('YOU HAVE BEEN HACKED');";
document.body.appendChild(script);

It will not allow you to do that anymore, this is too delicious. 😋✌️

Screenshot 1444-07-18 at 11 24 00 AM

@vzool
Copy link
Member Author

vzool commented Feb 9, 2023

This is the current status 🙈

Screenshot 1444-07-18 at 11 26 56 AM

@zigazajc007
Copy link
Member

Would need to check / make a research about the disadvantages on providing CSP in both ways.

Of course there is one issue which is an advantage also, website will no longer work with HTTP when access a deployment on LAN (http://192.168.x.x), and that's an excellent thing. So, the solution is by providing Self-Singed certificate which is better than a plain-text and access LAN deployment by (https://192.168.x.x). hugs Even, all browser will just give certificate error with the option to ignore and continue surving the website. yumv

Sadly this won't be possible because of Umbrel and also Tor. Both Umbrel and Tor operate on HTTP.

@vzool
Copy link
Member Author

vzool commented Feb 9, 2023

Sadly this won't be possible because of Umbrel and also Tor. Both Umbrel and Tor operate on HTTP.

I'm not sure why Umbrel supposes that a LAN network is always safe, in fact, it is never safe. Any network attached to the internet it is not safe anymore. I tested Umbrel before and it is still not stable.
So, I think it is fine for Passky to go with Umbrel on HTTPS and later on Tor. 🤔

@zigazajc007
Copy link
Member

zigazajc007 commented Feb 9, 2023

Sadly this won't be possible because of Umbrel and also Tor. Both Umbrel and Tor operate on HTTP.

I'm not sure why Umbrel supposes that a LAN network is always safe, in fact, it is never safe. Any network attached to the internet it is not safe anymore. I tested Umbrel before and it is still not stable. So, I think it is fine for Passky to go with Umbrel on HTTPS and later on Tor. thinking

Umbrel manage certificates on their own, so we would probably need to wait for them to add support first. LAN network is not always safe, but is a lot safer than hosting Passky Server on the internet, as everyone has access to it.

@vzool
Copy link
Member Author

vzool commented Feb 12, 2023

Umbrel manage certificates on their own, so we would probably need to wait for them to add support first. LAN network is not always safe, but is a lot safer than hosting Passky Server on the internet, as everyone has access to it.

gulp building script has been expanded to export extra resources for "insecure HTTP protocol" at the directory:
Passky-Website/dist/http which can be used to build the image for Umbrel.
But, dist/http directory is not tracked by git so you can type gulp to generate all the files, or just call ./publish_for_http.sh from the terminal which will transform the secure HTTPS web app to work with "insecure HTTP protocol". 😋✌️

@vzool
Copy link
Member Author

vzool commented Feb 12, 2023

BTW, on the HTTP side integrity and CSP still works but without the need for the HTTPS channel which will not be required anymore for the transformed app on dist/http, and the original app still force HTTPS.
Now, we can support the best of the two worlds. 🤗

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