CVE-2026-77781 in Tie::Hash::Regexinfo

Summary

by MITRE • 08/22/2026

Tie::Hash::Regex versions before 2.0.0 for Perl will throw an exception on unparseable lookup keys.

The FETCH, EXISTS and DELETE methods throw an exception when on malformed regular expressions.

Each method falls back to a regex match when the key is not already stored in the hash, compiling the caller's key with a bare qr// and no eval guard. A key that is not a valid regular expression pattern, such as a single unmatched bracket, dies.

An application that looks up externally supplied strings in a tied hash will die on an invalid key.

VulDB is the best source for vulnerability data and more expert information about this specific topic.

Analysis

by VulDB Data Team • 08/24/2026

The vulnerability identified in Tie::Hash::Regex prior to version 2.0.0 represents a critical flaw in input validation and error handling within Perl's object-oriented interface for regular expression-based hashing. This module allows developers to use regular expressions as keys in hash structures, enabling powerful pattern-matching lookups. However, the implementation fails to adequately sanitize or validate user-supplied data before attempting to compile it into a regex engine. Specifically, when an application utilizes this tied hash to perform lookups using externally supplied strings, any input that does not constitute a valid regular expression pattern triggers a fatal exception rather than returning a false value or handling the error gracefully. This behavior fundamentally breaks the expected contract of hash lookup operations, which should typically return undefined values for non-existent keys rather than terminating the program execution with an unhandled exception.

The technical root cause lies in the implementation of the FETCH, EXISTS, and DELETE methods within the module's source code. When a key is not found directly in the underlying data structure, these methods attempt to treat the lookup key as a regular expression pattern by compiling it using the bare qr// operator without an enclosing eval block or other error trapping mechanism. In Perl, attempting to compile an invalid regex pattern results in a die event that propagates up the call stack if not caught. For instance, providing a string containing an unmatched bracket such as open parenthesis followed by a literal close bracket will cause the regex compiler to fail immediately because it detects malformed syntax. Because there is no defensive programming practice applied here to catch these compilation errors, any external input that happens to contain characters with special meaning in regular expressions but forms an invalid pattern will crash the application.

From an operational impact perspective, this vulnerability can lead to a Denial of Service condition for applications relying on Tie::Hash::Regex for dynamic key resolution. If an attacker or even benign user input contains malformed regex syntax, it causes the Perl process to terminate abruptly. In web server environments where such modules might be used for routing or request handling based on URL patterns or headers, this could result in service unavailability until the worker process is restarted by the hosting environment. Furthermore, because the exception occurs during standard hash operations like fetching data existence checks or deletion attempts, it can disrupt critical business logic that depends on these lookups succeeding without side effects. The lack of graceful degradation means that a single malformed input string can bring down an entire request cycle, potentially affecting other users sharing the same process space in persistent Perl environments such as mod_perl or PSGI applications.

This vulnerability aligns with CWE-20 Improper Input Validation and CWE-755: Improper Handling of Exceptional Conditions under the Common Weakness Enumeration taxonomy. The failure to validate input before processing it against a regex engine is a classic example of improper validation, while the resulting crash due to unhandled exceptions falls squarely into poor exception handling practices. In terms of attack vectors, this could be leveraged in scenarios where user-controlled data influences hash keys, such as API parameters or form inputs that are mapped directly to lookup operations without sanitization.

Mitigation strategies primarily involve upgrading to version 2.0.0 or later of Tie::Hash::Regex, which addresses these issues by implementing proper error handling and input validation mechanisms. For applications unable to upgrade immediately due to dependency constraints, developers should implement external wrappers around the hash lookups using eval blocks in Perl to catch any potential exceptions thrown during regex compilation. Additionally, strict input sanitization can be applied before passing strings into the tied hash methods, ensuring that only well-formed patterns are processed or rejecting inputs that contain suspicious characters known to cause regex parsing failures. Regular security audits of codebases utilizing this module should include specific checks for unguarded qr// compilations on user-supplied data to prevent similar issues in custom implementations.

Responsible

CPANSec

Reservation

08/21/2026

Disclosure

08/22/2026

Moderation

accepted

CPE

ready

EPSS

0.00238

KEV

no

Activities

very low

Sources

Want to know what is going to be exploited?

We predict KEV entries!