-
-
Notifications
You must be signed in to change notification settings - Fork 48
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
Provide optional SRI hash when displaying embed code #565
Comments
At what point do you think the My first guess would be to generate it on application / server start how ever I'm not quite sure whether it is possible that the JS file (and therefore the corrosponding hash) can update during runtime? |
The only time when it could update would be at update time (which is why having the SRI hash should not be the default: it could break on update). Computing the hash could probably happen in two ways:
I think both options are fine, and in case you are planning to implement this (?) I'd probably pick the option you are more familiar with. Let me know if I can provide any further help. |
Thanks for your thoughts! My approach would be something like the following:
I think that's it? |
Tagging @hendr-ik who might have a picture of how such a feature could look like.
This should probably work if you do it on demand only.
We're stuck on npm 6 here because of the project layout and some npm issues
should give you a working development environment. |
The docker-compose setup worked like a charm.
This might be a local probmen though. I think I will get this going somehow and hopefully come back with a PR. |
In the docker-compose setup, you need to run every command inside the matching container. I.e. your command would turn into
The |
Thanks! That worked. I'm currently thinking about what would be the best way to retrieve the content of the Since I'm not really familiar with preact/react I'm wondering what the best way to do it.
My current understanding how ever is that preact does server side rendering (?) so it would be possible to spare that HTTP fetch call, right? Otherwise I would do the fetch and hash creation async on page load of Could you maybe share your thoughts on that? |
Unfortunately I forgot about one thing when I wrote my last comment: if you compute the hash off of a version that you fetch at runtime, the very calculation is vulnerable to MITM attacks, which is what the SRI hash is even supposed to prevent. I.e. if someone compromises the Moving on, I can see two other ways to implement this: Compute hash at build timeThe build for This is probably the "safest" way to do it. Compute hash on the serverAlternatively, the hash could be computed by the Go application at runtime. This value is then injected into the rendered HTML template for the Auditorium which can then read the hash from a global variable or similar. Do you think that makes sense? Let me know if I should clarify anything or if you think that I'm missing something. |
Makes sense. I should have come up with that by myself. It is probably the best way to create one environment variable for each locale? Thanks for your input! Really helpful. |
The script asset is bundled once per locale, so in the code we could always be using the same key on 'process.env'. The relevant place in the code would be: Lines 68 to 70 in c7aed87
|
I see. I'll take a look at it. Thank you. Will defining the envrionment variable inside the gulpfile be enough to make it available inside the Adding the envrionment variable always result in being |
For the production build, yes. The gulpfile does not have to do anything with the dev environment though, in this case env vars are set in the Lines 46 to 48 in c7aed87
I would assume a placeholder value is ok for use in development here? |
I agree with you. A placeholder seems to be fine how ever I think it is important to mention in the docs that under development circumstances the script integrity function does not work because it is only a placerholder value. This question might seem a bit silly but how exactly do I trigger a production build? In the docs I only could find instructions related to the After that I'll probably be able to make a pull request that you can review and give feedback to. |
If you don't pass a target to
so |
Alright.
I'll set everything up and get back to you after production testing. |
I usually use the
should give you a local instance using your build (I doubt you need fake usage data for your needs so you can pass a low number to `-users').
Whatever works best for you. |
Ah. One thing I stumbled across:
You are referring to the If so do we need to create the environment variable in the |
That's a bit of a mindbender, yes. As for setting the env var this definitely needs to happen in the
Both options are fine I guess, the first one might be a little easier to get done as it's only a single place to change. |
I see - sorry to bother you again but how would such a pull of a script file work in theory? I have to admit I'm not quite sure whether this is the relevant piece to look at but the Inside the |
In the |
Hey there and thanks @raLaaaa for your contribution 👏 👏 👏 |
Hey, thank you for your feedback @hendr-ik . I'll still post it here as basis for discussion: I also created a work in progress merge where you can give some feedback on the implementation 👍 |
Some operators might prefer to embed the Offen script with an
integrity
attribute to prevent eventual MITM scenarios.The embed code box in the Auditorium could provide a toggle for displaying the snippet with such an SRI value added. The default behavior should still be using no hash (as this is easier to upgrade).
The text was updated successfully, but these errors were encountered: