Sensitive Information in Source Code Comments
HTML, JavaScript or CSS comments sent to the browser contain information useful to an attacker, such as internal host names, file paths, developer notes or credentials.
| Severity | Low |
| CVSS 3.1 | 3.7 CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:L/I:N/A:N Open in the calculator |
| CVSS 4.0 | 6.3 CVSS:4.0/AV:N/AC:L/AT:P/PR:N/UI:N/VC:L/VI:N/VA:N/SC:N/SI:N/SA:N Open in the calculator |
| CWE | CWE-615: Inclusion of Sensitive Information in Source Code Comments |
| OWASP Top 10 | A01:2025 Broken Access Control |
| MITRE ATT&CK | T1594 Search Victim-Owned Websites |
| Category | Information Disclosure |
Description
Comments left in HTML, JavaScript or CSS that the server sends to the browser contain information not meant for users, and anyone can read them by viewing the page source or the delivered files. Comments in server-side code are removed before the response is sent and are not exposed in this way; the finding concerns comments that reach the client, including those kept in unminified scripts and in source maps.
Typical content includes developer notes about known problems or unfinished security controls, commented-out links to administrative, test or unreleased functions, internal host names, IP addresses and file paths, names and email addresses of developers, details of the software in use and, occasionally, credentials, keys or test accounts. These details rarely compromise the application by themselves, but they reduce an attacker's effort: hidden functions and parameters become targets, internal names and paths help plan further attacks, and notes about weaknesses show where to look. Where comments contain credentials, keys or test accounts, the impact is higher and should be rated on what those give access to.
The issue is identified by reviewing the source of the application's pages and scripts, manually or with tools that extract comments from responses, such as the comment-finding features of intercepting proxies.
Remediation
Keep comments meant for developers out of what is sent to the browser:
- Strip comments from scripts and stylesheets in the build process, for example through minification, and in templates use the template language's own comments, which the server does not send, such as
@* *@in Razor or{# #}in Jinja and Twig, in place of HTML comments. - Review the comments that remain, and remove any that describe internal systems, unfinished work or security controls.
- Remove commented-out code, particularly links or forms for functions that are not meant to be available, and make sure those functions are themselves removed or protected on the server.
- Do not publish source maps to production unless they are needed, or restrict who can fetch them.
- Change any credential or key found in a comment, since it should be treated as exposed.
Confirm the fix by reviewing the source of the affected pages and files again.
References
Add This Finding to Your Library
In Pental this write-up is in Settings, Library. Add to my library copies it into your own, rated in your firm's CVSS version, ready to put in your own words.
Free trialYour trial starts when your portal goes live, not when you sign up, so the time you spend setting up does not count. · No card required
Only need the reporting? Our reporting tool is free and open source, with the same library.