appbaseio / appbaseio/reactivesearch

bug: image src attributes not validated for javascript: protocol URLs

Offen
#2,320 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
Vorherrschende Sprache
JavaScript
Sterne
4.9k
Forks
478
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

## Problem

Image `src` attributes in SearchBox, SelectedFilters, and AIAnswer Chat pass URLs through `xss()`, which only strips HTML tags but does NOT validate against `javascript:` protocol URLs. This means an attacker-provided image URL like `javascript:alert('XSS')` would bypass the sanitizer.

```js
// packages/web/src/components/search/SearchBox.js:1159
search-icon
// packages/web/src/components/basic/SelectedFilters.js:144
thumbnail
```

The `xss` library strips HTML/JS from strings, but `` doesn't need HTML injection — the URL itself is the attack vector.

## Locations

- `packages/web/src/components/search/SearchBox.js` (L1159, L1774)
- `packages/web/src/components/basic/SelectedFilters.js` (L144)
- `packages/web/src/components/search/AIAnswer/Chat.js` (L79)

## Suggested Fix

Wrap URL assignment with a protocol check:

```js
function sanitizeImageUrl(url) {
if (!url) return null;
try {
const parsed = new URL(url);
if (parsed.protocol === 'http:' || parsed.protocol === 'https:') return url;
} catch (e) { /* invalid URL */ }
return null;
}
```

## Severity

High — XSS via image URL injection

Beitragsleitfaden

Beitragsleitfaden öffnen

Rechercherichtung

Inspect the image URL handling in packages/web/src/components/search/SearchBox.js, packages/web/src/components/basic/SelectedFilters.js, and packages/web/src/components/search/AIAnswer/Chat.js, starting with the listed lines and existing xss() usage. Confirm the affected image src values reject javascript: and other non-http(s) URLs while preserving valid URLs, and add or update coverage if the surrounding files provide tests.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
javascript, react
Bereich
frontend, security
Issue-Typ
Bug
Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Aktivitätsstatus
Ruhig
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
55/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.