CVE-2023-42446: Pow Pow Mnesia Cache Doesn't Invalidate Vulnerability

MODERATE
Advisory Identifier: GHSA-3cjh-p6pw-jhv9
CVSS 6.5
CWE-672 CWE-298
Published
Advisory Summary

CVE-2023-42446 is a MODERATE (CVSS 6.5) pow mnesia cache doesn't invalidate vulnerability (CWE-672: Operation on a Resource after Expiration or Release) affecting Pow libraries in the Hex ecosystem. The issue involves pow mnesia cache doesn't invalidate all expired keys on startup. Remediation is available by upgrading affected packages to version 1.0.34.

CVE-2023-42446 at a Glance

CVE Identifier CVE-2023-42446
GHSA Identifier GHSA-3cjh-p6pw-jhv9
Severity MODERATE
CVSS v3.1 Base Score 6.5
CWE Classification CWE-672: Operation on a Resource after Expiration or Release
Affected Product Pow
Package Ecosystem Hex
Published Date
Last Updated

Security Impact

CVSS: 6.5

The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:N/I:H/A:N).

Attack Vector Network (AV:N)
Attack Complexity Low (AC:L)
Privileges Required Low (PR:L)
User Interaction None (UI:N)
Scope Unchanged (S:U)
Confidentiality None (C:N)
Integrity High (I:H)
Availability None (A:N)

How to Fix CVE-2023-42446

To remediate this vulnerability, upgrade all affected Pow dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

pow fixed: 1.0.34
Upgrade pow to 1.0.34
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

inspect dependencies for pow

How to Check if You Are Affected

To determine whether your application is affected by CVE-2023-42446, inspect your project dependencies for Pow:

inspect dependencies for pow

Analyze the terminal output to locate any version of Pow in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 1.0.34), your application is affected.

Note: Verify declared build manifests and deployed runtime container environments.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-672: Operation on a Resource after Expiration or Release, where the product uses, accesses, or otherwise operates on a resource after that resource has been expired, released, or revoked. In Pow, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

Use of `Pow.Store.Backend.MnesiaCache` is susceptible to session hijacking as expired keys are not being invalidated correctly on startup. A cache key may become expired when all `Pow.Store.Backend.MnesiaCache` instances have been shut down for a period that is longer than the keys' remaining TTL and the expired key won't be invalidated on startups. ### Workarounds The expired keys, including all expired sessions, can be manually invalidated by running: ```elixir :mnesia.sync_transaction(fn -> Enum.each(:mnesia.dirty_select(Pow.Store.Backend.MnesiaCache, [{{Pow.Store.Backend.MnesiaCache, :_, :_}, [], [:"$_"]}]), fn {_, key, {_value, expire}} -> ttl = expire - :os.system_time(:millisecond) if ttl < 0, do: :mnesia.delete({Pow.Store.Backend.MnesiaCache, key}) end) end) ``` ### References https://github.com/pow-auth/pow/commit/15dc525be03c466daa5d2119ca7acdec7b24ed17 https://github.com/pow-auth/pow/issues/713 https://github.com/pow-auth/pow/pull/714

CVE-2023-42446 Affected Pow Versions

1 component(s)
Fixed Versions:
1.0.34
Product / Package Ecosystem Affected Versions Fixed Version
pow
Hex
≥ 1.0.14
< 1.0.34
1.0.34

References

Frequently Asked Questions

What is CVE-2023-42446?
CVE-2023-42446 is a security vulnerability in Pow involving Pow Mnesia cache doesn't invalidate all expired keys on startup under CWE-672: Operation on a Resource after Expiration or Release.
Which Pow versions are affected?
Affected versions include releases prior to 1.0.34 across affected packages: pow.
What version fixes CVE-2023-42446?
Upgrading to 1.0.34 (or the latest patched release for your respective branch) resolves the vulnerability.
Is pow affected?
Yes, pow is affected in releases prior to 1.0.34. Upgrade your dependency to 1.0.34 or later.
What is the CVSS score of CVE-2023-42446?
CVE-2023-42446 has a CVSS v3.1 base score of 6.5 (MODERATE) with vector string CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:N/I:H/A:N.
What CWE is associated with CVE-2023-42446?
CVE-2023-42446 is classified under CWE-672: Operation on a Resource after Expiration or Release (The product uses, accesses, or otherwise operates on a resource after that resource has been expired, released, or revoked.).
How can I check Hex dependencies for CVE-2023-42446?
Run the dependency tree command: 'inspect dependencies for pow'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-3cjh-p6pw-jhv9",
  "modified" : "2023-09-19T17:00:08Z",
  "published" : "2023-09-19T17:00:08Z",
  "aliases" : [ "CVE-2023-42446" ],
  "summary" : "Pow Mnesia cache doesn't invalidate all expired keys on startup",
  "details" : "Use of `Pow.Store.Backend.MnesiaCache` is susceptible to session hijacking as expired keys are not being invalidated correctly on startup. A cache key may become expired when all `Pow.Store.Backend.MnesiaCache` instances have been shut down for a period that is longer than the keys' remaining TTL and the expired key won't be invalidated on startups.\n\n### Workarounds\n\nThe expired keys, including all expired sessions, can be manually invalidated by running:\n\n```elixir\n:mnesia.sync_transaction(fn ->\n  Enum.each(:mnesia.dirty_select(Pow.Store.Backend.MnesiaCache, [{{Pow.Store.Backend.MnesiaCache, :_, :_}, [], [:\"$_\"]}]), fn {_, key,  {_value, expire}} ->\n    ttl = expire - :os.system_time(:millisecond)\n    if ttl < 0, do: :mnesia.delete({Pow.Store.Backend.MnesiaCache, key})\n  end)\nend)\n```\n\n### References\nhttps://github.com/pow-auth/pow/commit/15dc525be03c466daa5d2119ca7acdec7b24ed17\nhttps://github.com/pow-auth/pow/issues/713\nhttps://github.com/pow-auth/pow/pull/714\n",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:N/I:H/A:N"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "Hex",
      "name" : "pow"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "1.0.14"
      }, {
        "fixed" : "1.0.34"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/pow-auth/pow/security/advisories/GHSA-3cjh-p6pw-jhv9"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2023-42446"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/pow-auth/pow/issues/713"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/pow-auth/pow/pull/714"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/pow-auth/pow/commit/15dc525be03c466daa5d2119ca7acdec7b24ed17"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/pow-auth/pow"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-298", "CWE-672" ],
    "severity" : "MODERATE",
    "github_reviewed" : true,
    "github_reviewed_at" : "2023-09-19T17:00:08Z",
    "nvd_published_at" : "2023-09-18T22:15:47Z"
  }
}