Secrets
Secrets in client JavaScript
Keep API keys and tokens out of the JavaScript that browsers download.
Why it matters
Anything sent to the browser can be read by anyone. A key in front-end code is not hidden; it is published.
The usual damage is a bill from a third-party API or access to data the key allows. Moving the call to the server removes the exposure.
How to fix it
-
Search the built JavaScript for key-like strings
-
Move privileged calls behind your own server
-
Use short-lived tokens and restrict them by origin or scope
-
Rotate any key that was shipped to the browser
Prompt for an AI assistant
Copy the text below and paste it into an AI assistant.
You are the person improving this website. Check the item below and fix it if it applies to the site. Item: Secrets in client JavaScript Summary: Keep API keys and tokens out of the JavaScript that browsers download. Steps: 1. Search the built JavaScript for key-like strings 2. Move privileged calls behind your own server 3. Use short-lived tokens and restrict them by origin or scope 4. Rotate any key that was shipped to the browser References: - Secrets Management (OWASP) (https://cheatsheetseries.owasp.org/cheatsheets/Secrets_Management_Cheat_Sheet.html) Constraints: - Keep the existing design and tone of voice. - Show the file or section you changed and the suggested final wording. - Do not decide ambiguous points alone; give options and a recommendation. - Do not change anything outside the listed item.
Checked by
-
vuln
Public exposure checks
Related checks
-
.env file exposure
Make sure .env and other secret files cannot be downloaded from the public site.
-
Source map exposure
Do not publish source maps that contain your original source code.
References
-
Secrets Management (OWASP)
OWASP cheat sheet(Reference)
Check your site now
Enter a URL and find what is missing before launch, for free.
Run audit