GitHub Advisoryadvisory · npm
GHSA-hvqh-jw65-wcpq devbridge-autocomplete has XSS in its default formatters: formatGroup and formatResult fail to escape HTML in untrusted inputs
MEDIUM
Official page ↗
- Ecosystem
- npm
- Packages
- devbridge-autocomplete
- Severity
- Moderate
- CVSS vector
- CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:L/I:L/A:N
- Weaknesses
- CWE-79
- Reviewed
- 2026-06-22
Affected packages
• npm devbridge-autocomplete: < 2.0.1 → fixed in 2.0.1
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 '' + category + '';
}
```
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
PoC: formatGroup XSS in jQuery-Autocomplete v2.0.0
var poisoned = [
{ value: 'Apple', data: { category: "" } },
{ value: 'Avocado', data: { category: 'Safe Group' } }
];
$('#ac').devbridgeAutocomplete({
lookup: poisoned,
groupBy: 'category',
minChars: 1
});
```
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`.
Related
Weakness · CWE (1)
- CWE-79 Improper Neutralization of Input During Web Page Generation weakness