Critical Magento 2 Security Alert: Password Hash Extraction Via Search Filters

Critical Magento 2 Security Vulnerability: Password Hash Extraction Via Search Filters

A significant security vulnerability has been identified in Magento Open Source and Adobe Commerce versions 2.4.x, specifically affecting 2.4.6-p11, 2.4.7-p8, and 2.4.8-p3. This flaw allows an attacker with an admin or integration token to extract customer password hashes from the system, posing a severe risk of account takeover and data breaches.

The Vulnerability Explained

The core of the issue lies within the customer search endpoint (/V1/customers/search). This API endpoint, accessible with a Magento_Customer::customer permission, accepts caller-supplied filter fields and applies them directly to the customer collection. Crucially, the password_hash attribute, a static EAV column, is not excluded from these filters.

An attacker can exploit this by sending a LIKE filter on the password_hash field. Although the hash itself is never returned in the JSON response items, the total_count field acts as a boolean oracle. If a guessed character prefix for the hash matches, total_count will be at least 1; if it doesn't, total_count will be 0. By repeating this query and iterating through characters, an attacker can reconstruct the full stored hash character by character. For instance, in a lab environment, the first 16 hex characters were recovered in just 131 oracle calls.

Root Cause and Technical Details

The vulnerability stems from how CustomerRepository::getList() processes search criteria. It adds every customer attribute to the select statement, and the FilterProcessor then maps request field names directly to collection conditions without any allowlist check. Since password_hash is registered as a static attribute, it's treated as a normal column predicate in the SQL WHERE clause. The relevant code snippets highlight this:

// lib/internal/Magento/Framework/Api/SearchCriteria/CollectionProcessor/FilterProcessor.php:65-92
foreach ($filterGroup->getFilters() as $filter) {
    $c>getConditionType() ?: 'eq';
    $fields[] = $this->getFieldMapping($filter->getField());
    $conditions[] = [$c> $filter->getValue()];
}
if ($fields) {
    $collection->addFieldToFilter($fields, $conditions);
}

// lib/internal/Magento/Framework/Data/Collection/AbstractDb.php:614-629
public function addFieldToFilter($field, $c
{
    $resultC>_translateCondition($field, $condition);
    $this->_select->where($resultCondition, null, Select::TYPE_CONDITION);
    return $this;
}

The fix, a RestrictedFieldsPlugin, exists in the 2.4-develop branch but is absent from the affected stable releases, leaving many live Magento stores exposed.

Impact and Attack Path

  • Confidentiality Breach: Every customer password hash can be reconstructed.
  • Account Takeover: Cracked passwords can be replayed against customer accounts, leading to access to PII, addresses, and order history.
  • Fraud and Regulatory Risk: Changes to orders, addresses, and account settings under victim identity, leading to potential fraud, privacy exposure, and regulatory notification requirements.

The attack path involves obtaining an admin or integration token with Magento_Customer::customer permissions, then iteratively querying the /rest/V1/customers/search endpoint with LIKE filters on password_hash, using total_count as an oracle to reconstruct the hash.

Detection and Remediation

Detection:

  • Alert on /rest/V1/customers/search requests filtering by password_hash, rp_token, or confirmation.
  • Identify many requests from a single token with incrementing LIKE prefixes.
  • Review admin/integration token inventory and rotation policies.
  • Monitor MySQL general logs or query telemetry for LIKE operations on e.password_hash.

Remediation:

  1. Backport the Fix: Implement the RestrictedFieldsPlugin and its DI registration from 2.4-develop to all affected stable branches (2.4.8-p3, 2.4.7-p8, etc.). This plugin explicitly rejects restricted filter and sort fields like password_hash.
  2. Strengthen Filtering: Consider replacing the blocklist approach with an allowlist of filterable customer fields for enhanced security.
  3. Add Regression Tests: Ensure REST, SOAP, and GraphQL search criteria are covered.
  4. Token Rotation and Audit: Immediately rotate all admin and integration tokens and audit recent customer search usage.
  5. WAF Rule: Optionally, add a Web Application Firewall (WAF) rule to block requests containing password_hash in search criteria as a defense-in-depth measure.

This vulnerability underscores the importance of staying updated with Magento security patches and regularly auditing your store's security posture, especially if you are running older versions or are in the process of a Magento migration.

Start with the tools

Explore migration tools

See options, compare methods, and pick the path that fits your store.

Explore migration tools