Inclusion of Sensitive Information in Source Code Comments

Incomplete Variant
Structure: Simple
Description

While adding general comments is very useful, some programmers tend to leave important data, such as: filenames related to the web application, old links or links which were not meant to be browsed by users, old code fragments, etc.

Extended Description

An attacker who finds these comments can map the application's structure and files, expose hidden parts of the site, and study the fragments of code to reverse engineer the application, which may help develop further attacks against the site.

Common Consequences 1
Scope: Confidentiality

Impact: Read Application Data

Detection Methods 1
Automated Static AnalysisHigh
Automated static analysis, commonly referred to as Static Application Security Testing (SAST), can find some instances of this weakness by analyzing source code (or binary/compiled code) without having to execute it. Typically, this is done by building a model of data flow and control flow, then searching for potentially-vulnerable patterns that connect "sources" (origins of input) with "sinks" (destinations where the data interacts with external components, a lower layer such as the OS, etc.)
Potential Mitigations 1
Phase: Distribution
Remove comments which have sensitive information about the design/implementation of the application. Some of the comments may be exposed to the user and affect the security posture of the application.
Demonstrative Examples 1
The following comment, embedded in a JSP, will be displayed in the resulting HTML output.

Code Example:

Bad
JSP
jsp
Observed Examples 3
CVE-2007-6197Version numbers and internal hostnames leaked in HTML comments.
CVE-2007-4072CMS places full pathname of server in HTML comment.
CVE-2009-2431blog software leaks real username in HTML comment.
Modes of Introduction
Implementation