/

CVE-2026-120644

Severity:

CRITICAL RISK

(9.1)

Cookie Attribute Injection (CWE-116) in Perl CGI::Cookie

CVE-2026-120644

Deferred

Vulnerability type

Category:

Cookie Attribute Injection

CWE:

CWE-116

Impact:

Cookie Policy Manipulation

Severity:

CRITICAL RISK

(9.1)

CVSS version:

3.1

Catch this CVE while code is being written

Detect vulnerable code directly in pull requests, so CVEs are fixed before merge.

Summary

CGI::Cookie versions before 5.00 can place unvalidated path, domain, and expires values directly into a Set-Cookie header. If an application builds these values from request data, an attacker may be able to inject additional cookie attributes, potentially changing how the browser handles the cookie.

Affected context

The issue occurs when an application uses affected CGI::Cookie versions to create cookies and supplies path, domain, or expires values that are influenced by request data. Those values are written into the Set-Cookie header without checking for semicolons or control characters, which may allow additional cookie attributes to be introduced.

Exploit preconditions

  • Attack surface: An application endpoint that creates or updates cookies
  • Required access: Ability to influence request data used for cookie attributes
  • Trigger point: The application emits a Set-Cookie header using the affected library
  • Why exploitation is possible: Attribute values are inserted into the header without adequate validation or neutralization

Why this happens

The library writes path, domain, and expires values into a Set-Cookie header without preventing characters that can delimit or alter cookie attributes. This is an output-neutralization failure mapped to CWE-116: Improper Encoding or Escaping of Output. When values are derived from untrusted input, the header may be interpreted differently than the application intended.

Potential impact

  • An attacker may be able to add or alter cookie attributes, such as Domain or SameSite.
  • Cookie scope or browser handling may differ from the application's intended policy.
  • Depending on application behavior, altered cookie handling could contribute to session-related security risks.

General mitigation guidance

Defensive approaches focus on preventing untrusted data from changing the structure of response headers.

  • Use cookie APIs and serialization behavior that safely handle attribute values.
  • Validate attribute values against narrowly defined formats and reject delimiters or control characters where they are not valid.
  • Prefer fixed, application-controlled cookie attributes over values derived from request data.
  • Apply least privilege to the data and code paths that can set cookies, and use secure-by-default cookie policies where appropriate.

How teams detect issues like this

Review cookie creation paths for request-derived values passed into path, domain, or expires attributes. Static analysis can flag unsanitized data flowing into Set-Cookie header construction, while code review can check whether validation occurs before serialization. Policy checks may require approved cookie-setting APIs and reject control characters or unexpected delimiters in attribute values.

Sources

SourceLink
github.comgithub.com/leejo/CGI.pm/commit/0b3527faaa9de55f79ca7d59dd3bcfb2c5540e00.patch
metacpan.orgmetacpan.org/release/LEEJO/CGI-4.72/source/lib/CGI/Cookie.pm
metacpan.orgmetacpan.org/release/LEEJO/CGI-5.00/changes

Frequently asked

questions

It affects applications that use affected CGI::Cookie versions and allow untrusted data to influence cookie attribute values.

Not necessarily. The relevant condition is the ability to influence request data that the application uses when setting a cookie.

Ensure cookie attributes are safely serialized, and use validated, application-controlled values rather than passing request data directly into them.

Use secure cookie-setting APIs, validate values against strict formats, and review data flows from request input to response headers.

Find out what's already
exploitable in your codebase.