CVE-2021-3377 in ansi_upinfo

Summary

by MITRE • 03/06/2021

The npm package ansi_up converts ANSI escape codes into HTML. In ansi_up v4, ANSI escape codes can be used to create HTML hyperlinks. Due to insufficient URL sanitization, this feature is affected by a cross-site scripting (XSS) vulnerability. This issue is fixed in v5.0.0.

If you want to get best quality of vulnerability data, you may have to visit VulDB.

Analysis

by VulDB Data Team • 11/04/2025

The vulnerability identified as CVE-2021-3377 affects the npm package ansi_up which serves as a utility for converting ANSI escape codes into HTML format. This package is commonly used in terminal emulators, log viewers, and console output processors where rich text formatting is required. The specific issue arises from the package's handling of hyperlink creation functionality introduced in version 4, where ANSI escape codes can be leveraged to generate HTML hyperlinks within the converted output. The flaw exists in the URL sanitization mechanism that fails to properly validate and sanitize user-provided input before incorporating it into generated HTML content.

The technical exploitation of this vulnerability occurs through crafted ANSI escape sequences that contain malicious URLs within hyperlink definitions. When the ansi_up library processes such input, it fails to adequately sanitize the URL parameters, allowing attackers to inject malicious HTML or JavaScript code into the generated output. This creates a classic cross-site scripting vulnerability where the malicious payload executes in the context of the victim's browser when they view the rendered HTML content. The vulnerability is categorized as CWE-79 - Improper Neutralization of Input During Web Page Generation, which specifically addresses the failure to properly sanitize user input before including it in web content.

The operational impact of this vulnerability extends beyond simple XSS attacks as it can enable more sophisticated exploitation patterns including session hijacking, data exfiltration, and privilege escalation within the affected application context. Applications that use ansi_up to display terminal output from untrusted sources become vulnerable to these attacks, particularly in environments where users can submit console output or log files that may contain malicious ANSI sequences. The vulnerability affects web applications that process terminal output from various sources including automated testing environments, system monitoring tools, and user-generated console sessions where the input validation is insufficient.

Mitigation strategies for CVE-2021-3377 require immediate patching of the ansi_up library to version 5.0.0 or later where the URL sanitization has been properly implemented. Organizations should conduct comprehensive vulnerability assessments to identify all applications that utilize the affected package and ensure proper input validation is implemented at multiple layers. The remediation approach should include implementing proper HTML escaping for all user-provided content, validating URL formats against known safe patterns, and employing content security policies to prevent execution of unauthorized scripts. Additionally, security teams should consider implementing runtime monitoring for suspicious HTML injection patterns and establish secure coding practices that prevent similar issues in custom implementations that may replicate the vulnerable functionality. The ATT&CK framework categorizes this vulnerability under T1203 - Exploitation for Client Execution, highlighting the need for robust input validation and output encoding mechanisms to prevent exploitation.

Reservation

02/01/2021

Disclosure

03/06/2021

Moderation

accepted

CPE

ready

EPSS

0.08000

KEV

no

Activities

very low

Sources

Do you know our Splunk app?

Download it now for free!