How do secrets leak through frontend environment variables?
A value compiled into browser code is readable by visitors. Separate a public API key from a service credential. Having “env” in a variable name does not make it private; inspect the generated JavaScript.
How to check it
- Find which variables browser code uses.
- Keep service-role and management credentials on the server.
- Scan build output for sensitive variable names and value patterns.
Concrete example
Example: a Supabase publishable key can be used by a client while RLS restricts data access. Putting a service-role credential in that bundle breaks the intended security boundary.
Avoid a false conclusion
Deleting an exposed secret from a file is insufficient. Revoke or rotate it, inspect access logs and account for historical copies.
Reference
VCT Editorial