astro:env
leak detection
#956
Replies: 4 comments 2 replies
-
For opt-out, might make sense to have both |
Beta Was this translation helpful? Give feedback.
-
@florian-lefebvre This is a great proposal! I have a few questions about all of this if you don't mind me asking here are just a couple that I can think of:
|
Beta Was this translation helpful? Give feedback.
-
This is great!! You can read more about our (DMNO) other security related features here and here. The leak detecting middleware is quite straightforward. We also inject a check into the vite build process to detect any leaks in built javascript files. We currently don't have any per-item opt-out although we probably will add it. I suspect the false positives will come from users having values set like Described there is one more feature that I don't think @florian-lefebvre had seen yet - which is intercepting http requests so secrets can only be sent to a list of allowed domains. For example a Stripe secret key is only allowed to be sent to For both log redaction and http interception, we are patching node globals. It is surprisingly easy to do for a normal node.js application, but things get a bit dicey when you add in lambas, edge runtimes, and all the various build processes that occur between your code and running in some environments. For example, the Lambda and Vercel function runtimes are already patching console methods to redirect console logs to their own logging services. Extra care also needs to be taken to re-trigger the patching logic at the right times, since it's not always just a single long-running process. For http interception, we are relying on @mswjs/interceptors. Please if you want to try it out and get a feel for how it feels, give DMNO a spin - we'd love to know what you think! Relevant code is here: |
Beta Was this translation helpful? Give feedback.
-
I quite like Astro having first class support for this as it shows I wonder if making it an option under About the line where we do leak detection, I think the current middleware logic of scanning responses (or rendered strings somewhere else) is enough. I don't think we should intercept anything pass that, like patching globals. The existing leak detection should be enough to capture most cases. |
Beta Was this translation helpful? Give feedback.
-
Body
Summary
Add an opt-in feature to
astro:env
to allow detecting leaked secrets.Background & Motivation
Although secrets are supposed to only be used server-side, it's easy to leak them by mistake:
Goals
4321
)Example
This feature is inspired by DMNO (really great tool check it out!).
Client-side leak detection can be done using a middleware, see attempt withastro/astro#11203.
Terminal masking probably require overriding? Not ideal
Questions
Are there any other aspect we need to cover?
Beta Was this translation helpful? Give feedback.
All reactions