Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

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

Open
#2,320 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

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

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.

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.

// packages/web/src/components/search/SearchBox.js:1159
<img src={XSS(props.iconURL)} alt="search-icon" />
// packages/web/src/components/basic/SelectedFilters.js:144
<img width="30px" alt="thumbnail" src={imageValue} />

The xss library strips HTML/JS from strings, but <img src="javascript:..."> 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:

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

Dominant language
JavaScript
Stars
4.9k
Forks
480
PR merge metrics
No merged PRs in 30d

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from appbaseio/reactivesearch

All issues in appbaseio/reactivesearch

Similar issues

More JavaScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.