Vulnerabilities in pkg:gem/devise_masquerade

PACKAGE
Advisory Identifier: GHSA-25f5-gc4h-hc22
Advisory Summary

CVE-2021-28680 is a HIGH (CVSS 8.1) improper privilege management vulnerability (CWE-269: Improper Privilege Management) affecting Devise masquerade libraries in the RubyGems ecosystem. The issue involves improper privilege management in devise_masquerade. Remediation is available by upgrading affected packages to version 1.3.1.

1 Known Advisory Record(s)
Package Vulnerability Intelligence

pkg:gem/devise_masquerade

1 Known Advisory Record(s)

Vulnerability advisories affecting package pkg:gem/devise_masquerade. Select an advisory below to view technical details or fixes.

Advisory ID CVE / NVD Severity Summary
GHSA-25f5-gc4h-hc22 CVE-2021-28680 HIGH Improper Privilege Management in devise_masquerade

CVE-2021-28680 at a Glance

CVE Identifier CVE-2021-28680
GHSA Identifier GHSA-25f5-gc4h-hc22
Severity HIGH
CVSS v3.1 Base Score 8.1
CWE Classification CWE-269: Improper Privilege Management
Affected Product Devise masquerade
Package Ecosystem RubyGems
Published Date
Last Updated

Security Impact

CVSS: 8.1

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

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

How to Fix CVE-2021-28680

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

devise_masquerade fixed: 1.3.1
Upgrade devise_masquerade to 1.3.1
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 devise_masquerade

How to Check if You Are Affected

To determine whether your application is affected by CVE-2021-28680, inspect your project dependencies for Devise masquerade:

inspect dependencies for devise_masquerade

Analyze the terminal output to locate any version of Devise masquerade in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 1.3.1), 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-269: Improper Privilege Management, where the product does not properly assign, modify, track, or check privileges for an actor, creating an unintended sphere of control for that actor. In Devise masquerade, 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

The devise_masquerade gem before 1.3 allows certain attacks when a password's salt is unknown. An application that uses this gem to let administrators masquerade/impersonate users loses one layer of security protection compared to a situation where Devise (without this extension) is used. If the server-side `secret_key_base` value became publicly known (for instance if it is committed to a public repository by mistake), there are still other protections in place that prevent an attacker from impersonating any user on the site. When masquerading is not used in a plain Devise application, one must know the password salt of the target user if one wants to encrypt and sign a valid session cookie. When `devise_masquerade` is used, however, an attacker can decide which user the "back" action will go back to without knowing that user's password salt and simply knowing the user ID, by manipulating the session cookie and pretending that a user is already masqueraded by an administrator.

CVE-2021-28680 Affected Devise masquerade Versions

1 component(s)
Fixed Versions:
1.3.1
Product / Package Ecosystem Affected Versions Fixed Version
devise_masquerade
RubyGems
< 1.3.1
1.3.1

References

Frequently Asked Questions

What is CVE-2021-28680?
CVE-2021-28680 is a security vulnerability in Devise masquerade involving Improper Privilege Management in devise_masquerade under CWE-269: Improper Privilege Management.
Which Devise masquerade versions are affected?
Affected versions include releases prior to 1.3.1 across affected packages: devise_masquerade.
What version fixes CVE-2021-28680?
Upgrading to 1.3.1 (or the latest patched release for your respective branch) resolves the vulnerability.
Is devise_masquerade affected?
Yes, devise_masquerade is affected in releases prior to 1.3.1. Upgrade your dependency to 1.3.1 or later.
What is the CVSS score of CVE-2021-28680?
CVE-2021-28680 has a CVSS v3.1 base score of 8.1 (HIGH) with vector string CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:H/A:H.
What CWE is associated with CVE-2021-28680?
CVE-2021-28680 is classified under CWE-269: Improper Privilege Management (The product does not properly assign, modify, track, or check privileges for an actor, creating an unintended sphere of control for that actor.).
How can I check RubyGems dependencies for CVE-2021-28680?
Run the dependency tree command: 'inspect dependencies for devise_masquerade'. 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-25f5-gc4h-hc22",
  "modified" : "2023-09-05T21:51:12Z",
  "published" : "2021-12-08T19:55:30Z",
  "aliases" : [ "CVE-2021-28680" ],
  "summary" : "Improper Privilege Management in devise_masquerade",
  "details" : "The devise_masquerade gem before 1.3 allows certain attacks when a password's salt is unknown. An application that uses this gem to let administrators masquerade/impersonate users loses one layer of security protection compared to a situation where Devise (without this extension) is used. If the server-side `secret_key_base` value became publicly known (for instance if it is committed to a public repository by mistake), there are still other protections in place that prevent an attacker from impersonating any user on the site. When masquerading is not used in a plain Devise application, one must know the password salt of the target user if one wants to encrypt and sign a valid session cookie. When `devise_masquerade` is used, however, an attacker can decide which user the \"back\" action will go back to without knowing that user's password salt and simply knowing the user ID, by manipulating the session cookie and pretending that a user is already masqueraded by an administrator.",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:H/A:H"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "RubyGems",
      "name" : "devise_masquerade"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "1.3.1"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2021-28680"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/oivoodoo/devise_masquerade/issues/83"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/oivoodoo/devise_masquerade/pull/76"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/oivoodoo/devise_masquerade"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/oivoodoo/devise_masquerade/releases/tag/v1.3.1"
  }, {
    "type" : "WEB",
    "url" : "https://labanskoller.se/blog/2021/03/23/the-devise-extension-that-peeled-off-one-layer-of-the-security-onion-cve-2021-28680"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-269" ],
    "severity" : "HIGH",
    "github_reviewed" : true,
    "github_reviewed_at" : "2021-12-08T19:36:08Z",
    "nvd_published_at" : "2021-12-07T21:15:00Z"
  }
}