Sploitus

Exploit for CVE-2026-76564

githubexploit Β· 2026-08-21

Exploit Code

README178 lines
## https://sploitus.com/exploit?id=B44477A4-3D6C-5E09-AA00-D0C0AE67D2FE
# Stored XSS via User-Agent in Admin Order View in PhocaCart

**PhocaCart ≀ 6.1.7 β€” Unauthenticated Attacker Stores XSS Payload via Checkout. Executes in Admin Browser Context**

![CVE](https://img.shields.io/badge/CVE-CVE--2026--76564-green)
![CVSS v4.0](https://img.shields.io/badge/CVSS_v4.0-8.6-red)
![CWE-79](https://img.shields.io/badge/CWE--79-Cross--site_Scripting-orange)
![Affected](https://img.shields.io/badge/Affected-5.0.0_–_6.1.7-red)
![Researcher](https://img.shields.io/badge/Researcher-Toan_Le-blue)

---

## SUMMARY

PhocaCart 6.1.7 for Joomla stores the raw HTTP `User-Agent` header from checkout requests in the orders database table when the `store_user_agent` configuration option is enabled. The stored value is subsequently rendered without HTML encoding into the administrator order edit view via `itemText()` in `Adminview.php`.

An unauthenticated attacker can place an order with a crafted `User-Agent` containing a JavaScript payload. When an administrator opens the order in the backend, the payload executes in the admin browser context β€” enabling session hijacking, credential theft, or unauthorized administrative actions.

The vulnerability requires `store_user_agent = 1` (non-default) to be enabled. Because this option is a deliberate administrator choice to collect browser statistics, affected shops are those where the shop owner has enabled the feature β€” making exploitation fully silent from the attacker's perspective.

---

## AFFECTED VERSIONS

| COMPONENT                 | VULNERABLE     | TESTED ON                                     | FIXED |
| ------------------------- | -------------- | --------------------------------------------- | ----- |
| PhocaCart (com_phocacart) | 5.0.0 – 6.1.7 | Joomla 5.4.7 + PhocaCart 6.1.7 + MariaDB 10.6 | 6.1.8 |

---

## VULNERABILITY DETAILS

**Type:** Stored XSS (CWE-79) β€” admin-targeted
**Authentication required:** None to inject. Administrator to trigger
**CSRF token required:** Yes (standard Joomla CSRF token required for checkout)
**File:** `administrator/components/com_phocacart/libraries/Phoca/Render/Adminview.php:382`

### Root Cause

When `store_user_agent = 1`, the method `PhocacartUtils::getUserAgent()` returns `$_SERVER['HTTP_USER_AGENT']` without any sanitization. This raw string is stored in `#__phocacart_orders` (truncated at 200 characters β€” insufficient to prevent XSS). When an administrator views the order in the backend, `itemText()` concatenates the stored value directly into the HTML response with no call to `htmlspecialchars()`.

Data flow:

```
Attacker sends checkout request:
  User-Agent: alert(document.domain)

    utils.php:334   PhocacartUtils::getUserAgent()
    └─ return (string) $_SERVER['HTTP_USER_AGENT']   // raw, no sanitization
        order.php:413  $d['user_agent'] = substr($user_agent, 0, 200)
        └─ INSERT INTO #__phocacart_orders (user_agent) VALUES ('...')

Admin opens order in backend:
    edit.php:84    echo $r->itemText($this->itemcommon->user_agent, ...)
    Adminview.php:382  '' . $item . ''
                                           // β†’ NO htmlspecialchars()
    β†’ Browser renders: alert(document.domain)
    β†’ XSS fires in administrator's browser
```

**ORDER.PHP β€” STORE PHASE (VULNERABLE SOURCE)**

`administrator/components/com_phocacart/libraries/phocacart/order/order.php:424`

```php
$user_agent = PhocacartUtils::getUserAgent(); // reads $_SERVER['HTTP_USER_AGENT'] raw
$d['user_agent'] = substr($user_agent, 0, 200); // stored in DB unfiltered
```

**ADMINVIEW.PHP:382 β€” RENDER PHASE (VULNERABLE SINK)**

```php
// No htmlspecialchars() applied:
$output .= '  ' . $item . '' . "\n";
```

Called from `administrator/components/com_phocacart/views/phocacartorder/tmpl/edit.php:84`:

```php
echo $r->itemText($this->itemcommon->user_agent, Text::_('COM_PHOCACART_USER_AGENT'), '', 'user_agent');
```

The `itemText()` function passes `$item` (the stored `user_agent` value) directly into the HTML output with no encoding, making it the primary sink. Fixing it at the sink level protects all callers of `itemText()`.

---

## PROOF OF CONCEPT

The attack requires completing a full checkout flow with a malicious `User-Agent` header. The CSRF token must be obtained first since Joomla's checkout controller validates it.

#### 0. Prerequisite β€” Enable Store User Agent Information

In Joomla admin, navigate to **Components β†’ Phoca Cart β†’ Options β†’ Main tab β†’ Statistics Options**. Set **Store User Agent Information = Yes** and save.

![Prerequisite: Store User Agent Information = Yes](images/s0-prerequisite-enable-store-user-agent.png)

#### 1. Obtain CSRF Token

The attacker visits the shop frontend to extract a valid Joomla CSRF token required by the checkout controller. The token appears in the HTML source or JavaScript config of any shop page.

![Step 1: Attacker obtains CSRF token from shop frontend via Burp Suite](images/s1-step1-obtain-csrf-token.png)

#### 2. Add Product to Cart

The attacker adds a product to cart via the AJAX checkout endpoint using a benign `User-Agent`. This transitions the checkout session to the next state.

![Step 2: Add product to cart β€” POST checkout.add](images/s1-step2-add-product-to-cart.png)

#### 3. Save Billing Address

The attacker submits billing information to advance the checkout state machine.

![Step 3: Save billing address β€” Burp Suite](images/s1-step3-save-billing-address.png)

#### 4. Save Shipping Method

The attacker selects a shipping method to proceed to payment.

![Step 4: Save shipping method β€” Burp Suite](images/s1-step4-save-shipping-method.png)

#### 5. Save Payment Method

The attacker selects a payment method (e.g., Cash on Delivery).

![Step 5: Save payment method β€” Burp Suite](images/s1-step5-save-payment-method.png)

#### 6. Inject Payload β€” Place Order with Malicious User-Agent

Critical injection step. The attacker places the final order via `task=checkout.order` with the `User-Agent` header set to the XSS payload. The `checkout.order` task reads raw `HTTP_USER_AGENT` and stores it unescaped in `#__phocacart_orders.user_agent`.

```
POST /index.php/shop/checkout HTTP/1.1
Host: TARGET
User-Agent: alert(document.domain)
Content-Type: application/x-www-form-urlencoded

phcheckouttac=1&task=checkout.order&option=com_phocacart&return=&=1
```

Result: Order created. Database stores `user_agent = 'alert(document.domain)'`.

![Step 6: Order placement with malicious User-Agent β€” payload injected into database](images/s1-step6-inject-payload-checkout-order.png)

#### 7. Admin Views Order List

Administrator navigates to **Components β†’ Phoca Cart β†’ Orders**. The injected order appears in the list. XSS is not yet triggered at this stage.

![Step 7: Admin order list in Joomla backend β€” injected order visible](images/s1-step7-admin-views-order-list.png)

#### 8. XSS Fires β€” Admin Opens Order Detail

When the administrator clicks the order to open the edit view, the stored `user_agent` is rendered unescaped via `itemText()`. JavaScript executes immediately.

Trigger URL:

```
/administrator/index.php?option=com_phocacart&view=phocacartorder&layout=edit&id=
```

![Step 8: XSS payload executes in administrator's browser β€” alert(document.domain) confirms execution context](images/s1-step8-xss-fires-admin-opens-order-detail.png)

---

## IMPACT

1. **Admin Session Hijacking** β€” The XSS payload can exfiltrate the administrator's session cookie, granting full backend access without credentials.
2. **Unauthorized Admin Actions** β€” Executing in the admin browser context, the payload can perform any backend action: create privileged accounts, install malicious extensions, or modify content.
3. **Persistent Backdoor** β€” A payload that installs a web shell or creates a rogue admin account persists beyond the XSS event itself, giving the attacker durable access to the server.

---

## REFERENCES

- **CVE:** https://vulners.com/cve/CVE-2026-76564
- **NVD:** https://nvd.nist.gov/vuln/detail/CVE-2026-76564
- **GitHub Advisory:** https://github.com/advisories/GHSA-98mw-pj3j-99v2
- **Vendor Repository:** https://github.com/PhocaDesign/PhocaCart