appbaseio / appbaseio/reactivesearch

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

Open
#2,320 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
4.9k
Forks
478
PR merge metrics
No merged PRs in 30d

Description

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

Contributor guide

Open the contributing guide

Research direction

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.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, react
Domain
frontend, security
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.