appbaseio / appbaseio/reactivesearch

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

Abierto
#2,320 0 comentarios 0 reacciones 0 asignados Ver en GitHub
Lenguaje dominante
JavaScript
Estrellas
4.9k
Forks
478
Métricas de merge de PR
Sin PR fusionados en 30 d

Descripción

## 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

Guía de contribución

Abrir la guía de contribución

Línea de trabajo

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.

Escrito por el modelo de indexación a partir del texto del issue.

Evaluación

Stack tecnológico
javascript, react
Área
frontend, security
Tipo de issue
Error
Dificultad
4/5
Tiempo estimado
3-5 días
Estado de actividad
Tranquilo
Claridad
Bastante claro
Aptitud para principiantes
55/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.