Skip to content

fix(webserver): whitelist search sort param before storing it in the session - #107

Merged
ngosang merged 1 commit into
amule-org:masterfrom
ngosang:fix/search-sort-whitelist
Jun 11, 2026
Merged

fix(webserver): whitelist search sort param before storing it in the session#107
ngosang merged 1 commit into
amule-org:masterfrom
ngosang:fix/search-sort-whitelist

Conversation

@ngosang

@ngosang ngosang commented Jun 11, 2026

Copy link
Copy Markdown
Member

The search page stored the raw ?sort= query parameter into $_SESSION["search_sort"], unlike the downloads, shared and servers pages, which already validate it against the column keys my_cmp() understands before persisting it (the #869 whitelist pattern).

Although the value stored in the session is not currently echoed back into HTML (the "update search results" link reflects only the already-whitelisted per-request value), keeping an attacker-controlled string in the session is a latent reflected-XSS hazard: any future template change printing that variable would become exploitable.

Apply the same string-equality whitelist (size|name|sources) used by the other three sortable pages. Unknown values drop to "", which falls through to the existing "keep current sort" branch, so behaviour for valid links is unchanged and garbage values no longer toggle the sort-reverse flag either.

Verified against a running amuleweb: ?sort=name and ?sort=sources still sort and are reflected in the update link; ?sort="><script>alert(1) </script> is not reflected anywhere in the response and the page renders normally.

…session

The search page stored the raw ?sort= query parameter into
$_SESSION["search_sort"], unlike the downloads, shared and servers
pages, which already validate it against the column keys my_cmp()
understands before persisting it (the amule-project#869 whitelist pattern).

Although the value stored in the session is not currently echoed back
into HTML (the "update search results" link reflects only the
already-whitelisted per-request value), keeping an attacker-controlled
string in the session is a latent reflected-XSS hazard: any future
template change printing that variable would become exploitable.

Apply the same string-equality whitelist (size|name|sources) used by
the other three sortable pages. Unknown values drop to "", which falls
through to the existing "keep current sort" branch, so behaviour for
valid links is unchanged and garbage values no longer toggle the
sort-reverse flag either.

Verified against a running amuleweb: ?sort=name and ?sort=sources still
sort and are reflected in the update link; ?sort="><script>alert(1)
</script> is not reflected anywhere in the response and the page
renders normally.
@ngosang
ngosang merged commit 47ef45a into amule-org:master Jun 11, 2026
10 checks passed
@ngosang
ngosang deleted the fix/search-sort-whitelist branch June 11, 2026 17:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant