This vulnerability occurs when an application accepts user input and fails to properly sanitize characters that can be interpreted as comment markers (like /*, */, //, #, or <!--) before passing that data to another system component. This allows an attacker to inject malicious comments that can break data processing, alter logic, or expose sensitive information.
Think of comment delimiters as hidden instructions that tell a parser or interpreter to ignore everything that follows on a line or within a block. When an application doesn't filter these characters from untrusted input, an attacker can inject them to "comment out" critical parts of a command, query, or configuration file. This manipulation can disrupt data flows, bypass security checks, or corrupt files in downstream systems like databases, log processors, or configuration parsers. The core issue is a failure in input validation and output encoding specific to the context of the receiving component. For example, injecting `/*` into a SQL query might break its structure, while injecting `<!--` into an XML document could hide malicious payloads from an XML parser. To prevent this, developers must always treat user input as untrusted and sanitize or encode it according to the specific syntax rules of the target interpreter before any processing occurs.
Impact: Unexpected State
Strategy: Input Validation
Strategy: Output Encoding
Strategy: Input Validation