Summary
IO::Compress before 2.220 allows attacker-controlled output glob strings to be evaluated as Perl code inside File::GlobMapper.
By injecting a double quote into the output glob, an attacker can break out of the intended string context and execute arbitrary Perl code with the privileges of the calling process.
Affected context
This vulnerability appears when applications use IO::Compress with File::GlobMapper and pass output glob patterns that are derived from untrusted or partially untrusted input.
The issue is specific to code paths where _parseOutputGlob() processes a user-controlled glob, stores it in parser state, and _getFiles() later evaluates that state with eval STRING.
Systems that strictly generate output globs from hard-coded or validated-safe patterns are less likely to be exposed, but any dynamic construction that incorporates external data may introduce risk.
Exploit preconditions
- Attack surface: Any Perl application using IO::Compress:: File::GlobMapper with dynamic output glob patterns
- Required access: Ability to influence or control the value passed as the output glob (e.g., via CLI arguments, configuration files, environment variables, or web parameters)
- Trigger point: Execution of code paths that call
_parseOutputGlob()on the attacker-controlled glob and subsequently invoke_getFiles() - Why exploitation is possible: The implementation wraps the caller-supplied glob in double quotes, stores it, and later feeds it into
eval STRING. An embedded double quote breaks the wrapper and lets the attacker inject arbitrary Perl code, whichevalexecutes as part of the expression.
Why this happens
The core issue is the use of eval STRING on data derived from external input, a classic instance of CWE-95: Improper Neutralization of Directives in Dynamically Evaluated Code ('Eval Injection').
_parseOutputGlob() attempts to treat the glob as a string expression by wrapping it in double quotes, but it does not neutralize or restrict embedded quotes or Perl metacharacters.
When _getFiles() later passes this wrapped expression to eval STRING, any injected double quote closes the string literal and allows arbitrary Perl code to follow.
This pattern conflates data (glob patterns) with code, violating the principle of separating untrusted input from dynamic evaluation mechanisms.
Potential impact
- Arbitrary Perl code execution in the context of the vulnerable process
- Reading or modifying sensitive files accessible to the application
- Exfiltration or tampering with application data and configuration
- Pivoting to other components or systems reachable from the compromised process
- Denial of service by terminating the process or exhausting resources
General mitigation guidance
Effective mitigation focuses on removing the dependency on eval STRING for handling glob expressions and strictly treating glob patterns as data.
Recommended secure patterns include:
- Avoiding dynamic evaluation entirely: use dedicated globbing and path-handling APIs rather than constructing Perl expressions.
- Treating glob patterns as opaque data: do not interpolate them into code or expression strings; pass them to functions that interpret glob syntax without executing Perl.
- Constraining inputs: if dynamic globs are necessary, validate them against a strict whitelist of allowed characters (e.g., alphanumerics, limited wildcard characters) and reject or escape quotes and Perl metacharacters.
- Applying least privilege: run Perl applications with minimal filesystem and OS permissions so that, even if a glob behaves unexpectedly, the process has limited access.
- Isolating risky parsing: where dynamic behavior is unavoidable, consider isolating it in a separate, locked-down process or environment to reduce blast radius.
How teams detect issues like this
Detection efforts can focus on identifying unsafe dynamic evaluation patterns and risky use of globbing utilities:
- Static analysis: Search for
evalusages that operate on strings built from variables or external input, especially in IO::Compress and File::GlobMapper call sites. - Code review cues: Flag any code that:
- Constructs Perl expressions by concatenating user input into strings.
- Wraps user-controlled values in quotes and later passes them to
eval. - Treats glob patterns as code rather than data.
- Policy enforcement: Adopt coding standards that discourage or forbid
eval STRINGunless rigorously justified and reviewed. Integrate these standards into CI using linters or custom rules. - Runtime monitoring: Where feasible, log and monitor suspicious output glob patterns or unexpected errors arising from eval, which may indicate attempted injection.

