Incomplete HTML escaping by Xapian::MSet::snippet()

Olly Betts via Xapian-discuss <[email protected]>
Newsgroups gmane.comp.search.xapian.general
Message-ID <[email protected]>
Hello folks,

Back in 2018 I spotted that the HTML escaping done by
Xapian::MSet::snippet() was incomplete.  We fixed this at the time, but
this week Arpit Jain spotted that we'd missed fixing a corner case.

This affects 2.0.0 and 1.4.x for x <= 22.  Hopefully nobody is still
using 1.2.x, but that is unaffected as it didn't have MSet::snippet().

I released 1.4.23 and 2.0.1 today which both include a fix.  If you want
to cherry-pick the fix and apply it to an older release, you can find
patches at:

https://trac.xapian.org/wiki/SecurityFixes/2018-07-02#a2026-08-13update

The bug is that no escaping happens if empty strings are passed for both
hi_start and hi_end, and text.size() <= length.

If those conditions can be triggered, there's potential for an attacker
who can feed documents into a system to inject HTML markup into results
pages for some searches.

We suspect empty highlighting strings are an unusual way to use this
method and haven't managed to find any real world example of such use,
but the fix is small and unlikely to cause problems so we recommend
applying it, or auditing your code to check it doesn't call
MSet::snippet() in this way.

If you maintain packages of xapian-core, I'd strongly encourage you to
upgrade to a fixed version or apply the patch (I'm working through the
process of doing so for Debian, where I also maintain packages of
xapian-core).

Cheers,
    Olly
signature.asc (application/pgp-signature, 833 B)
-----BEGIN PGP SIGNATURE-----

iQIzBAABCgAdFiEECOJAD/f+j+3jrLUoGBR7BzutKwcFAmp+ds0ACgkQGBR7Bzut
Kwc2+xAAtyhulcsrxer08pEmTfUe6QIgV23NKeVRSe+f61OQAD+JrEbW3UldSo7L
L/EATRHf6j3QLxvHid8mwU4sXtqAYtQ/UL3t5AaT9bFov48JahATKdAFKAJjT9cv
Pai/o8a6Ps9vvt4Tk/2Ux5IaVOxOhwu10C0DfRM64Mvvyn9k3RcvsP3uIxCg/az7
wjd0q1ZqxTag5J6k2j8ujjtmtCGl09TZ/GxYAqTXT71nWZQ3fmcyWLQgiIHofYON
9Pffi/y2Edk9MmF1l0u0cXMXe7Q4tZhcN9QQjWUFiR9rAyty4E3G3KIvbhoteQx3
6aOhufFywFyMk86AI7pHiVSJdioDGE6R03JLcLgxvk7oknqRDMJDAp7y0J3W34kr
CDT3ybv6QTphTiw4RW6Mknf9IMGnQsBnttoBhCbDlRNVDjACJFzW0zJg2lG59t1t
PuhvMWUlPqBJiTrqDkMzUwIiasPPlPz13V1shGXKWL6uUoGAKT5U9U4N883unfsn
cdBgjftZ/Ni+wBM4s0u5En2NymH/SZODUTOdHFpLAZztyis+keSk+S7vf4VGE8Sh
PJq1LisgGTSzeXFB5ASWPRTjc+7wdDSmWfTqgkZhVjjlGivIVHJ1W/Lf+oBqQLSk
d+//o3oy2sHJQ26jqyiii4SNT/Ne12qw/y3u8t2TO2Wn7uc3dkY=
=6JqO
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.